Hassam Posted July 17, 2013 Share Posted July 17, 2013 Hello, I'm posting here, because, I try spawn some cars with my friend, and I spawned one car, and my friend spawn another and my car is destroyed. I need help to fix for I and my friend can use one vehicle and when I change to another car, the first car will be destroy. addEvent ( "SwatSpawn_Ambulance", true ) addEventHandler ( "SwatSpawn_Ambulance", root, function () if ( isElement ( Ambulance) ) then destroyElement ( Ambulance ) elseif ( isElement ( Bullet) ) then destroyElement ( Bullet ) elseif ( isElement ( Enforcer) ) then destroyElement ( Enforcer ) end x,y,z = getElementPosition(source) Ambulance = createVehicle ( 416,x+3,y,z, 0, 0, 270) if ( Ambulance ) then setVehicleColor ( Ambulance, 0, 0, 65, 255, 255, 255 ) end setTimer ( warpPedIntoVehicle, 200, 1, source,Ambulance ) triggerClientEvent (source,"closeWindowCars", root ) end ) addEvent ( "SwatSpawn_Enforcer", true ) addEventHandler ( "SwatSpawn_Enforcer", root, function () if ( isElement ( Ambulance) ) then destroyElement ( Ambulance ) elseif ( isElement ( Bullet) ) then destroyElement ( Bullet ) elseif ( isElement ( Enforcer) ) then destroyElement ( Enforcer ) end x,y,z = getElementPosition(source) Enforcer = createVehicle ( 427,x+3,y,z, 0, 0, 270) setTimer ( warpPedIntoVehicle, 200, 1, source,Enforcer ) triggerClientEvent (source,"closeWindowCars", root) if ( Enforcer ) then setVehicleColor ( Enforcer, 0, 0, 65, 255, 255, 255 ) end end ) addEvent ( "SwatSpawn_Bullet", true ) addEventHandler ( "SwatSpawn_Bullet", root, function () if ( isElement ( Ambulance) ) then destroyElement ( Ambulance ) elseif ( isElement ( Bullet) ) then destroyElement ( Bullet ) elseif ( isElement ( Enforcer) ) then destroyElement ( Enforcer ) end x,y,z = getElementPosition(source) Bullet = createVehicle ( 541,x+3,y,z, 0, 0, 270) setTimer ( warpPedIntoVehicle, 200, 1, source,Bullet ) triggerClientEvent (source,"closeWindowCars", root) if ( Bullet ) then setVehicleColor ( Bullet, 0, 0, 65, 255, 255, 255 ) end end ) Link to comment
Castillo Posted July 17, 2013 Share Posted July 17, 2013 That's because you are using the same variable name for every player, you must use tables intead. 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