Jump to content

onPlayerWasted


myonlake

Recommended Posts

Hello,

I guess I am too tired (once again) to understand this one.

I am trying to see if the player is the killer of someone.

function onKill(ammo, killer, weapon, bodypart) 
    if killer == thePlayer then 
        outputChatBox("You killed a player", thePlayer, 255, 255, 255, false) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onKill) 
 

Let me guess, it's just one of those tiny things that I've made wrong/forgotten..

This is just for one bigger script that I'm doing.

Edited by myonlake
Link to comment
function onKill(ammo, killer, weapon, bodypart) 
    if (source and getElementType(source) == "player") then 
        outputChatBox("You killed a player", thePlayer, 255, 255, 255, false) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onKill) 

What I get from what you said is that you want to check if the player/ped you've just killed is a player.

Link to comment

"thePlayer" does not exists in your script...

function onKill(ammo, killer, weapon, bodypart) 
    if (killer and killer ~= source) then 
        outputChatBox("You killed a player", killer, 255, 255, 255, false) 
        givePlayerMoney(killer, 100) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), onKill) 

This should give $100 to the killer.

Link to comment

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...