Adde Posted June 28, 2013 Share Posted June 28, 2013 Hello, I want to create a script that set the players hp +2 everytime he/she kills a zombie. I have done something like this but it wont work. I don´t know if there is a "onClientPedWasted". Or should I set add health to server side and use triggerServerEvent? client function Zombie(attacker, weapon, bodypart, loss) if (getElementData(source, "zombie") == true) then if ( attacker == player ) then if (getElementHealth(attacker) < 100) then local Heal = getElementHealth(attacker) + 50 killPed(source, attacker, weapon, bodypart) end end end addEventHandler("onClientPedWasted", getRootElement(), Zombie) Link to comment
Dealman Posted June 28, 2013 Share Posted June 28, 2013 There is, onClientPedWasted. Whenever in doubt, always refer to the MTA Wiki since it for the most part has very thorough examples and explanations of how every(most) functions and events work. Also, you'll need to use setElementHealth, not getElementHealth. Link to comment
Adde Posted June 28, 2013 Author Share Posted June 28, 2013 Yes i know but i couldn´t find onClientPedWasted on wiki. Wtf, I din´t notice that Link to comment
Dealman Posted June 28, 2013 Share Posted June 28, 2013 Did you get it to work? I just wrote this up a bit fast, I've never worked with Peds before so it might or might not work Also I got rid of the killPed part since the event is triggered when the ped is killed, I don't see a reason to kill what's already been killed function onClientKillZombie(killer, weapon, bodypart) if (getElementData(source, "zombie") == true) then if(getElementType(killer) == "player") then if(getElementHealth(killer) < 100) then setElementHealth(killer, getElementHealth(killer)+2) end end end end addEventHandler("onClientPedWasted", getRootElement(), onClientKillZombie) Link to comment
Adde Posted June 28, 2013 Author Share Posted June 28, 2013 Did you get it to work?I just wrote this up a bit fast, I've never worked with Peds before so it might or might not work Also I got rid of the killPed part since the event is triggered when the ped is killed, I don't see a reason to kill what's already been killed function onClientKillZombie(killer, weapon, bodypart) if (getElementData(source, "zombie") == true) then if(getElementType(killer) == "player") then if(getElementHealth(killer) < 100) then setElementHealth(killer, getElementHealth(killer)+2) end end end end addEventHandler("onClientPedWasted", getRootElement(), onClientKillZombie) Yea, that works. I did almost the same. But I forgot [ If getElementType(killer) == "player") == true) then ] The reason why I may had some things that not was needed is bcs I copied my zombieheadshot script and replaced playsound with setElementHealth. I didn´t think of delete the "killPed". But thx 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