joedajoester Posted November 11, 2011 Share Posted November 11, 2011 I have this script, im trying to make the cars spawn with 2 objects attached to them but the 2 objects i need to be recreated at resource start so i dont have to make each car their own objects, and when I type /spatula. Please help i gave this my best shot. addEventHandler ( "onResourceStart", getRootElement(), attach) function attach(thePlayer) gate1 = createObject(971, 0, 0, 5) Car1 = createVehicle ( 567, -1736, -2895, 55, 0, 0, 236 ) Car2 = createVehicle ( 567, -1744, -2913.3000488281, 55, 0, 354.488, 220 ) attachElements( gate1, Car1, 0.4, 6.2, -0.6, 90, 90, 90 ) attachElements( gate2, Car1, 0.4, 13.2, -0.6, 90, 90, 90 ) addVehicleUpgrade ( Car1, 1087 ) addVehicleUpgrade ( Car2, 1087 ) function attach(thePlayer) if not isPedInVehicle(thePlayer) then return end local vehicle = getPedOccupiedVehicle(thePlayer) local car1gate1 = createObject(971, 0, 0, 5) local car1gate2 = createObject(971, 0, 0, 5) attachElements( car1gate1, vehicle, 0.4, 6.2, -0.6, 90, 90, 90 ) attachElements( car1gate2, vehicle, 0.4, 13.2, -0.6, 90, 90, 90 ) addVehicleUpgrade ( vehicle, 1087 ) end addCommandHandler ( "spatula", attach) end Link to comment
^Dev-PoinT^ Posted November 11, 2011 Share Posted November 11, 2011 try This function attach(thePlayer) gate1 = createObject(971, 0, 0, 5) Car1 = createVehicle ( 567, -1736, -2895, 55, 0, 0, 236 ) Car2 = createVehicle ( 567, -1744, -2913.3000488281, 55, 0, 354.488, 220 ) attachElements( gate1, Car1, 0.4, 6.2, -0.6, 90, 90, 90 ) attachElements( gate2, Car1, 0.4, 13.2, -0.6, 90, 90, 90 ) addVehicleUpgrade ( Car1, 1087 ) addVehicleUpgrade ( Car2, 1087 ) function attach(thePlayer) if not isPedInVehicle(thePlayer) then return end local vehicle = getPedOccupiedVehicle(thePlayer) local car1gate1 = createObject(971, 0, 0, 5) local car1gate2 = createObject(971, 0, 0, 5) attachElements( car1gate1, vehicle, 0.4, 6.2, -0.6, 90, 90, 90 ) attachElements( car1gate2, vehicle, 0.4, 13.2, -0.6, 90, 90, 90 ) addVehicleUpgrade ( vehicle, 1087 ) end addCommandHandler ( "spatula", attach) addEventHandler ( "onResourceStart", getRootElement(), attach) Link to comment
Castillo Posted November 11, 2011 Share Posted November 11, 2011 (edited) addEventHandler ( "onResourceStart", resourceRoot, function () local gate1 = createObject(971, 0, 0, 5) local gate2 = createObject(971, 0, 0, 5) local Car1 = createVehicle ( 567, -1736, -2895, 55, 0, 0, 236 ) local Car2 = createVehicle ( 567, -1744, -2913.3000488281, 55, 0, 354.488, 220 ) attachElements( gate1, Car1, 0.4, 6.2, -0.6, 90, 90, 90 ) attachElements( gate2, Car1, 0.4, 13.2, -0.6, 90, 90, 90 ) addVehicleUpgrade ( Car1, 1087 ) addVehicleUpgrade ( Car2, 1087 ) end) function attach(thePlayer) if not isPedInVehicle(thePlayer) then return end local vehicle = getPedOccupiedVehicle(thePlayer) local car1gate1 = createObject(971, 0, 0, 5) local car1gate2 = createObject(971, 0, 0, 5) attachElements( car1gate1, vehicle, 0.4, 6.2, -0.6, 90, 90, 90 ) attachElements( car1gate2, vehicle, 0.4, 13.2, -0.6, 90, 90, 90 ) addVehicleUpgrade ( vehicle, 1087 ) end addCommandHandler ( "spatula", attach) Edited November 11, 2011 by Guest Link to comment
joedajoester Posted November 11, 2011 Author Share Posted November 11, 2011 This doesnt spawn the cars with it, one car has one gate and the other has none. Link to comment
Castillo Posted November 11, 2011 Share Posted November 11, 2011 Copy my code again, I forgot to create the second gate. 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