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 ) Failure is simply an opportunity to begin again more intelligently - Henry Ford
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) Currently developing for International Gaming Community - Join us!
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 ) See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
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) Currently developing for International Gaming Community - Join us!
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. See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
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) Failure is simply an opportunity to begin again more intelligently - Henry Ford
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. See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
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? Currently developing for International Gaming Community - Join us!
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) 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
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