Jump to content

Blow Vehicle


Recommended Posts

I wrote a script to Blow a vehicle a player is in by entering blowplayer *playername*

However, this also blows all other cars spawned by that player, even if the player is not in them.

How can I make that only the car the player is using right now is blown?

function blowplayer (thePlayer, commandname, target) 
local targetp = getPlayerFromName (target) 
local root = getRootElement (targetp) 
if ( targetp ) then -- Wenn Spieler existiert und in Auto 
if getPedOccupiedVehicle(targetp) then 
blowVehicle ( root ) 
else 
outputChatBox("The selected Player is not in a vehicle", thePlayer) 
end 
else 
outputChatBox("Invalid player specified", thePlayer) 
end 
end 
addCommandHandler ( "blowplayer", blowplayer ) 

Link to comment

You're using getRootElement, that's wrong.

function blowplayer ( thePlayer, commandname, target ) 
    local targetp = getPlayerFromName ( target ) 
    if ( targetp ) then -- Wenn Spieler existiert und in Auto 
        if ( isPedInVehicle ( targetp) ) then -- If the target is on a vehicle .. 
            blowVehicle ( getPedOccupiedVehicle ( targetp ) ) -- Blow his/her vehicle. 
    else 
        outputChatBox ( "The selected Player is not in a vehicle", thePlayer ) 
    end 
    else 
        outputChatBox ( "Invalid player specified", thePlayer ) 
    end 
end 
addCommandHandler ( "blowplayer", blowplayer ) 

Read comments.

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