Afk script (need only users, not admins?)

Hi, I’m using a script to get the player out if this AFK is.

But I just want you to take out the users, not the administrators

Here is the server.lua:

RegisterServerEvent("kickForBeingAnAFKDouchebag")
AddEventHandler("kickForBeingAnAFKDouchebag", function()
	DropPlayer(source, "You were AFK for too long.")
end)

Here is the client.lua:

-- CONFIG --

-- AFK Kick Time Limit (in seconds)
secondsUntilKick = 180

-- Warn players if 3/4 of the Time Limit ran up
kickWarning = true

-- CODE --

Citizen.CreateThread(function()
	while true do
		Wait(1000)

		playerPed = GetPlayerPed(-1)
		if playerPed then
			currentPos = GetEntityCoords(playerPed, true)

			if currentPos == prevPos then
				if time > 0 then
					if kickWarning and time == math.ceil(secondsUntilKick / 4) then
						TriggerEvent("chatMessage", "WARNING", {255, 0, 0}, "^1You'll be kicked in " .. time .. " seconds for being AFK!")
					end

					time = time - 1
				else
					TriggerServerEvent("kickForBeingAnAFKDouchebag")
				end
			else
				time = secondsUntilKick
			end

			prevPos = currentPos
		end
	end
end)

Thank you and I’m sorry for my english

1 Like

What permission system you using?

Hi, VRP

No need to delete your prior replies and post the same thing just to push a notification. That can be considered spam which is obviously not allowed.

Everyone on this forum helps on a voluntary basis, meaning no one is paid or receive perks etc. for helping and being here on the forums. So be patient and someone will help you soon :slight_smile:

I’m sorry but it was my internet failure, the message was not sent to me, when I realized I deleted it