Skip to content

Commit

Permalink
cmd_limiter: also active when singleplayer but without warnings and f…
Browse files Browse the repository at this point in the history
…orce resign
  • Loading branch information
Ruwetuin authored Mar 25, 2024
1 parent 0cbe84e commit 24c6e17
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions luarules/gadgets/cmd_limiter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ function gadget:GetInfo()
}
end

if gadgetHandler:IsSyncedCode() or Spring.Utilities.Gametype.IsSinglePlayer() then
if gadgetHandler:IsSyncedCode() then
return
end

local historyFrames = 180
local maxCommands = 600
local startWarningOffences = 3
local maxOffences = 6
local isSingleplayer = Spring.Utilities.Gametype.IsSinglePlayer()

local history = {}
local totalCmdCount = 0
Expand All @@ -36,13 +37,15 @@ function gadget:CommandNotify(cmdID, cmdParams, cmdOpts)
if totalCmdCount > maxCommands then
offenceFrames[gf] = true
totalOffence = totalOffence + 1
if totalOffence >= maxOffences then
--Spring.I18N('ui.cmdlimiter.forceresign')
Spring.Echo("\255\255\040\040YOU QUEUED TOO MUCH BUILDINGS TOO MANY TIMES, YOU HAVE BEEN FORCE RESIGNED!")
Spring.SendCommands("spectator")
elseif totalOffence >= startWarningOffences then
--Spring.I18N('ui.cmdlimiter.forceresignwarning')
Spring.Echo("\255\255\085\085YOU HAVE QUEUED TOO MUCH BUILDINGS IN A SHORT PERIOD, KEEP DOING THIS AND YOU WILL GET AUTO RESIGNED!")
if not isSingleplayer then
if totalOffence >= maxOffences then
--Spring.I18N('ui.cmdlimiter.forceresign')
Spring.Echo("\255\255\040\040YOU QUEUED TOO MUCH BUILDINGS TOO MANY TIMES, YOU HAVE BEEN FORCE RESIGNED!")
Spring.SendCommands("spectator")
elseif totalOffence >= startWarningOffences then
--Spring.I18N('ui.cmdlimiter.forceresignwarning')
Spring.Echo("\255\255\085\085YOU HAVE QUEUED TOO MUCH BUILDINGS IN A SHORT PERIOD, KEEP DOING THIS AND YOU WILL GET AUTO RESIGNED!")
end
end
totalCmdCount = totalCmdCount - math.floor(maxCommands/2) -- remove some so user can instantly queue something next without instantly being warned again
return true
Expand Down

0 comments on commit 24c6e17

Please sign in to comment.