Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use math.ceil instead of math.Round #53

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/mapvote/client/modules/map_vote.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function MapVote.StartVote( maps, endTime )
timer.Remove( "MapVoteCountdown" )
return
end
local timeLeft = math.Round( math.Clamp( endTime - CurTime(), 0, math.huge ) )
local timeLeft = math.ceil( math.Clamp( endTime - CurTime(), 0, math.huge ) )

countdownLabel:SetText( string.FormattedTime( timeLeft or 0, "%02i:%02i" ) )
end )
Expand Down
6 changes: 3 additions & 3 deletions lua/mapvote/server/modules/rtv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function RTV.ShouldChange()

if totalPlayers == 0 then return end

return totalVotes >= math.Round( totalPlayers * conf.RTVPercentPlayersRequired )
return totalVotes >= math.ceil( totalPlayers * conf.RTVPercentPlayersRequired )
end

function RTV.StartIfShouldChange()
Expand Down Expand Up @@ -99,7 +99,7 @@ function RTV.AddVote( ply )
timer.Simple( 0, function()
if not ply:IsValid() then return end
MsgN( ply:Nick() .. " has voted to change the map." )
local percentage = math.Round( RTV.GetPlayerCount() * conf.RTVPercentPlayersRequired )
local percentage = math.ceil( RTV.GetPlayerCount() * conf.RTVPercentPlayersRequired )
PrintMessage( HUD_PRINTTALK,
ply:Nick() .. " has voted to change the map. (" .. RTV.GetVoteCount() .. "/" .. percentage .. ")" )
end )
Expand Down Expand Up @@ -127,7 +127,7 @@ function RTV.CanVote( ply )
if ply.RTVVoted then
return false,
string.format( "You have already voted to change the map! (%s/%s)", RTV.GetVoteCount(),
math.Round( RTV.GetPlayerCount() * conf.RTVPercentPlayersRequired ) )
math.ceil( RTV.GetPlayerCount() * conf.RTVPercentPlayersRequired ) )
end

if MapVote.state.isInProgress then
Expand Down
Loading