diff --git a/[admin]/admin2/client/main/admin_automatic-scripts.lua b/[admin]/admin2/client/main/admin_automatic-scripts.lua
new file mode 100644
index 000000000..39e290ac6
--- /dev/null
+++ b/[admin]/admin2/client/main/admin_automatic-scripts.lua
@@ -0,0 +1,147 @@
+--[[**********************************
+*
+* Multi Theft Auto - Admin Panel
+*
+* client\main\admin_server.lua
+*
+* Original File by lil_Toady
+*
+**************************************]]
+addEvent("aOnAutomaticScriptChange", true)
+addEvent("aReceiveAutoScripts", true)
+
+local aAutoScripts = {}
+
+aAutoScripts["pingkicker"] = {
+ state = nil,
+ timer = nil,
+ limit = 300,
+ checkInterval = 3000,
+ toggle = function(state)
+ if isElement(aServerTab.PingKickerCheck) then
+ guiCheckBoxSetSelected(aServerTab.PingKickerCheck, state)
+ end
+ if isElement(aServerTab.PingKicker) then
+ guiSetText(aServerTab.PingKicker, aAutoScripts["pingkicker"].limit)
+ end
+ end,
+ execute = function()
+ local myPing = getPlayerPing(localPlayer)
+ if (myPing > aAutoScripts["pingkicker"].limit) then
+ triggerServerEvent("aAutomaticScriptKick", localPlayer, ("ping exceeded the limit (%i > %i)"):format(myPing, aAutoScripts["pingkicker"].limit))
+ end
+ end
+}
+
+aAutoScripts["fpskicker"] = {
+ state = nil,
+ timer = nil,
+ limit = 10,
+ checkInterval = 3000,
+ toggle = function(state)
+ if isElement(aServerTab.FPSKickerCheck) then
+ guiCheckBoxSetSelected(aServerTab.FPSKickerCheck, state)
+ end
+ if isElement(aServerTab.FPSKicker) then
+ guiSetText(aServerTab.FPSKicker, aAutoScripts["fpskicker"].limit)
+ end
+ end,
+ execute = function()
+ local myFPS = getCurrentFPS(localPlayer)
+ if (myFPS < aAutoScripts["fpskicker"].limit) then
+ triggerServerEvent("aAutomaticScriptKick", localPlayer, ("fps below the limit (%i < %i)"):format(myFPS, aAutoScripts["fpskicker"].limit))
+ end
+ end
+}
+
+aAutoScripts["idlekicker"] = {
+ state = nil,
+ timer = nil,
+ limit = 60,
+ checkInterval = 3000,
+ lastAction = getTickCount(),
+ toggle = function(state)
+ if isElement(aServerTab.IdleKickerCheck) then
+ guiCheckBoxSetSelected(aServerTab.IdleKickerCheck, state)
+ end
+ if isElement(aServerTab.IdleKicker) then
+ guiSetText(aServerTab.IdleKicker, aAutoScripts["idlekicker"].limit)
+ end
+ end,
+ execute = function()
+ local idleTime = (getTickCount() - aAutoScripts["idlekicker"].lastAction)
+ local max = aAutoScripts["idlekicker"].limit * 60000
+ if (idleTime > max) then
+ triggerServerEvent("aAutomaticScriptKick", localPlayer, ("more than %i minutes afk"):format(aAutoScripts["idlekicker"].limit))
+ end
+ end
+}
+
+function toggleAutomaticScript(scriptName, state)
+ if (not aAutoScripts[scriptName]) then
+ return false
+ end
+ if (state == aAutoScripts[scriptName].state) then
+ return false
+ end
+ if state then
+ aAutoScripts[scriptName].timer = setTimer(aAutoScripts[scriptName].execute, aAutoScripts[scriptName].checkInterval, 0)
+ else
+ if isTimer(aAutoScripts[scriptName].timer) then
+ killTimer(aAutoScripts[scriptName].timer)
+ end
+ aAutoScripts[scriptName].timer = nil
+ end
+ aAutoScripts[scriptName].state = state
+end
+
+function getAutomaticScriptInfo(scriptName, info)
+ return aAutoScripts[scriptName] and aAutoScripts[scriptName][info] or false
+end
+
+addEventHandler(
+ "aOnAutomaticScriptChange",
+ resourceRoot,
+ function(scriptName, info)
+ if (not aAutoScripts[scriptName]) then
+ return false
+ end
+ aAutoScripts[scriptName].limit = info.limit
+ toggleAutomaticScript(scriptName, info.state)
+ end
+)
+addEventHandler(
+ "aReceiveAutoScripts",
+ localPlayer,
+ function(info)
+ for k, v in pairs(info) do
+ if aAutoScripts[k] then
+ aAutoScripts[k].limit = v.limit
+ toggleAutomaticScript(k, v.state)
+ end
+ end
+ end
+)
+addEventHandler(
+ "onClientResourceStart",
+ resourceRoot,
+ function()
+ triggerServerEvent("aRequestAutomaticScripts", resourceRoot)
+ end
+)
+
+local fps = 0
+
+function getCurrentFPS()
+ return fps
+end
+
+addEventHandler("onClientPreRender", root, function(delta)
+ fps = (1 / delta) * 1000
+end)
+
+local function detectAction()
+ aAutoScripts["idlekicker"].lastAction = getTickCount()
+end
+addEventHandler("onClientKey", root, detectAction)
+addEventHandler("onClientCursorMove", root, detectAction)
diff --git a/[admin]/admin2/client/main/admin_server.lua b/[admin]/admin2/client/main/admin_server.lua
index 91ef19a64..7584662b8 100644
--- a/[admin]/admin2/client/main/admin_server.lua
+++ b/[admin]/admin2/client/main/admin_server.lua
@@ -101,25 +101,19 @@ function aServerTab.Create(tab)
guiCreateHeader(0.02, 0.755, 0.30, 0.035, "Automatic scripts:", true, tab)
aServerTab.PingKickerCheck =
- guiCreateCheckBox(0.03, 0.800, 0.30, 0.04, "Ping Kicker", false, true, tab, "setpingkicker")
- aServerTab.PingKicker = guiCreateEdit(0.35, 0.800, 0.135, 0.04, "300", true, tab)
- aServerTab.PingKickerSet = guiCreateButton(0.50, 0.800, 0.10, 0.04, "Set", true, tab, "setpingkicker")
- guiSetEnabled(aServerTab.PingKicker, false)
- guiSetEnabled(aServerTab.PingKickerSet, false)
+ guiCreateCheckBox(0.03, 0.780, 0.30, 0.04, "Ping Kicker (maximum)", getAutomaticScriptInfo('pingkicker', 'state'), true, tab, "setpingkicker")
+ aServerTab.PingKicker = guiCreateEdit(0.35, 0.780, 0.135, 0.04, getAutomaticScriptInfo('pingkicker', 'limit'), true, tab)
+ aServerTab.PingKickerSet = guiCreateButton(0.50, 0.780, 0.10, 0.04, "Set", true, tab, "setpingkicker")
aServerTab.FPSKickerCheck =
- guiCreateCheckBox(0.03, 0.845, 0.30, 0.04, "FPS Kicker", false, true, tab, "setfpskicker")
- aServerTab.FPSKicker = guiCreateEdit(0.35, 0.845, 0.135, 0.04, "5", true, tab)
- aServerTab.FPSKickerSet = guiCreateButton(0.50, 0.845, 0.10, 0.04, "Set", true, tab, "setfpskicker")
- guiSetEnabled(aServerTab.FPSKicker, false)
- guiSetEnabled(aServerTab.FPSKickerSet, false)
+ guiCreateCheckBox(0.03, 0.825, 0.30, 0.04, "FPS Kicker (minimum)", getAutomaticScriptInfo('fpskicker', 'state'), true, tab, "setfpskicker")
+ aServerTab.FPSKicker = guiCreateEdit(0.35, 0.825, 0.135, 0.04, getAutomaticScriptInfo('fpskicker', 'limit'), true, tab)
+ aServerTab.FPSKickerSet = guiCreateButton(0.50, 0.825, 0.10, 0.04, "Set", true, tab, "setfpskicker")
aServerTab.IdleKickerCheck =
- guiCreateCheckBox(0.03, 0.890, 0.30, 0.04, "Idle Kicker", false, true, tab, "setidlekicker")
- aServerTab.IdleKicker = guiCreateEdit(0.35, 0.890, 0.135, 0.04, "10", true, tab)
- aServerTab.IdleKickerSet = guiCreateButton(0.50, 0.890, 0.10, 0.04, "Set", true, tab, "setidlekicker")
- guiSetEnabled(aServerTab.IdleKicker, false)
- guiSetEnabled(aServerTab.IdleKickerSet, false)
+ guiCreateCheckBox(0.03, 0.870, 0.30, 0.04, "Idle Kicker (minutes)", getAutomaticScriptInfo('idlekicker', 'state'), true, tab, "setidlekicker")
+ aServerTab.IdleKicker = guiCreateEdit(0.35, 0.870, 0.135, 0.04, getAutomaticScriptInfo('idlekicker', 'limit'), true, tab)
+ aServerTab.IdleKickerSet = guiCreateButton(0.50, 0.870, 0.10, 0.04, "Set", true, tab, "setidlekicker")
guiCreateHeader(0.65, 0.015, 0.30, 0.035, "Allowed glitches:", true, tab)
local i = 1
@@ -266,6 +260,39 @@ function aServerTab.onClientClick(button)
triggerServerEvent("aServer", getLocalPlayer(), "setfpslimit", 36) -- 36 is default
guiSetText(aServerTab.FPS, 36)
end
+ elseif (source == aServerTab.PingKickerSet) then
+ local pinglimit = tonumber(guiGetText(aServerTab.PingKicker))
+ if pinglimit then
+ triggerServerEvent("aServer", getLocalPlayer(), "setpingkicker", pinglimit)
+ else
+ triggerServerEvent("aServer", getLocalPlayer(), "setpingkicker", 300) -- 300 is default
+ guiSetText(aServerTab.PingKicker, 300)
+ end
+ elseif (source == aServerTab.PingKickerCheck) then
+ local state = guiCheckBoxGetSelected(aServerTab.PingKickerCheck)
+ triggerServerEvent("aServer", getLocalPlayer(), "togglepingkicker", state)
+ elseif (source == aServerTab.FPSKickerSet) then
+ local fpslimit = tonumber(guiGetText(aServerTab.FPSKicker))
+ if fpslimit then
+ triggerServerEvent("aServer", getLocalPlayer(), "setfpskicker", fpslimit)
+ else
+ triggerServerEvent("aServer", getLocalPlayer(), "setfpskicker", 10) -- 10 is default
+ guiSetText(aServerTab.FPSKicker, 10)
+ end
+ elseif (source == aServerTab.FPSKickerCheck) then
+ local state = guiCheckBoxGetSelected(aServerTab.FPSKickerCheck)
+ triggerServerEvent("aServer", getLocalPlayer(), "togglefpskicker", state)
+ elseif (source == aServerTab.IdleKickerSet) then
+ local idlelimit = tonumber(guiGetText(aServerTab.IdleKicker))
+ if idlelimit then
+ triggerServerEvent("aServer", getLocalPlayer(), "setidlekicker", idlelimit)
+ else
+ triggerServerEvent("aServer", getLocalPlayer(), "setidlekicker", 60) -- 60 is default
+ guiSetText(aServerTab.IdleKicker, 60)
+ end
+ elseif (source == aServerTab.IdleKickerCheck) then
+ local state = guiCheckBoxGetSelected(aServerTab.IdleKickerCheck)
+ triggerServerEvent("aServer", getLocalPlayer(), "toggleidlekicker", state)
elseif (source == aServerTab.QuickReload) then
triggerServerEvent(
"aServer",
diff --git a/[admin]/admin2/meta.xml b/[admin]/admin2/meta.xml
index 091bc92ce..cfdc33678 100644
--- a/[admin]/admin2/meta.xml
+++ b/[admin]/admin2/meta.xml
@@ -39,6 +39,7 @@
+
@@ -57,6 +58,7 @@
+
@@ -250,23 +252,41 @@
-
-
+
+
-
+