'LinKin Posted August 20, 2013 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. Need a clanwar script? Click here! Do you want some free scripts for your DD server? Visit my website.
Moderators IIYAMA Posted August 20, 2013 Moderators 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). Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
'LinKin Posted August 22, 2013 Author Posted August 22, 2013 It does not work. It still be the same as before. Need a clanwar script? Click here! Do you want some free scripts for your DD server? Visit my website.
iPrestege Posted August 22, 2013 Posted August 22, 2013 Please show the client code when the script trigger 'afkSlap' Event .
'LinKin Posted August 23, 2013 Author 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() Need a clanwar script? Click here! Do you want some free scripts for your DD server? Visit my website.
Ab-47 Posted August 23, 2013 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. And now Aurora is back again, pm for more info. Ex. Lead dev & L6 Staff at AUR, NGC, MTA RP & SAA. Ex. Developer at Community of Social Gamers - CSG Ex Founder of International Gaming Community - IGC and Union of Individual Players- UIP Ab-47
arezu Posted August 23, 2013 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.
xXMADEXx Posted August 23, 2013 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." The Ultimate Lua Tutorial! | MTA PHP SDK
Ab-47 Posted August 23, 2013 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. And now Aurora is back again, pm for more info. Ex. Lead dev & L6 Staff at AUR, NGC, MTA RP & SAA. Ex. Developer at Community of Social Gamers - CSG Ex Founder of International Gaming Community - IGC and Union of Individual Players- UIP Ab-47
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