iPanda Posted December 30, 2014 Share Posted December 30, 2014 (edited) Why does not work function setVehicleWheelStates? (server) local veh = createVehicle(422,x,y,z) setVehicleWheelStates(veh,2,2,2,2) -- the problem here addEventHandler('onPlayerVehicleEnter',function(veh) setVehicleWheelStates(veh,-1,-1,-1,-1) outputChatBox('Wheel is fixed!',source) end) Nothing happens. No error. - Edited January 3, 2015 by Guest Link to comment
Kenix Posted December 31, 2014 Share Posted December 31, 2014 1st argument should be vehicle-pointer (veh - variable) but (your is number 2 ). Link to comment
iPanda Posted January 1, 2015 Author Share Posted January 1, 2015 Kenix, It's my banal error when write the code on a forum. But is not the problem. If you observe the correct syntax - nothing happens. As though function does not work. Link to comment
Miika Posted January 1, 2015 Share Posted January 1, 2015 Try this: addCommandHandler("createcar", function(thePlayer) local x,y,z = getElementPosition(thePlayer) veh = createVehicle(422,x,y,z) setVehicleWheelStates(veh,2,2,2,2) end ) addEventHandler("onVehicleEnter", getRootElement(), function(player) local theVehicle = getPedOccupiedVehicle ( player ) local id = getElementModel ( theVehicle ) if id == 422 then setVehicleWheelStates(theVehicle,-1,-1,-1,-1) outputChatBox('Wheel is fixed!', player, 0, 255, 0, true) end end) Link to comment
iPanda Posted January 1, 2015 Author Share Posted January 1, 2015 Miika822, Your version does not suit my script. Maybe there are other ways of checking vehicle as a source, and a change of state of the wheels? Link to comment
Mizudori Posted January 2, 2015 Share Posted January 2, 2015 I think it will be easier to help if you will say what your function should do. For example you can get vehicle element from onMarkerHit or OnVehicleEnter. front left -> Flat local veh = createVehicle(422,x,y,z) setVehicleWheelStates(veh,1,-1,-1,-1) right rear -> fallen off local veh = createVehicle(422,x,y,z) setVehicleWheelStates(veh,-1,-1,-1,2) front left -> fallen off and rear left -> fallen off local veh = createVehicle(422,x,y,z) setVehicleWheelStates(veh,2,2,-1,-1) Link to comment
iPanda Posted January 2, 2015 Author Share Posted January 2, 2015 Mizudori, Suppose onMarkerHit Link to comment
Mizudori Posted January 2, 2015 Share Posted January 2, 2015 Mizudori, Suppose onMarkerHit This is server side event change_w = createMarker (x, y, z, "checkpoint", 1, 255,0,0,255) <== x,y,z position of marker function MarkerHit( hitElement, matchingDimension ) <-- hitElement = to element that hit the marker if(getElementType(hitElement) == "player")then <-- check if element is player local veh = getPedOccupiedVehicle(hitElement) <-- if yes check if he is in vehicle if(veh)then <-- if yes then veh = the player vehicle loca x = setVehicleWheelStates(veh,2,2,-1,-1) <-- example of change wheel states if(x)then <-- check if works outputChatBox("success") end else return 0 <-- if no, do end and do nothing end end end addEventHandler( "onMarkerHit", change_w, MarkerHit ) Link to comment
iPanda Posted January 3, 2015 Author Share Posted January 3, 2015 Mizudori, Your example does not work... and it does not work... --being inside the car addCommandHandler('wheel',function(panda) local veh = getPedOccupiedVehicle(panda) setVehicleWheelStates(veh,-1,-1,-1,-1) end) I do not understand what the problem is. I've been doing this, but not one of the options does not work. Maybe function has bugs? Link to comment
Mizudori Posted January 3, 2015 Share Posted January 3, 2015 Mizudori, Your example does not work...and it does not work... --being inside the car addCommandHandler('wheel',function(panda) local veh = getPedOccupiedVehicle(panda) setVehicleWheelStates(veh,-1,-1,-1,-1) end) I do not understand what the problem is. I've been doing this, but not one of the options does not work. Maybe function has bugs? it works fine for me. I mispelled local there. Try this. This one is tested function MarkerHit( hitElement, matchingDimension ) -- hitElement = to element that hit the marker if(getElementType(hitElement) == "player")then -- check if element is player local veh = getPedOccupiedVehicle(hitElement) -- if yes check if he is in vehicle if(veh)then -- if yes then veh = the player vehicle local x = setVehicleWheelStates(veh,2,2,-1,-1) -- example of change wheel states if(x)then -- check if works outputChatBox("success") end else return 0 -- if no, do end and do nothing end end end addEventHandler( "onMarkerHit", change_w, MarkerHit ) 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