E-mail Posted August 22, 2011 Share Posted August 22, 2011 Hi all i need to make this script work for BaseMode See Plase Help me !! ---ClientSide afkKeys = {"arrow_l", "arrow_u", "arrow_r", "arrow_d" } afkTimer = nil afkTime = 25000 -- 25 Seconds function pushKey( key, state ) if ( state == "down" ) then if isTimer(afkTimer) then killTimer(afkTimer) afkTimer = setTimer(function() triggerServerEvent ( "onAfkEvent", getLocalPlayer(), afkTime) end, afkTime, 1) else afkTimer = setTimer(function() triggerServerEvent ( "onAfkEvent", getLocalPlayer(), afkTime) end, afkTime, 1) end end end function AfkKeys() setElementData(getLocalPlayer(), "idletime", 0) for key,keyNames in pairs(afkKeys) do bindKey(keynames, "both", pushKey) end end addEventHandler ( "onClientPlayerJoin", getRootElement(), AfkKeys) -- ServerSide MaxAfkTime = 60 -- 1 Minute AfkKickReason = "Afk for "..MaxAfkTime .." Seconds" function onAfkEvent(afkTime) if client then setElementData(client , "idletime", tonumber(getElementData(client , "idletime")+tonumber(afkTime))) afkTime = AfkTime/1000 outputChatBox (getPlayerName(client).." is "..afkTime .." Seconds Afk!", getRootElement()) if afkTime > MaxAfkTime then setElementData(client, "idletime", 0) kickPed ( client, "Afk-Script", AfkKickReason ) end end end addEvent( "onAfkEvent", true ) addEventHandler( "onAfkEvent", getRootElement(), onAfkEvent) -- Coded by Timic Link to comment
HoLsTeN Posted August 22, 2011 Share Posted August 22, 2011 did you try to Change The Event ? it is Idea i dont know if it will work just try Maybe work addEventHandler ( "onClientPlayerJoin", getRootElement(), AfkKeys) Change to addEventHandler ( "OnClientPlayerSpawn", getRootElement(), AfkKeys) Link to comment
E-mail Posted August 22, 2011 Author Share Posted August 22, 2011 i did dont work Thx For try Holsten Link to comment
50p Posted August 22, 2011 Share Posted August 22, 2011 Use onClientResourceStart instead. onClientPlayerJoin is triggered for players who join, but not the local player. addEventHandler ( "onClientResourceStart", getResourceRootElement(), AfkKeys) Link to comment
E-mail Posted August 22, 2011 Author Share Posted August 22, 2011 Thx For Try 50P its not work i start debugscript 3 Nothing show afkKeys = {"arrow_l", "arrow_u", "arrow_r", "arrow_d" } afkTimer = nil afkTime = 25000 -- 25 Seconds function pushKey( key, state ) if ( state == "down" ) then if isTimer(afkTimer) then killTimer(afkTimer) afkTimer = setTimer(function() triggerServerEvent ( "onAfkEvent", getLocalPlayer(), afkTime) end, afkTime, 1) else afkTimer = setTimer(function() triggerServerEvent ( "onAfkEvent", getLocalPlayer(), afkTime) end, afkTime, 1) end end end function AfkKeys() setElementData(getLocalPlayer(), "idletime", 0) for key,keyNames in pairs(afkKeys) do bindKey(keynames, "both", pushKey) end end addEventHandler ( "onClientResourceStart", getResourceRootElement(), AfkKeys) Link to comment
SDK Posted August 22, 2011 Share Posted August 22, 2011 There's a small typo in the last function, keynames and keyNames need to be the same. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now