Jump to content

[Help] Vehicle Destory


3B00DG4MER

Recommended Posts

Posted

Hello,this my old script,i have add some of features

I want this Time when The Black team or White team Enter vehicle destroy it

Client :

  
addEventHandler("onClientVehicleEnter", getRootElement(), 
    function(theVehicle,thePlayer, seat) 
    if(getTeamName(thePlayer) == "WhiteTeam" or getTeamName(thePlayer) == "BlackTeam") then 
    local veh = getVehicleName(theVehicle) 
            destroyElement( veh ) 
        end 
    end 
) 
  

Posted
getTeamName requires a team element, use getPlayerTeam to obtain the team element.

You mean That ?

addEventHandler("onClientVehicleEnter", getRootElement(), 
    function(source,theVehicle,thePlayer, seat) 
    if(getPlayerTeam(source) == "WhiteTeam" or getPlayerTeam(source) == "BlackTeam") then 
    local veh = getVehicleName(theVehicle) 
            destroyElement( veh ) 
        end 
    end 
) 

But nothing Happend :(

Posted

No, getPlayerTeam returns a team element, to get the name you must use

getTeamName ( getPlayerTeam ( thePlayer ) ) 

Like this:

addEventHandler ( "onClientVehicleEnter", getRootElement(), 
    function ( thePlayer ) 
        local teamName = getTeamName ( getPlayerTeam ( thePlayer ) ) 
        if ( teamName == "WhiteTeam" or teamName == "BlackTeam")  then 
            destroyElement ( source ) 
        end 
    end 
) 

Posted
No, getPlayerTeam returns a team element, to get the name you must use
getTeamName ( getPlayerTeam ( thePlayer ) ) 

Now the Error is This

    local vehicleName = getVehicleName ( theVehicle ) 
            destroyElement( vehicleName ) 

Bad Argument

Posted
Do you even know what does getVehicleName do?

it get name of the vehicle

Exactly. You can't destroy a vehicle name, thats not an element. Use Solidsnake's code, that should work.

His Code not work,and There is No bug with his code

Posted

Well, i am not set to help as i am a beginner but i think that should work ( didn't test it )

addEventHandler ( "onClientVehicleEnter", getRootElement(), 
    function ( thePlayer ) 
        local teamName = getTeamName ( getPlayerTeam ( thePlayer ) ) 
        if ( teamName == "WhiteTeam" or teamName == "BlackTeam")  then 
        local theVehicle = getPedOccupiedVehicle ( thePlayer ) 
    destroyElement(theVehicle) 
        end 
    end 
) 

Posted
addEventHandler ( "onVehicleEnter", root, 
    function ( player ) 
        local team = getTeamName ( getPlayerTeam ( player ) ) 
        if ( team == "WhiteTeam" or team == "BlackTeam" ) then 
            destroyElement ( source ) 
        end 
    end 
) 

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