Jump to content

[Help]Car Spawn


Recommended Posts

Posted

Server Side

local vehicles = { } 
addEvent ( "spawnvehicle", true ) 
addEventHandler ( "spawnvehicle", root, 
    function ( vehID ) 
     if  ( isElement ( vehicles [ source ] ) ) then 
         destroyElement ( vehicles [ source ] ) 
 end  
         vehicles [ source ] = createVehicle ( vehID, 2168.0910644531, -2275.087890625, 13.5,0,0,220 ) 
    if ( vehicles [ source ] ) then 
    end 
  setTimer ( warpPedIntoVehicle, 200, 1, source, vehicles [ source ] ) 
  triggerClientEvent ( source, "closeWindow", root ) 
end) 

when I spawn a car always it spawn 2 of them .

Posted

try this:

local vehicles = { } 
addEvent ( "spawnvehicle", true ) 
addEventHandler ( "spawnvehicle", root,function ( vehID ) 
    if  ( isElement ( vehicles [ source ] ) ) then 
        destroyElement ( vehicles [ source ] ) 
    end 
    vehicles [ source ] = createVehicle ( vehID, 2168.0910644531, -2275.087890625, 13.5,0,0,220 ) 
    if ( vehicles [ source ] ) then --Don't leave if statements blank 
        setTimer ( warpPedIntoVehicle, 200, 1, source, vehicles [ source ] ) 
        triggerClientEvent ( source, "closeWindow", root ) 
    end 
end) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

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