Jump to content

Duplicated Vehicles


GerardWay

Recommended Posts

Posted

Whenever I use

createVehicle 

, it totally glitches out. Lets say if I try to get in the created vehicle, another vehicle of the same kind will be inside that created vehicle. Does anybody know how to fix this please?

Posted
function vehCreate() 
veh1 = createVehicle (447, -1420.7259521484, 501.92907714844, 17.640787124634) 
setVehicleDamageProof (veh1, true) 
end 
addEventHandler ("onResourceStart", getRootElement(), vehCreate) 
  
function vehCreate2() 
veh2 = createVehicle (447, -1407.1575927734, 502.88314819336, 18.18126, 18.376713624268) 
setVehicleDamageProof (veh2, true) 
end 
addEventHandler ("onResourceStart", getRootElement(), vehCreate2) 

Posted

You are creating a vehicle whenever a resource starts, for example admin.

Use this instead:

function vehCreate() 
veh1 = createVehicle (447, -1420.7259521484, 501.92907714844, 17.640787124634) 
setVehicleDamageProof (veh1, true) 
  
veh2 = createVehicle (447, -1407.1575927734, 502.88314819336, 18.18126, 18.376713624268) 
setVehicleDamageProof (veh2, true) 
end 
addEventHandler ("onResourceStart", resourceRoot, vehCreate) 

As you can see I added "resourceRoot", this will bind the event "onResourceStart" on the resource's Root, so the resource only. And I combined the vehicle creationg togheter, it was a bit useless to add 2 event handlers with the same function.

Have fun!

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