Jump to content

"onPlayerWasted" attacker problem


tigerman

Recommended Posts

Posted

hey, im trying to make map like battlefield 2 but im having some troubles with onPlayerWasted

if player is in vehicle (source) then the attacker wount get a point, what should i do ?

  • Moderators
Posted

You can get the playerElement who was in this véhicule like this:

local thePlayer = getVehicleController( source )  

and give the point to thePlayer :wink:

Posted
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

  • Moderators
Posted

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

Posted

dosen't work... now i have started thinking about is it even possible to make such script because player attacks vehicle and logically source player vehicle kills source player with its explode

  • Moderators
Posted

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) 

  • Moderators
Posted

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) 

  • Moderators
Posted

Who dies in vehicle ? I understood "killed by a vehicle" lol

So how you kill the other player ? You explode the vehicle or you shoot the player in the vehicle ?

Posted

ok yeah i probably dint say propery what i wanted .. my english isnt the best

but well, i shoot the car with M4 and then car will explode but i wount get kill

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