-- prevent clients from flooding others off the server by rapidly changing team/class -- author reyalp@gmail.com -- version 1 - Fri Jun 9 16:12:38 PST 2006 -- -- Configure using these three variables minchangetime = 1000 -- one change per second is always OK maxchanges = 6 -- 6 per second is briefly OK, -- need this fairly high since class scripts use the team command -- and people might cycle through a bunch before they get the class they want -- lua numbers are float, so they get some reduction even if they don't wait a the full time bantime = 300 -- seconds to ban, adjust to taste -- debug --[[ function printf(...) et.G_Print(string.format(unpack(arg))) end --]] limittable = {} function et_ClientCommand( clientNum, command ) -- debug -- printf("ClientCommand %d %s\n",clientNum,command) if string.lower(command) == "team" then if not limittable[clientNum] then limittable[clientNum] = { ["lastchange"] = leveltime, ["count"] = 1, } else -- less typing local rec = limittable[clientNum] rec.count = rec.count + 1 local deltatime = leveltime - rec.lastchange -- shouldn't ever happen if deltatime < 0 then rec.lastchange = leveltime rec.count = 1 return 0 end -- lua numbers are float, so they get some reduction even if they don't wait a the full time local reduce = deltatime / minchangetime -- debug -- printf("count %f lastchange %d delta %d reduce %f\n",rec.count, rec.lastchange, deltatime, reduce) if rec.count >= reduce then rec.count = rec.count - reduce else rec.count = 0 end if rec.count > maxchanges then et.trap_DropClient( clientNum, "too many team changes", bantime ) -- don't count against the next sucker to get this slot rec.count = 0 end rec.lastchange = leveltime end end return 0 end function et_RunFrame(ltime) leveltime = ltime end