Jump to content

create an object when a player's car explode


Recommended Posts

Hello, I have this script that creates an object when a player dies:

addEventHandler("onPlayerWasted", getRootElement(), 
    function ()  
            local creator = getPlayerName(source) 
            local fX, fY, fZ = getElementPosition (source) 
            createObject ( 1212, fX, fY, fZ+0.5) 
            triggerClientEvent ( 'play', source ) 
    end 
) 

I have the problem that when the player is dead for afk (and the ped inside the car is killed) the object is created, and I want to create that object only when the player's vehicle is exploded.

I tried to use isVehicleBlown but using it the object is not created, and that don't give me any errors on the debug.

addEventHandler("onPlayerWasted", getRootElement(), 
    function ()  
        local theVehicle = getPedOccupiedVehicle(source) 
        if (theVehicle) then 
            if isVehicleBlown(theVehicle) then 
            local creator = getPlayerName(source) 
            local fX, fY, fZ = getElementPosition (source) 
            createObject ( 1212, fX, fY, fZ+0.5) 
            triggerClientEvent ( 'play', source ) 
            else 
            --nothing 
            end 
        end 
    end 
) 

Link to comment
addEventHandler("onPlayerWasted", root,  
    function() 
        local theVehicle = getPedOccupiedVehicle(source) 
        if isVehicleBlown(theVehicle) then 
            local creator = getPlayerName(source) 
            local x, y, ,z = getElementPosition(source) 
            createObject(1212, x, y, z+0.5) 
            triggerClientEvent(srouce, "play", source) 
        end 
    end) 

Link to comment
addEventHandler("onPlayerWasted", root,  
    function() 
        local theVehicle = getPedOccupiedVehicle(source) 
        if isVehicleBlown(theVehicle) then 
            local creator = getPlayerName(source) 
            local x, y, ,z = getElementPosition(source) 
            createObject(1212, x, y, z+0.5) 
            triggerClientEvent(srouce, "play", source) 
        end 
    end) 

Didn't work, the object is not created and I get this error:

Bad argument @ 'isVehicleBlown' [Expected vehicle at argument 1, got boolean] 

Link to comment

Try this:

addEventHandler ( "onPlayerWasted", root, 
    function ( ) 
        local theVeh = getPedOccupiedVehicle ( source ) 
        if ( theVeh ) then  
            if ( isVehicleBlown ( theVeh ) ) then  
                local creator = getPlayerName ( source ) 
                local x, y, z = getElementPosition ( source ) 
                createObject ( 1212, x, y, z + 0.5 ) 
                triggerClientEvent ( "play", source ) 
            end  
        end 
    end 
) 

Link to comment
Try this:
addEventHandler ( "onPlayerWasted", root, 
    function ( ) 
        local theVeh = getPedOccupiedVehicle ( source ) 
        if ( theVeh ) then  
            if ( isVehicleBlown ( theVeh ) ) then  
                local creator = getPlayerName ( source ) 
                local x, y, z = getElementPosition ( source ) 
                createObject ( 1212, x, y, z + 0.5 ) 
                triggerClientEvent ( "play", source ) 
            end  
        end 
    end 
) 

Didn't work either. And now I don't get any errors on the debug.

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