Using @Overkillz script
Make a folder in resource directory named antiafk
make three files: afk_c.lua, afk_s.lua, meta.xml
in afk_s.lua paste:
function kickPlayerFromServer()
kickPlayer (source)
outputChatBox(getPlayerName(source).." #ffffffhas been kicked by ANTI-AFK BOT",root,255,255,255,true)
end
addEvent("onkickPlayerFromServer",true)
addEventHandler("onkickPlayerFromServer",getRootElement(),kickPlayerFromServer)
in afk_c.lua paste:
local afkTime = 30 --In Minutes
local antiAFKkeys = {"accelerate", "vehicle_left", "vehicle_right", "brake_reverse"} --Check out more keys at https://wiki.multitheftauto.com/wiki/Key_names
kickerTimer = setTimer(function()
triggerServerEvent("onkickPlayerFromServer",localPlayer)
end,afkTime*1000*60,1)
function afkReset()
resetTimer(kickerTimer)
end
do
for i,key in ipairs(antiAFKkeys) do
bindKey ( key, "down", afkReset )
end
end
in meta.xml paste this:
<meta>
<info author="OVERKILLZ" type="script" name="ANTI-AFK" />
<script src="afk_c.lua" type="client" cache="false" />
<script src="afk_s.lua" type="server" />
</meta>
Now go to your server window and type refresh or refreshall and then type start antiafk