ronaldoguedess Posted January 3, 2014 Share Posted January 3, 2014 (edited) I would like to know how to identify that attack the player sticks his knife in the ped, wanted to create a function, but how to identify it? é uma dessas animações: setPedAnimation ( source, "knife", "KILL_Knife_Player", -1, false, false, true) setPedAnimation ( ptarget, "knife", "KILL_Knife_Ped_Damage", -1, false, false, true) Edited January 3, 2014 by Guest Link to comment
Plean Posted January 3, 2014 Share Posted January 3, 2014 onPlayerStealthKill onClientPlayerStealthKill Link to comment
ronaldoguedess Posted January 3, 2014 Author Share Posted January 3, 2014 Thank you! I tried to use this example file on the server and did not return anything. PED killed and nothing happened. function onStealthKill(source) outputChatBox("Stealth kill!", source) end addEventHandler("onPlayerStealthKill", getRootElement(), onStealthKill) Link to comment
Plean Posted January 3, 2014 Share Posted January 3, 2014 function onStealthKill(target) outputChatBox("Stealth kill!", source) end addEventHandler("onPlayerStealthKill", getRootElement(), onStealthKill) Link to comment
ronaldoguedess Posted January 3, 2014 Author Share Posted January 3, 2014 I got it! Thank you! However, something went wrong and I can not identify the player who gave the knife. The "Source" is PED And I do not know what I am. if killer then pedsalive = pedsalive - 1 setElementData(killer, "pedskilled", getElementData(killer, "pedskilled") + 1) end I can not receive data from the player that the attack took place. tried and "thePlayer" and "Player". Solution? Link to comment
Plean Posted January 3, 2014 Share Posted January 3, 2014 The "source" is player, who stealth killed ped/player. Link to comment
ronaldoguedess Posted January 3, 2014 Author Share Posted January 3, 2014 yes, but in my ta the contrary. The Source this being the "PED" who was killed! Is there another way I can get my player? Link to comment
Drakath Posted January 3, 2014 Share Posted January 3, 2014 targetPlayer is the victim. Source is the killer. Link to comment
ronaldoguedess Posted January 5, 2014 Author Share Posted January 5, 2014 Does it have something wrong? I Can not Get the "Source" and not the "targetPlayer". Client _________________________________ function onStealthKill(source, targetPlayer) triggerServerEvent("onPedGetsKilledStealthKill", source, targetPlayer) end addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), onStealthKill) Server ___________________________________ function PedKilledgggg(source, targetPlayer) if source then setElementData(source, "Pedkilled", getElementData(source, "Pedkilled") + 1) end end addEvent("onPedGetsKilledStealthKill", true) addEventHandler("onPedGetsKilledStealthKill", getRootElement(), PedKilledgggg) Hugs Link to comment
DNL291 Posted January 5, 2014 Share Posted January 5, 2014 function onStealthKill(targetPlayer) if (not wasEventCancelled()) then triggerServerEvent("onPedGetsKilledStealthKill", source, targetPlayer) end end addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), onStealthKill) Link to comment
Moderators IIYAMA Posted January 8, 2014 Moderators Share Posted January 8, 2014 Does it have something wrong? I Can not Get the "Source" and not the "targetPlayer".Client _________________________________ function onStealthKill(source, targetPlayer) triggerServerEvent("onPedGetsKilledStealthKill", source, targetPlayer) end addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), onStealthKill) Server ___________________________________ function PedKilledgggg(source, targetPlayer) if source then setElementData(source, "Pedkilled", getElementData(source, "Pedkilled") + 1) end end addEvent("onPedGetsKilledStealthKill", true) addEventHandler("onPedGetsKilledStealthKill", getRootElement(), PedKilledgggg) Hugs Why waste the source? why waste data? The source isn't a parameter, it something that get created automatic when an event got trigged. function onStealthKill(source, targetPlayer) triggerServerEvent("onPedGetsKilledStealthKill", source, targetPlayer) end addEventHandler("onClientPlayerStealthKill", getLocalPlayer(), onStealthKill) function PedKilledgggg(targetPlayer) if isElement(source) then setElementData(source, "Pedkilled", getElementData(source, "Pedkilled") + 1) end end addEvent("onPedGetsKilledStealthKill", true) addEventHandler("onPedGetsKilledStealthKill", getRootElement(), PedKilledgggg) Also:(bugged) setElementData(source, "Pedkilled", getElementData(source, "Pedkilled") + 1) setElementData(source, "Pedkilled", (getElementData(source, "Pedkilled")or 0) + 1) BTW: If you don't do anything extra clientside, then do it serverside, as you did first. https://wiki.multitheftauto.com/wiki/On ... tealthKill 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