Mimimiguel Posted June 23, 2011 Share Posted June 23, 2011 Hello, I am trying to script a vehicle interior but it doesn't work and debugscript doesn't report any trouble, here it is the script: addEventHandler("OnVehicleStartEnter", getRootElement(), function( player, seat, jacked, door ) local a1 = createVehicle( 416, 10, 0, 0 ) local a2 = createVehicle( 416, 20, 0, 0 ) local a3 = createVehicle( 416, 30, 0, 0 ) if door == 2 or 3 and source == a1 or a2 or a3 then cancelEvent() if source == a1 then setElementPosition(player, 2003.3, 2284.2, 1011.1) setElementDimension( player, 103 ) setElementData( player, "ambulance", 1 ) bindKey("num_5", "down", bajar) outputChatBox("Pulsa num_5 para bajar", player) -- "Use num_5 to get off the car" elseif source == a2 then setElementPosition(player, 2003.3, 2284.2, 1011.1) setElementDimension( player, 104 ) setElementData( player, "ambulance", 2 ) bindKey("num_5", "down", bajar) outputChatBox("Pulsa num_5 para bajar", player) -- "Use num_5 to get off the car" elseif source == a3 then setElementPosition(player, 2003.3, 2284.2, 1011.1) setElementDimension( player, 105 ) setElementData( player, "ambulance", 3 ) bindKey("num_5", "down", bajar) outputChatBox("Pulsa num_5 para bajar", player) -- "Use num_5 to get off the car" end end end ) function bajar( player ) ambulance = getElementData( player, "ambulance" ) if ambulance == 1 then ax, ay, az = getElementPosition( a1 ) setElementDimension( player, 0 ) setElementPosition( player, ax, ay, az ) elseif ambulance == 2 then ax, ay, az = getElementPosition( a2 ) setElementDimension( player, 0 ) setElementPosition( player, ax, ay, az ) elseif ambulance == 3 then ax, ay, az = getElementPosition( a3 ) setElementDimension( player, 0 ) setElementPosition( player, ax, ay, az ) end end thanks! Link to comment
JR10 Posted June 23, 2011 Share Posted June 23, 2011 You create the 3 vehicles when a player enter a car why?? And its local so you can't use it in any other block. Link to comment
Kenix Posted June 23, 2011 Share Posted June 23, 2011 (edited) Try this a1 = createVehicle( 416, 10, 0, 0 ) a2 = createVehicle( 416, 20, 0, 0 ) a3 = createVehicle( 416, 30, 0, 0 ) addEventHandler("onVehicleStartEnter", getRootElement(), function( player, seat, jacked, door ) if door == 2 or 3 and source == a1 or a2 or a3 then cancelEvent() if source == a1 then setElementPosition(player, 2003.3, 2284.2, 1011.1) setElementDimension( player, 103 ) setElementData( player, "ambulance", 1 ) bindKey(player,"num_5", "down", bajar) outputChatBox("Pulsa num_5 para bajar", player) -- "Use num_5 to get off the car" elseif source == a2 then setElementPosition(player, 2003.3, 2284.2, 1011.1) setElementDimension( player, 104 ) setElementData( player, "ambulance", 2 ) bindKey(player,"num_5", "down", bajar) outputChatBox("Pulsa num_5 para bajar", player) -- "Use num_5 to get off the car" elseif source == a3 then setElementPosition(player, 2003.3, 2284.2, 1011.1) setElementDimension( player, 105 ) setElementData( player, "ambulance", 3 ) bindKey(player,"num_5", "down", bajar) outputChatBox("Pulsa num_5 para bajar", player) -- "Use num_5 to get off the car" end end end ) function bajar( player ) ambulance = getElementData( player, "ambulance" ) if ambulance == 1 then ax, ay, az = getElementPosition( a1 ) setElementDimension( player, 0 ) setElementPosition( player, ax, ay, az ) elseif ambulance == 2 then ax, ay, az = getElementPosition( a2 ) setElementDimension( player, 0 ) setElementPosition( player, ax, ay, az ) elseif ambulance == 3 then ax, ay, az = getElementPosition( a3 ) setElementDimension( player, 0 ) setElementPosition( player, ax, ay, az ) end end Edited June 23, 2011 by Guest Link to comment
will briggs Posted June 23, 2011 Share Posted June 23, 2011 Edit: Why do you need 3 vehicles :> Link to comment
Mimimiguel Posted June 23, 2011 Author Share Posted June 23, 2011 Thanks! I need that 3 vehicles because I only want the player to enter in the ambulance interior for those 3 cars. EDIT: It still doesn't work Link to comment
JR10 Posted June 23, 2011 Share Posted June 23, 2011 Post the errors or the warnings. and maybe try this: a1 = createVehicle( 416, 10, 0, 0 ) a2 = createVehicle( 416, 20, 0, 0 ) a3 = createVehicle( 416, 30, 0, 0 ) addEventHandler("onVehicleStartEnter", getRootElement(), function( player, seat, jacked, door ) if door == 2 or 3 and source == a1 or source == a2 or source == a3 then cancelEvent() if source == a1 then setElementPosition(player, 2003.3, 2284.2, 1011.1) setElementDimension( player, 103 ) setElementData( player, "ambulance", 1 ) bindKey(player,"num_5", "down", bajar) outputChatBox("Pulsa num_5 para bajar", player) -- "Use num_5 to get off the car" elseif source == a2 then setElementPosition(player, 2003.3, 2284.2, 1011.1) setElementDimension( player, 104 ) setElementData( player, "ambulance", 2 ) bindKey(player,"num_5", "down", bajar) outputChatBox("Pulsa num_5 para bajar", player) -- "Use num_5 to get off the car" elseif source == a3 then setElementPosition(player, 2003.3, 2284.2, 1011.1) setElementDimension( player, 105 ) setElementData( player, "ambulance", 3 ) bindKey(player,"num_5", "down", bajar) outputChatBox("Pulsa num_5 para bajar", player) -- "Use num_5 to get off the car" end end end ) function bajar( player ) ambulance = getElementData( player, "ambulance" ) if ambulance == 1 then ax, ay, az = getElementPosition( a1 ) setElementDimension( player, 0 ) setElementPosition( player, ax, ay, az ) elseif ambulance == 2 then ax, ay, az = getElementPosition( a2 ) setElementDimension( player, 0 ) setElementPosition( player, ax, ay, az ) elseif ambulance == 3 then ax, ay, az = getElementPosition( a3 ) setElementDimension( player, 0 ) setElementPosition( player, ax, ay, az ) end end Link to comment
Mimimiguel Posted June 24, 2011 Author Share Posted June 24, 2011 It doesn't work and it also doesn't report any kind of bug via debugscript Link to comment
JR10 Posted June 24, 2011 Share Posted June 24, 2011 I tested it, your problem is the interior, the position you specified above is an interior, so you must use setElementInterior. Link to comment
Mimimiguel Posted June 24, 2011 Author Share Posted June 24, 2011 Is it necesary if the interior is in "interior 0"? Anyway i'll try it and answer thanks for your support EDIT: Works perfectly, thanks again 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