Chaos Posted August 15, 2014 Share Posted August 15, 2014 hey, i have a question why this won't abort knife kill when some one trying to kill me ? function onKill() timer1 = setTimer(function() addEventHandler("onClientPlayerStealthKill",localPlayer,abortAllStealthKills) end,20000,1) end addCommandHandler( "peace", onKill) function abortAllStealthKills(targetPlayer) cancelEvent() end Link to comment
Castillo Posted August 15, 2014 Share Posted August 15, 2014 Must be because 'source' in onClientPlayerStealthKill is the player that initiated the stealth kill, not the victim. Change 'localPlayer' in addEventHandler to 'root', and then inside "abortAllStealthKills" function, before cancelEvent ( ), put: if ( targetPlayer == localPlayer ) then end Link to comment
Chaos Posted August 16, 2014 Author Share Posted August 16, 2014 Castillo but i need it abort stealthkill only for me that's mean others can get kill by knife Link to comment
Castillo Posted August 16, 2014 Share Posted August 16, 2014 That's what the code should do, have you tried it? You can also use element data. Link to comment
Chaos Posted August 16, 2014 Author Share Posted August 16, 2014 i tried this but it seems not working function onKill() timer1 = setTimer(function() addEventHandler("onClientPlayerStealthKill",root,abortAllStealthKills) end,3000,1) end addCommandHandler( "peace", onKill) function abortAllStealthKills(targetPlayer) if ( targetPlayer == localPlayer ) then outputChatBox("should now no one can kill you with a knife") cancelEvent() end end Link to comment
Castillo Posted August 16, 2014 Share Posted August 16, 2014 Set a element data when they use /peace and make the addEventHandler defined without having to use a command, then in "abortAllStealthKills" function check if the targetPlayer has that element data. Link to comment
Chaos Posted August 17, 2014 Author Share Posted August 17, 2014 i think you mean something like this function onKill() timer1 = setTimer(function() setElementData(localPlayer,"peace",true) outputChatBox("peace is on !") end,3000,1) end addCommandHandler( "peace", onKill) function abortAllStealthKills(targetPlayer) if getElementData(targetPlayer,"peace") == true then cancelEvent() end end addEventHandler("onClientPlayerStealthKill", root, abortAllStealthKills) Link to comment
Chaos Posted August 17, 2014 Author Share Posted August 17, 2014 it's working perfect thanks a lot Castillo. Link to comment
Storm-Hanma Posted September 25, 2017 Share Posted September 25, 2017 On 8/16/2014 at 17:23, Chaos said: i think you mean something like this function onKill() timer1 = setTimer(function() setElementData(localPlayer,"peace",true) outputChatBox("peace is on !") end,3000,1) end addCommandHandler( "peace", onKill) function abortAllStealthKills(targetPlayer) if getElementData(targetPlayer,"peace") == true then cancelEvent() end end addEventHandler("onClientPlayerStealthKill", root, abortAllStealthKills) how can i add this in freeroam panel?pls its only for on mode how can i make for off mode? for example if i type peace no one can kill me by knife same when i type peace now i can get killed my knife i want this for only a particular player not for all if i typed peace and only i must be in safe not whole server players below is my code i just want to make it for players who enable disable knife mode addCommandHandler("kinfe", function() if not kinfeKill then outputChatBox("#00ff0Server: disableknife mode On!", 0, 255, 0, true) else outputChatBox("#00ff00Server: disableknife mode Off!", 255, 0, 0, true) end kinfeKill = not kinfeKill end) function stopKnifeKill() if kinfeKill then cancelEvent() end end addEventHandler("onClientPlayerStealthKill", localPlayer, stopKnifeKill) addCommandHandler("disableknife", function() if not kinfeKill then outputChatBox("#00ff0Server: disableKnife mode On!", 0, 255, 0, true) else outputChatBox("#00ff00Server: disableKnife mode Off!", 255, 0, 0, true) end kinfeKill = not kinfeKill end) function stopKnifeKill() if kinfeKill then cancelEvent() end end addEventHandler("onClientPlayerStealthKill", localPlayer, stopKnifeKill) this is code 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