Jump to content

setVehicleWheelStates does not work


iPanda

Recommended Posts

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 by Guest
Link to comment

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

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

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

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