Eweest Posted July 7, 2015 Share Posted July 7, 2015 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
Miika Posted July 8, 2015 Share Posted July 8, 2015 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
Calculador Posted July 8, 2015 Share Posted July 8, 2015 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
Eweest Posted July 8, 2015 Author Share Posted July 8, 2015 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
Eweest Posted July 8, 2015 Author Share Posted July 8, 2015 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
Eweest Posted July 10, 2015 Author Share Posted July 10, 2015 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
Calculador Posted July 10, 2015 Share Posted July 10, 2015 What do you mean? -- Syntax warpPedIntoVehicle ( ped thePed, vehicle theVehicle, [ int seat=0 ] ) Link to comment
Eweest Posted July 11, 2015 Author Share Posted July 11, 2015 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
Calculador Posted July 11, 2015 Share Posted July 11, 2015 Do you want if the player is in the car, he could spawn a new car ? If so, you only need remove the line 3: if isPedInVehicle(source) then return end Link to comment
Eweest Posted July 11, 2015 Author Share Posted July 11, 2015 Do you want if the player is in the car, he could spawn a new car ?If so, you only need remove the line 3: if isPedInVehicle(source) then return end thx, for helping me) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now