XxRomxX Posted July 21, 2013 Share Posted July 21, 2013 Necesito un AFK Que no de slap que de kick donde puedo encontrarlo? Link to comment
Atouk Posted July 22, 2013 Share Posted July 22, 2013 Fijate en la parte donde diga que le saca vida o slap cambiasela y ponele kickPlayer Link to comment
XxRomxX Posted July 22, 2013 Author Share Posted July 22, 2013 Bueno,Ya lo tengo kickea todo,pero salen estos 2 errores 1°WARNING: AntiAFK\Server.lua:88: Bad argument @ 'getPlayerName' [Expected element at argument 1] 2°ERROR: AntiAFK\Server.lua:88: attempt to concatenate a boolean value Link to comment
MTA Team 0xCiBeR Posted July 22, 2013 MTA Team Share Posted July 22, 2013 Postea el script Link to comment
Sasu Posted July 22, 2013 Share Posted July 22, 2013 En la wiki, hay un script, justo lo que queres. function checkAFKPlayers() for index, thePlayer in ipairs(getElementsByType("player"))do -- Loop all online players if (getPlayerIdleTime(thePlayer) > 300000) then -- Player hasn't moved for 300,000ms (5 minutes) kickPlayer(thePlayer, "Idle for 5 minutes") -- Kick the idle player end end end setTimer(checkAFKPlayers, 30000, 0) -- Timer to execute every 30 seconds, checking for idlers https://wiki.multitheftauto.com/wiki/GetPlayerIdleTime Link to comment
Sasu Posted July 22, 2013 Share Posted July 22, 2013 Hace falta el client? No. Y recuerda agregarlo al ACL Admin. Link to comment
XxRomxX Posted July 22, 2013 Author Share Posted July 22, 2013 Lo coloque,Pero no me kickea Link to comment
FraN-724 Posted July 22, 2013 Share Posted July 22, 2013 Buscate uno en la comunidad, hay muchos y solo le quitas para que no te de slap y solo que te de kick. Link to comment
XxRomxX Posted July 22, 2013 Author Share Posted July 22, 2013 Server --***********************************-- --***********************************-- -- Anti AFK System -- -- By Al3grab -- -- Server Side -- --***********************************-- --***********************************-- ----------- CHANGEABLE AFK_TIME = 1 -- the time that if the player didn't moved he will be AFK , in minutes . AFK_TIMES = 5 -- afk times before the player get kicked . SHOW,AFK_MSG = true -- show the afk message [true or false msgs = true -- show messages on chat box ? ----------- function onResourceStart() -- outputDebugString("Anti-AFK By Al3grab | Started") -- startCheck() end addEventHandler("onResourceStart",resourceRoot,onResourceStart) function startCheck() checkTimer = setTimer ( function() for i,m in ipairs ( getElementsByType("player") ) do local idle = getPlayerIdleTime(m) if tonumber(idle) >= AFK_TIME * 60 * 1000 then if not isPlayerAfk(m) then -- the player is afk triggerEvent("onPlayerAfk",m,m,idle) end else local afk = isPlayerAfk(m) if ( afk == true ) then -- the player was afk and now he is back ! triggerEvent("onPlayerAfkBack",m,m) end end end end , 1000 , 0 ) end addEvent("onPlayerAfk",true) addEventHandler("onPlayerAfk",root,function ( Player , Time ) ------ if SHOW then if ( tostring ( AFK_MSG ) ) then showAfkMessage(Player,true) end end ------ setPlayerAfk(Player,true) ------ end ) addEvent("onPlayerAfkBack",true) addEventHandler("onPlayerAfkBack",root,function ( Player ) setPlayerAfk(source,false) ------ showAfkMessage(source,false) ------ end ) function isPlayerAfk(Player) local afk = getElementData(Player,"State-AFK") or false return afk end function setPlayerAfk(Player,state) setElementData(Player,"State-AFK",state or false) end function showAfkMessage(Player,state) if state == true then ev = "YouAreAFK" else ev = "YouAreNotAFK" end triggerClientEvent(Player,tostring(ev) or "YouAreAFK",Player) end function onAfkEnd(Player) Player = Player or source -- setElementData(Player,"AFKtime",getElementData(Player,"AFKtime") + 1 ) local afkTimes = getElementData(Player,"AFKtime") if ( afkTimes and afkTimes >= AFK_TIMES ) then kickPlayer(Player,"You Have Been Afk For : "..tonumber(AFK_TIME).." Minutes") if msgs then outputChatBox("** #FFFF00"..getPlayerName(Player).."#FFFF00 Has Been kicked for being afk ["..afkTimes.."]",root,255,0,0,true) end else killPed(Player) if msgs then outputChatBox("** #FFFF00"..getPlayerName(Player).."#FFFF00 Has Been slapped for being afk ["..afkTimes.."]",root,255,0,0,true) end end end addEvent("KillAFK",true) addEventHandler("KillAFK",root,onAfkEnd) client --***********************************-- --***********************************-- -- Anti AFK System For War -- -- By Al3grab -- -- Client Side -- --***********************************-- --***********************************-- -------------- CHANGEABLE NumToCount = 20 -- the number to count before the player get killed / kicked MSGtoShow = "You Are Afk" -- the Message to show CountSpeed = 1500 -- less number will be faster. -------------- UNCHANGEABLE rRoot = getResourceRootElement(getThisResource()) -- Resource Root ,, setElementData(getLocalPlayer(),"AFKtime",0) -- Rest AFK Times For Player setElementData(localPlayer,"State-AFK",false) --- DX --- sw, sh = guiGetScreenSize() -- Get The Screen Size x,y = sw/2,sh/2 -- Using Math to Set The Text in center addEvent("YouAreAFK",true) -- AFK Message Event addEventHandler("YouAreAFK",root, -- AFK Message Event Handler function() -- AFK Message Function function You() -- AFK Message Function dxDrawText( MSGtoShow, x-700,y-497,sw,sh,tocolor ( 0, 0, 0, 255 ), 4, "pricedown","center", "center", false, false, false)-- AFK Message Shaddow dxDrawText( MSGtoShow, x-700,y-500,sw,sh,tocolor ( 255, 255, 0, 255 ), 4, "pricedown","center", "center", false, false, false)-- AFK Message end -- END of AFK Message Function addEventHandler ( "onClientRender",root,You) -- AFK Message Event Handler Count() -- Kill Player Counting Trigger end ) function Count()-- Counting -- Count -- local n = NumToCount -- Count Number local count = ""..n.."" -- Count Number local x,y = sw/2,sh/2 -- Center Text function txt() dxDrawText(" You Will Be Killed After "..count.." Seconds", x-700,y-292,sw,sh,tocolor ( 0, 0, 0, 255 ), 1, "pricedown","center", "center", false, false, false) -- Counting DX dxDrawText(" You Will Be Killed After "..count.." Seconds", x-700,y-295,sw,sh,tocolor ( 255, 0, 0, 255 ), 1, "pricedown","center", "center", false, false, false)-- Counting DX dxDrawText(" Move To Cancel", x-700,y-241,sw,sh,tocolor ( 0, 0, 0, 255 ), 1, "pricedown","center", "center", false, false, false)-- Text DX dxDrawText(" Move To Cancel", x-700,y-243,sw,sh,tocolor ( 255, 0, 0, 255 ), 1, "pricedown","center", "center", false, false, false)-- Text DX end addEventHandler ( "onClientRender" , root ,txt)-- Adding DX Event Handler timer = setTimer ( -- Count function()-- Count n = n - 1 -- Count count = ""..n.."" -- Count playSoundFrontEnd ( 20 )-- Play Sound On Count if n == 0 then -- on Count END triggerServerEvent ("KillAFK", getLocalPlayer()) -- Triggers Killing Function playSoundFrontEnd ( 101 ) -- Play SOund on Count END removeEventHandler ( "onClientRender" , root ,txt) -- Remove DX Text's After Count END removeEventHandler ( "onClientRender",root,You)-- Remove DX Text's After Count END end end , CountSpeed , NumToCount ) -- End Of Count Timer --- Count--- end addEvent("YouAreNotAFK",true) -- Removing Message Event addEventHandler("YouAreNotAFK",root,-- Removing Message Event function()-- Removing Message Function removeEventHandler ( "onClientRender",root,You)-- Removing Message 1 removeEventHandler ( "onClientRender" , root ,txt)-- Removing Message 2 if isTimer(timer) then killTimer(timer)-- Killing The Timer end end ) -- END of Removing Message Event --- DX --- 1 Link to comment
FraN-724 Posted July 22, 2013 Share Posted July 22, 2013 Creo que seria asi server --***********************************-- --***********************************-- -- Anti AFK System -- -- By Al3grab -- -- Server Side -- --***********************************-- --***********************************-- ----------- CHANGEABLE AFK_TIME = 1 -- the time that if the player didn't moved he will be AFK , in minutes . AFK_TIMES = 5 -- afk times before the player get kicked . SHOW,AFK_MSG = true -- show the afk message [true or false msgs = true -- show messages on chat box ? ----------- function onResourceStart() -- outputDebugString("Anti-AFK By Al3grab | Started") -- startCheck() end addEventHandler("onResourceStart",resourceRoot,onResourceStart) function startCheck() checkTimer = setTimer ( function() for i,m in ipairs ( getElementsByType("player") ) do local idle = getPlayerIdleTime(m) if tonumber(idle) >= AFK_TIME * 60 * 1000 then if not isPlayerAfk(m) then -- the player is afk triggerEvent("onPlayerAfk",m,m,idle) end else local afk = isPlayerAfk(m) if ( afk == true ) then -- the player was afk and now he is back ! triggerEvent("onPlayerAfkBack",m,m) end end end end , 1000 , 0 ) end addEvent("onPlayerAfk",true) addEventHandler("onPlayerAfk",root,function ( Player , Time ) ------ if SHOW then if ( tostring ( AFK_MSG ) ) then showAfkMessage(Player,true) end end ------ setPlayerAfk(Player,true) ------ end ) addEvent("onPlayerAfkBack",true) addEventHandler("onPlayerAfkBack",root,function ( Player ) setPlayerAfk(source,false) ------ showAfkMessage(source,false) ------ end ) function isPlayerAfk(Player) local afk = getElementData(Player,"State-AFK") or false return afk end function setPlayerAfk(Player,state) setElementData(Player,"State-AFK",state or false) end function showAfkMessage(Player,state) if state == true then ev = "YouAreAFK" else ev = "YouAreNotAFK" end triggerClientEvent(Player,tostring(ev) or "YouAreAFK",Player) end function onAfkEnd(Player) Player = Player or source -- setElementData(Player,"AFKtime",getElementData(Player,"AFKtime") + 1 ) local afkTimes = getElementData(Player,"AFKtime") if ( afkTimes and afkTimes >= AFK_TIMES ) then kickPlayer(Player,"You Have Been Afk For : "..tonumber(AFK_TIME).." Minutes") if msgs then outputChatBox("** #FFFF00"..getPlayerName(Player).."#FFFF00 Has Been kicked for being afk ["..afkTimes.."]",root,255,0,0,true) end end end addEvent("KillAFK",true) addEventHandler("KillAFK",root,onAfkEnd) Link to comment
Atouk Posted July 22, 2013 Share Posted July 22, 2013 Claro, pero porque no sacas ese outPutChatBox que te dice que lo an kikeado por estar afk 1 ves ._., yo digo que no tendria sentido . Pero vos haces lo que quieras jajja Link to comment
FraN-724 Posted July 22, 2013 Share Posted July 22, 2013 Jajaja solo le quite el killPed, que lo aga él también ps, no todo tenemos que dejarselo listo, tiene que aprender igual. Link to comment
XxRomxX Posted July 23, 2013 Author Share Posted July 23, 2013 Ya Arregle el Problema de "1°WARNING: AntiAFK\Server.lua:88: Bad argument @ 'getPlayerName' [Expected element at argument 1] 2°ERROR: AntiAFK\Server.lua:88: attempt to concatenate a boolean value" Gracias A Todos Por Ayudarme Link to comment
XxRomxX Posted July 23, 2013 Author Share Posted July 23, 2013 El ANTIAFK Era para race y me kickea ami igual al estar specteando a un user Link to comment
EstrategiaGTA Posted July 23, 2013 Share Posted July 23, 2013 No hagas doble-post, usa el boton EDIT. ¿Lo que quieres es que si estás vigilando con Spectate a un usuario, no te eche del servidor? Link to comment
Recommended Posts