tigerman Posted March 13, 2011 Share Posted March 13, 2011 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 ? Link to comment
Moderators Citizen Posted March 13, 2011 Moderators Share Posted March 13, 2011 You can get the playerElement who was in this véhicule like this: local thePlayer = getVehicleController( source ) and give the point to thePlayer Link to comment
tigerman Posted March 13, 2011 Author Share Posted March 13, 2011 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 Citizen Posted March 13, 2011 Moderators Share Posted March 13, 2011 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
tigerman Posted March 13, 2011 Author Share Posted March 13, 2011 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 Link to comment
Moderators Citizen Posted March 13, 2011 Moderators Share Posted March 13, 2011 Yeah sorry my bad, I writen getElementType( source ) instead of getElementType( attacker ) 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 Citizen Posted March 13, 2011 Moderators Share Posted March 13, 2011 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
tigerman Posted March 13, 2011 Author Share Posted March 13, 2011 nothing, when player who dies in vehicle it wount say anything but if he isnt in vehicle then it works fine Link to comment
Moderators Citizen Posted March 13, 2011 Moderators Share Posted March 13, 2011 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 ? Link to comment
tigerman Posted March 13, 2011 Author Share Posted March 13, 2011 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 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