Jump to content

killPed help!


Recommended Posts

Posted

Okay Now I've been trying to find the solution but can't.

Here it is. I need something like onPlayerDamage but ped. IsPedDead is not good i tried it. I'm trying to make a resource, when you kill a ped you have an output message. Can somebody help me please?

Nick

Posted (edited)

So i've tried this but this did not work. I guess i did some fatal error

function PedWasted() 
setElementHealth ( killer, 0  )  
outputChatBox( "Just in the middle", player, 255, 0, 0 ) 
end 
addEventHandler("onClientPedWasted", getRootElement(), PedWasted) 
  
  

Edit: It didn't work even. It's for only players. I thought peds are non player npcs in MTA. I've tried this with the citizens resource.

function PedDamage() 
outputChatBox("Just in the middle", player, 255, 0, 0) 
end 
addEventHandler("onClientPedDamage", getRootElement(), PedDamage) 

Edited by Guest
Posted
function PedDamage(player) -- Look this line ! 
outputChatBox("Just in the middle", player, 255, 0, 0) 
end 
addEventHandler("onClientPedDamage", getRootElement(), PedDamage) 

Posted

Thanks. One more thing. In this:

function PedWasted(player) --The player definition goes here i think 
setElementHealth ( killer, 0  )  
outputChatBox( "Just in the middle", player, 255, 0, 0 ) 
end 
addEventHandler("onClientPedWasted", getRootElement(), PedWasted) 
  
  

But how to define killer in this one?

Thank you for helping a beginner

EDIT:These are for only player or NPC's too? Cuz' not working. I'm doing something wrong

  
function PedDamage(player) 
outputChatBox("Just in the middle", player, 255, 0, 0) 
end 
addEventHandler("onClientPedDamage", getRootElement(), PedDamage) 

Posted
function PedWasted(player) --The player definition goes here i think 
setElementHealth ( source, 0  ) 
outputChatBox( "Just in the middle", player, 255, 0, 0 ) 
end 
addEventHandler("onClientPedWasted", getRootElement(), PedWasted) 

Posted

I mean: It works when i kill a player, i die. But when i kill a ped, an npc(don't know what the difference is) it not works. I'm trying this on the citizens resource:https://community.multitheftauto.com/index.php?p=resources&s=details&id=3390

Posted
addEventHandler ( "onPedWasted", root, 
    function ( _, killer ) 
        setElementHealth ( killer, 0 ) 
        outputChatBox ( "Just in the middle", killer, 255, 0, 0 ) 
    end 
) 

That's a server side script.

Posted (edited)

It works thank you so much everyone. But i have an other question: What makes it's serverside? What is the difference between this and above the last script?

Edited by Guest
Posted

Correct me if i'm wrong: The onClientPedWasted is client side, but the OnPedWasted is server sided? And i can't set the player's health in the client just in the server side? I think i'm starting to understand this.

Posted

Just one more thing:

  
addEventHandler ( "onPedWasted", root, 
    function ( _, killer ) 
        setElementHealth ( killer, -50 ) -- It not works 
        outputChatBox ( "Just in the middle", killer, 255, 0, 0 ) 
    end 
) 
  

In clientside it should be working i think. How can i just decrease hp?

Posted

You have to get the player health then decrease it.

addEventHandler ( "onPedWasted", root, 
    function ( _, killer ) 
        setElementHealth ( killer, ( getElementHealth ( killer ) - 50 ) ) 
        outputChatBox ( "Just in the middle", killer, 255, 0, 0 ) 
    end 
) 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...