'LinKin Posted August 20, 2013 Share Posted August 20, 2013 Hello, I've been working on an AFK Killer / Kicker. I've modified the following function: function afkKill() local car = getPedOccupiedVehicle(source) blowVehicle (car) --setElementHealth( source, 0) end addEvent( "afkSlap", true ) addEventHandler( "afkSlap", getRootElement(), afkKill) *Note: The original funtion did not include the code-lines 2,3. (original function works 100%) When I test the modified function in my local server, it works perfectly. '/debugscript 3' doesn't show any @Bad Argument. But, when I upload it in a hosted server oppened for public, the script doesn't work. While having enabled 'debugscript 3'; the console shows an error by the following statement "@ Bad Argument 'blowVehicle' ". Which causes the script run prematurely (when the player is killed by the first time by the AFK, the 'bug' makes it to keep counting the number of times the played was killed by AFK up to 3 (which is the limit and when the player gets kicked)) as a result, the player gets kicked if he's killed just once by the AFK. Any ideas / solutions related to this problem are welcome. Thanks, LinKin. Link to comment
Moderators IIYAMA Posted August 20, 2013 Moderators Share Posted August 20, 2013 function afkKill() local car = getPedOccupiedVehicle(source) if car then blowVehicle (car) end end addEvent( "afkSlap", true ) addEventHandler( "afkSlap", getRootElement(), afkKill) Make sure he has a car before you try to blow it. You can't blow a boolean(false). Link to comment
'LinKin Posted August 22, 2013 Author Share Posted August 22, 2013 It does not work. It still be the same as before. Link to comment
iPrestege Posted August 22, 2013 Share Posted August 22, 2013 Please show the client code when the script trigger 'afkSlap' Event . Link to comment
'LinKin Posted August 23, 2013 Author Share Posted August 23, 2013 local player = getLocalPlayer() if(AFKtime >= MaxAFKtime) then if (afkCounter <= 4) then triggerServerEvent ( "afkWarn", player, 1, afkCounter) afkCounter = afkCounter+1 triggerServerEvent ( "afkSlap", player) stopWarn() Link to comment
Ab-47 Posted August 23, 2013 Share Posted August 23, 2013 local player = getLocalPlayer() if(AFKtime >= MaxAFKtime) then if (afkCounter <= 4) then triggerServerEvent ( "afkWarn", player, 1, afkCounter) afkCounter = afkCounter+1 triggerServerEvent ( "afkSlap", player) stopWarn() local player = getLocalPlayer() if(AFKtime >= MaxAFKtime) then if (afkCounter <= 4) then triggerServerEvent ( "afkWarn", player, 1, afkCounter) afkCounter = afkCounter+1 triggerServerEvent ( "afkSlap", root, player) stopWarn() Try now. Link to comment
arezu Posted August 23, 2013 Share Posted August 23, 2013 Just a note; Its better to use setElementHealth(source, 0) in this case because if somebody is close to the afk player, they will die too. Link to comment
xXMADEXx Posted August 23, 2013 Share Posted August 23, 2013 local player = getLocalPlayer() if(AFKtime >= MaxAFKtime) then if (afkCounter <= 4) then triggerServerEvent ( "afkWarn", player, 1, afkCounter) afkCounter = afkCounter+1 triggerServerEvent ( "afkSlap", player) stopWarn() local player = getLocalPlayer() if(AFKtime >= MaxAFKtime) then if (afkCounter <= 4) then triggerServerEvent ( "afkWarn", player, 1, afkCounter) afkCounter = afkCounter+1 triggerServerEvent ( "afkSlap", root, player) stopWarn() Try now. You cannot get the vehicle of "root." Link to comment
Ab-47 Posted August 23, 2013 Share Posted August 23, 2013 local player = getLocalPlayer() if(AFKtime >= MaxAFKtime) then if (afkCounter <= 4) then triggerServerEvent ( "afkWarn", player, 1, afkCounter) afkCounter = afkCounter+1 triggerServerEvent ( "afkSlap", player) stopWarn() local player = getLocalPlayer() if(AFKtime >= MaxAFKtime) then if (afkCounter <= 4) then triggerServerEvent ( "afkWarn", player, 1, afkCounter) afkCounter = afkCounter+1 triggerServerEvent ( "afkSlap", root, player) stopWarn() Try now. You cannot get the vehicle of "root." root = rootElement, the function is being triggered across file types, I think root is moreover recommended. We aren't stating the vehicle in this side of the function, that all comes on the other file. 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