AlirezaPlus

anti afk

Recommended Posts

Hi I need an anti-afk source
Please give me one and tell me how to set up
I have this source but did not work even with acl access in the admins section

I am a beginner. Please explain well. Thank you for the quick answer.

Share this post


Link to post

There are already a lot of anti-afk resources around the community. Just take some time to search one of them.

Otherwise, you can build your own one using

bindKey
setTimer

 

Share this post


Link to post

Could you be more specific about what you want?

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

Share this post


Link to post
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.

Share this post


Link to post

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.

Share this post


Link to post
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
  • Thanks 1

Share this post


Link to post

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.