Jump to content

"onPlayerWasted" attacker problem


tigerman

Recommended Posts

function kill ( ammo, attacker, weapon, bodypart ) 
if (attacker) then 
   outputChatBox ( getPlayerName(source).." killed by "..getPlayerName(attacker), getRootElement(), 255, 255, 255, true ) 
  
end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), kill) 

if player who got killed isnt in vehicle then it works else it dosent .. i dont think this would give me anything if i get his vehicle

Link to comment
  • Moderators

Try like this and try to understand this script too:

function kill ( ammo, attacker, weapon, bodypart ) 
    if (attacker) then 
        if ( getElementType( source ) == "vehicle" ) then -- if the attacker is a vehicle 
            local thePlayer = getVehicleController( attacker ) -- get the playerElement who is driving the car 
            outputChatBox ( getPlayerName(source).." killed by "..getPlayerName( thePlayer ), getRootElement(), 255, 255, 255, true ) 
        elseif ( getElementType( source ) == "player" ) then -- if the attacker is a player 
            outputChatBox ( getPlayerName(source).." killed by "..getPlayerName( attacker ), getRootElement(), 255, 255, 255, true ) 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), kill) 

It should work

Link to comment
  • Moderators

Yeah sorry my bad, I writen getElementType( source ) instead of getElementType( attacker ) :roll:

function kill ( ammo, attacker, weapon, bodypart ) 
    if (attacker) then 
        if ( getElementType( attacker ) == "vehicle" ) then -- if the attacker is a vehicle 
            local thePlayer = getVehicleController( attacker ) 
            outputChatBox ( getPlayerName(source).." killed by "..getPlayerName( thePlayer ), getRootElement(), 255, 255, 255, true ) 
        elseif ( getElementType( attacker ) == "player" ) then -- if the attacker is a player 
            outputChatBox ( getPlayerName(source).." killed by "..getPlayerName( attacker ), getRootElement(), 255, 255, 255, true ) 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), kill) 

Link to comment
  • Moderators

Try this and see my ouputChatBox in this code:

function kill ( ammo, attacker, weapon, bodypart ) 
    if (attacker) then 
        if ( getElementType( attacker ) == "vehicle" ) then -- if the attacker is a vehicle 
            local thePlayer = getVehicleController( attacker ) 
            outputChatBox ( getPlayerName(source).." killed by "..getPlayerName( thePlayer ) ) 
        elseif ( getElementType( attacker ) == "player" ) then -- if the attacker is a player 
            outputChatBox ( getPlayerName(source).." killed by "..getPlayerName( attacker ) ) 
        end 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), kill) 

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