Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Dynamic AFK Kick Times v1.1
- -- by H® Shaft
- -- Requested by jakallan3
- -- 2/14/2016 - corrected typo error, and added OnNewGame and OnGameEnd
- -- Script allows server admins to dynamically change AFK Kick times based on the number of players
- -- Editable AFK Time and # of Players
- -- Full Number: if 12 slot server, set to 10, if 16 slots, set to 14 - should not be set equal to the maximum amount of players
- -- how many players constitutes FULL number of players or almost full?
- Full_Players = 10
- -- how many players constitutes medium number of players?
- Medium_Players = 8
- -- how many players constitutes low number of players?
- Low_Players = 6
- -- how many players constitutes few number of players?
- Few_Players = 4
- ------------
- -- Kick Times Strategy: to Keep the server active and have less afk players, the MORE players there are, the LOWER the AFK time:
- -- how quickly in seconds to kick AFKs during a FULL player server?
- Full_Players_AFK_Time = 90
- -- how quickly in seconds to kick AFKs during a MEDIUM player server?
- Medium_Players_AFK_Time = 180
- -- how quickly in seconds to kick AFKs during a LOW player server?
- Low_Players_AFK_Time = 360
- -- how quickly in seconds to kick AFKs during a FEW player server?
- Few_Players_AFK_Time = 0
- -- if the script is UNLOADED, reset the afk kick time to this DEFAULT
- Default_AFK_Time = 0
- -- don't edit --
- api_version = "1.9.0.0"
- Amt_Players = 0
- function OnScriptLoad()
- register_callback(cb['EVENT_JOIN'], "OnPlayerJoin")
- register_callback(cb['EVENT_LEAVE'], "OnPlayerLeave")
- register_callback(cb['EVENT_GAME_START'], "OnNewGame")
- register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
- if get_var(0, "$gt") ~= "n/a" then
- Amt_Players = tonumber(get_var(0, "$pn"))
- if (Amt_Players <= Few_Players) then
- execute_command("afk_kick Few_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Few_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players <= Low_Players) then
- execute_command("afk_kick Low_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Low_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players > Low_Players) and (Amt_Players <= Medium_Players) then
- execute_command("afk_kick Medium_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Medium_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players > Medium_Players) and (Amt_Players <= Full_Players) then
- execute_command("afk_kick Full_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Medium_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- end
- end
- end
- function OnPlayerJoin(PlayerIndex)
- Amt_Players = tonumber(get_var(0, "$pn"))
- if (Amt_Players <= Few_Players) then
- execute_command("afk_kick Few_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Few_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players <= Low_Players) then
- execute_command("afk_kick Low_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Low_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players > Low_Players) and (Amt_Players <= Medium_Players) then
- execute_command("afk_kick Medium_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Medium_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players > Medium_Players) and (Amt_Players <= Full_Players) then
- execute_command("afk_kick Full_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Medium_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- end
- end
- function OnPlayerLeave(PlayerIndex)
- Amt_Players = tonumber(get_var(0, "$pn"))
- if (Amt_Players <= Few_Players) then
- execute_command("afk_kick Few_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Few_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players <= Low_Players) then
- execute_command("afk_kick Low_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Low_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players > Low_Players) and (Amt_Players <= Medium_Players) then
- execute_command("afk_kick Medium_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Medium_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players > Medium_Players) and (Amt_Players <= Full_Players) then
- execute_command("afk_kick Full_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Medium_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- end
- end
- function OnNewGame()
- Amt_Players = tonumber(get_var(0, "$pn"))
- if (Amt_Players <= Few_Players) then
- execute_command("afk_kick Few_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Few_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players <= Low_Players) then
- execute_command("afk_kick Low_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Low_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players > Low_Players) and (Amt_Players <= Medium_Players) then
- execute_command("afk_kick Medium_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Medium_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players > Medium_Players) and (Amt_Players <= Full_Players) then
- execute_command("afk_kick Full_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Medium_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- end
- end
- function OnGameEnd()
- Amt_Players = tonumber(get_var(0, "$pn"))
- if (Amt_Players <= Few_Players) then
- execute_command("afk_kick Few_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Few_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players <= Low_Players) then
- execute_command("afk_kick Low_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Low_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players > Low_Players) and (Amt_Players <= Medium_Players) then
- execute_command("afk_kick Medium_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Medium_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- elseif (Amt_Players > Medium_Players) and (Amt_Players <= Full_Players) then
- execute_command("afk_kick Full_Players_AFK_Time")
- cprint("AFK Kick time was changed to " .. Medium_Players_AFK_Time .. " # of Players: " .. Amt_Players)
- end
- end
- function OnScriptUnload()
- execute_command("afk_kick Default_AFK_Time")
- cprint("AFK Kick time was changed to default of " .. Default_AFK_Time)
- end
- function OnError(Message)
- print(debug.traceback())
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement