Jump to content

anti afk


DirTyMaN

Recommended Posts

On 17/04/2019 at 02:15, Ab-47 said:

Could you be more specific about what you want?

I could walk you through setting it up or creating one yourself. 

Hi, I'm going to kick off a player who has been afk-free for more than 30 minutes without sleep, and the player who wanted to afk for more than 5 minutes has kicked off the chats for all the server's player, and the playerName Kicked By ParsMTA -Bot Reason: Afk 30min withou sleep, something like this or the like. I'm glad to explain the complete separation of the client file and the file server and the meta inside them what to write.

Link to comment

Im not partidary of doing the code for other people who don't even try to do it,  but you are a lucky day.

BTW: Not tested

I bassed anti-afk keys assuming that the player is in vehicle due to I have never worked about the movement of player out the vehicle.

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

--##Server Side
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)

Regards.

Link to comment
On 18/04/2019 at 20:52, AlirezaPlus said:

this is not bad.

but i am beginner

please :

client 

server 

meta


Explain

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

Edited by Ayush Rathore
  • Like 1
  • Thanks 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...