Xabache Posted February 7, 2015 Posted February 7, 2015 I can get either or here but not both? This can cancel the event, or it can kill the killer, depending on the order of killPed and cancelEvent. But I cant get it to both cancel the death of the Ped and kill the killer. Can I? addEventHandler ( "onClientPlayerStealthKill", root, function ( target ) killPed ( sourcePlayer, sourcePlayer ) cancelEvent ( ) end )
SkatCh Posted February 7, 2015 Posted February 7, 2015 You can't use 'killPed' because it's a server side function try to use triggerServerEvent() addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), function(target) if (target and getElementType(target) == "player" and target ~= source) then triggerServerEvent("KillAttacker",source) cancelEvent() end )
Xabache Posted February 7, 2015 Author Posted February 7, 2015 Okay that works to send the server a KillAttacker event not added serverside... function killAttacker (killer) killPed(killer) outputChatBox ("KARMA:" .. killer ... " is dead",source,0,233,0,true) end Yup no idea what I'm doing...
Tomas Posted February 7, 2015 Posted February 7, 2015 addEvent("KillAttacker",true) function killAttacker (killer) killPed(killer) outputChatBox ("KARMA:" .. killer ... " is dead",source,0,233,0,true) end addEventHandler("KillAttacker",resourceRoot,killAttacker)
Xabache Posted February 7, 2015 Author Posted February 7, 2015 Client: addEventHandler ( "onClientPlayerStealthKill", root, function ( target ) triggerServerEvent("KillAttacker",source) cancelEvent() end ) Server: addEvent("KillAttacker",true) function killAttacker (killer) killPed(killer) outputChatBox ("KARMA:" .. killer .. " is dead",source,0,233,0,true) end addEventHandler("KillAttacker",resourceRoot,killAttacker) No error message. But only canceling the event. The killer is not killed. The KARMA message is not displayed. What's wrong?
Anubhav Posted February 7, 2015 Posted February 7, 2015 Ye . Change triggerServerEvent line to: triggerServerEvent("KillAttacker", source, source )
Tomas Posted February 7, 2015 Posted February 7, 2015 Client: addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), function(target) if (target and getElementType(target) == "player" and target ~= source) then triggerServerEvent("KillAttacker",resourceRoot,source) cancelEvent() end ) Server: addEvent("KillAttacker",true) function killAttacker (killer) killPed(killer) outputChatBox ("KARMA:" .. killer .. " is dead",source,0,233,0,true) end addEventHandler("KillAttacker",resourceRoot,killAttacker)
Xabache Posted February 7, 2015 Author Posted February 7, 2015 Thank you Tomas and Anubhav, but neither suggestion functions. Anubhav's still cancels the event without killing the killer. and Tomas' the victim dies in the event without it being canceled and the killer is not harmed. I want the killer to be struck down as a result of their attempted Stealth Kill.
Anubhav Posted February 7, 2015 Posted February 7, 2015 Use my code and in server 2nd argument of addEventHandler should be root.
SkatCh Posted February 7, 2015 Posted February 7, 2015 Try this : Client addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), function(target) if (target and getElementType(target) == "player" and target ~= source) then triggerServerEvent("KillAttacker",source,source) cancelEvent() end ) Server function killAttacker (killer) killPed(killer) outputChatBox ("KARMA:" .. killer .. " is dead",source,0,233,0,true) end addEvent("KillAttacker",true) addEventHandler("KillAttacker",root,killAttacker)
Anubhav Posted February 7, 2015 Posted February 7, 2015 Try this :Client addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), function(target) if (target and getElementType(target) == "player" and target ~= source) then triggerServerEvent("KillAttacker",source,source) cancelEvent() end ) Server function killAttacker (killer) killPed(killer) outputChatBox ("KARMA:" .. killer .. " is dead",source,0,233,0,true) end addEvent("KillAttacker",true) addEventHandler("KillAttacker",root,killAttacker) Fully same what I told.
Tomas Posted February 7, 2015 Posted February 7, 2015 Use my code andin server 2nd argument of addEventHandler should be root. Why should be root?
Moderators IIYAMA Posted February 8, 2015 Moderators Posted February 8, 2015 When using root in an addEventHandler, it can accept every source element. When you use resourceRoot, it will only accept resourceRoot. This will become the source element from the addEventHandler: triggerServerEvent("KillAttacker",[color=#FF0000]source[/color],source)
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