Jump to content

Need help spawn vehicle(only one team)


Ryan123

Recommended Posts

in this script I want spawn one car with occupation(scoreboard), not team.Example:

mtascreen20120522191748.png

and here is the script:

for i,marker in ipairs(markers) do 
addEventHandler("onClientMarkerHit", marker, 
    function ( hitElement ) 
    if ( getTeamName(getPlayerTeam(hitElement)) == "Emergency" ) then 
        if (hitElement == localPlayer) then 
            createVehGui ( hitElement ) 
            if (MainGui ~= nil) then 
                guiSetVisible(MainGui, true) 
                showCursor(true) 
                guiSetInputEnabled(true) 
                setElementFrozen(hitElement, true) 
            end 
        end 
    end 
end 
) 
end 

Edited

Edited by Guest
Link to comment

You have to use getElementData.

for i,marker in ipairs ( markers ) do 
addEventHandler ( "onClientMarkerHit", marker, 
    function ( hitElement ) 
        if ( hitElement == localPlayer ) then 
            if ( getElementData ( hitElement, "Occupation" ) == "Medic" ) then 
                createVehGui ( hitElement ) 
                if ( MainGui ~= nil ) then 
                    guiSetVisible ( MainGui, true ) 
                    showCursor ( true ) 
                    guiSetInputEnabled ( true ) 
                    setElementFrozen ( hitElement, true ) 
                end 
            end 
        end 
    end 
) 
end 

Link to comment

hmmm okay.

Other help.when I spawn one sultan I want add color and the siren.

here is the script:

addEvent("spawnVehicle", true) 
addEventHandler("spawnVehicle", root, 
function (vehID) 
    if ( isElement(vehicles[source]) ) then 
        destroyElement(vehicles[source]) 
    end 
    vehicles[source] = createVehicle(vehID, getElementPosition(source)) 
    if sultan then 
      local setsultan = setVehicleColor ( "Sultan" , 6, 183, 248) 
    end 
    warpPedIntoVehicle(source, vehicles[source]) 
    triggerClientEvent("closeWindow", root) 
end 
) 
  

Link to comment
addEvent ( "spawnVehicle", true ) 
addEventHandler ( "spawnVehicle", root, 
    function ( vehID ) 
        if ( isElement ( vehicles [ source ] ) ) then 
            destroyElement ( vehicles [ source ] ) 
        end 
        vehicles [ source ] = createVehicle ( vehID, getElementPosition ( source ) ) 
        if ( vehicles [ source ] ) then -- What is "sultan"?? your vehicle element is: vehicles [ source ] 
            setVehicleColor ( vehicles [ source ], 6, 183, 248 ) -- Here goes the vehicle element, not a string. 
        end 
  
        setTimer ( warpPedIntoVehicle, 200, 1, source, vehicles [ source ] ) 
        triggerClientEvent ( source, "closeWindow", root ) 
    end 
) 

Link to comment
  • 2 months later...

So when I use this, is for destroy when I change Occupation.like this?

  
  
function  destroyelementchanged( vehID ) 
        if not (getElementData(localPlayer == Medic) then 
            destroyElement ( vehicles ) 
        end 
end 
addEventHadler("onElementDataChange",root,destroyelementchanged) 

Link to comment
So when I use this, is for destroy when I change Occupation.like this?
  
  
function  destroyelementchanged( vehID ) 
        if not (getElementData(localPlayer == Medic) then 
            destroyElement ( vehicles ) 
        end 
end 
addEventHadler("onElementDataChange",root,destroyelementchanged) 

No, that doesn't make any sense.

Link to comment

ahhhh, I'm new scripter, and I think, is now fine.Is type this?

addEventHandler("onElementDataChange",getElementRoot(), 
function () 
    if not (getElementData(localPlayer == "Occupation") = "SWAT Member") then 
    vehicles = getElementsByType("vehicle") 
    for i,v in ipairs(vehicle) 
        destroyElement(v) 
    end 
end 
end 
) 

I need help only for choose "getElementData" or "getElementRoot"

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