Jump to content

[HELP] Car


Eweest

Recommended Posts

Hi guys! How to make so that when spawn auto, last destroyed.

Server:

Vehicle = {} 
function spawnCars(modelid) 
    if isPedInVehicle(source) then 
    return end 
    if ( modelid ) then 
    local playerX,playerY,playerZ = getElementPosition(source) 
    Vehicle[source] = createVehicle(modelid,playerX,playerY, playerZ) 
    warpPedIntoVehicle(source,Vehicle[source]) 
    else 
    destroyElement(getPedOccupiedVehicle(source)) 
    end 
    end 
addEvent("spawn",true) 
addEventHandler("spawn",root,spawnCars) 

Link to comment
Vehicle = {} 
function spawnCars(modelid) 
if isPedInVehicle(source) then 
    return end 
    if ( Vehicle[source] ) then 
        destroyElement( Vehicle[source] ) -- Destroy it if already created 
    end 
    local playerX,playerY,playerZ = getElementPosition(source) 
    Vehicle[source] = createVehicle(modelid,playerX,playerY, playerZ) -- Creates a new vehicle 
    warpPedIntoVehicle(source,Vehicle[source]) 
end 
addEvent("spawn",true) 
addEventHandler("spawn",root,spawnCars) 

Test it.

Link to comment
Vehicle = {} 
function spawnCars(modelid) 
if isPedInVehicle(source) then 
    return end 
    if ( Vehicle[source] ) then 
        destroyElement( Vehicle[source] ) -- Destroy it if already created 
    end 
    local playerX,playerY,playerZ = getElementPosition(source) 
    Vehicle[source] = createVehicle(modelid,playerX,playerY, playerZ) -- Creates a new vehicle 
    warpPedIntoVehicle(source,Vehicle[source]) 
end 
addEvent("spawn",true) 
addEventHandler("spawn",root,spawnCars) 

Test it.

But, He wants to destroy the car if not modelid. Therefore

  
Vehicle = {} 
function spawnCars(modelid) 
    if isPedInVehicle(source) then 
    return end 
    if ( modelid ) then 
    local playerX,playerY,playerZ = getElementPosition(source) 
    Vehicle[source] = createVehicle(modelid,playerX,playerY, playerZ) 
    warpPedIntoVehicle(source,Vehicle[source]) 
    else 
    destroyElement(Vehicle[source]) 
    end 
    end 
addEvent("spawn",true) 
addEventHandler("spawn",root,spawnCars) 
  

Link to comment
Vehicle = {} 
function spawnCars(modelid) 
if isPedInVehicle(source) then 
    return end 
    if ( Vehicle[source] ) then 
        destroyElement( Vehicle[source] ) -- Destroy it if already created 
    end 
    local playerX,playerY,playerZ = getElementPosition(source) 
    Vehicle[source] = createVehicle(modelid,playerX,playerY, playerZ) -- Creates a new vehicle 
    warpPedIntoVehicle(source,Vehicle[source]) 
end 
addEvent("spawn",true) 
addEventHandler("spawn",root,spawnCars) 

Test it.

Thanks! Work)

Link to comment
Vehicle = {} 
function spawnCars(modelid) 
if isPedInVehicle(source) then 
    return end 
    if ( Vehicle[source] ) then 
        destroyElement( Vehicle[source] ) -- Destroy it if already created 
    end 
    local playerX,playerY,playerZ = getElementPosition(source) 
    Vehicle[source] = createVehicle(modelid,playerX,playerY, playerZ) -- Creates a new vehicle 
    warpPedIntoVehicle(source,Vehicle[source]) 
end 
addEvent("spawn",true) 
addEventHandler("spawn",root,spawnCars) 

Test it.

But, He wants to destroy the car if not modelid. Therefore

  
Vehicle = {} 
function spawnCars(modelid) 
    if isPedInVehicle(source) then 
    return end 
    if ( modelid ) then 
    local playerX,playerY,playerZ = getElementPosition(source) 
    Vehicle[source] = createVehicle(modelid,playerX,playerY, playerZ) 
    warpPedIntoVehicle(source,Vehicle[source]) 
    else 
    destroyElement(Vehicle[source]) 
    end 
    end 
addEvent("spawn",true) 
addEventHandler("spawn",root,spawnCars) 
  

Sory... The problem with working capability.

Link to comment

Server:

Vehicle = {} 
function spawnCars(modelid) 
if isPedInVehicle(source) then 
    return end 
    if ( Vehicle[source] ) then 
        destroyElement( Vehicle[source] ) 
    end 
    local playerX,playerY,playerZ = getElementPosition(source) 
    Vehicle[source] = createVehicle(modelid,playerX + 2,playerY, playerZ + 1) 
    warpPedIntoVehicle(source, Vehicle[source]) 
end 
addEvent("spawn",true) 
addEventHandler("spawn",root,spawnCars) 

How to make sure, so you spawn a car sitting in the car?

Thanks in advance.

Link to comment
What do you mean?
  
-- Syntax 
warpPedIntoVehicle ( ped thePed, vehicle theVehicle, [ int seat=0 ] ) 
  

Well look. When the spawn so

Vehicle = {} 
function spawnCars(modelid) 
if isPedInVehicle(source) then 
    return end 
    if ( Vehicle[source] ) then 
        destroyElement( Vehicle[source] ) 
    end 
    local playerX,playerY,playerZ = getElementPosition(source) 
    Vehicle[source] = createVehicle(modelid,playerX + 2,playerY, playerZ + 1) 
    warpPedIntoVehicle(source, Vehicle[source]) 
end 
addEvent("spawn",true) 
addEventHandler("spawn",root,spawnCars) 

then when the player is in the car, he could not spawn a new car until you leave. Here's how to make sure that I could.

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