GetVehicleWheelStates: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (→‎Example: UPDATED: getPlayerOccupiedVehicle to getPedOccupiedVehicle)
Line 23: Line 23:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function scriptWheelStates ( thePlayer, command, newFLeft, newRLeft, newFRight, newRRight )
function scriptWheelStates ( thePlayer, command, newFLeft, newRLeft, newFRight, newRRight )
   local theVehicle = getPlayerOccupiedVehicle ( thePlayer )
   local theVehicle = getPedOccupiedVehicle ( thePlayer )
   if ( theVehicle ) then -- check if the player is in a car
   if ( theVehicle ) then -- check if the player is in a car
   if ( newFLeft ) then -- if there's at least one argument passed, we change the wheel states
   if ( newFLeft ) then -- if there's at least one argument passed, we change the wheel states
Line 40: Line 40:
addCommandHandler ( "wheelstates", scriptWheelStates )</syntaxhighlight>
addCommandHandler ( "wheelstates", scriptWheelStates )</syntaxhighlight>
</section>
</section>
==See Also==
==See Also==
{{Vehicle functions}}
{{Vehicle functions}}

Revision as of 20:59, 15 September 2012

This function returns the current states of all the wheels on the vehicle.

No vehicles have more than 4 wheels, if they appear to they will be duplicating other wheels.

Syntax

int, int, int, int getVehicleWheelStates ( vehicle theVehicle )

Required Arguments

  • theVehicle: A handle to the vehicle that you wish to know the wheel states of.

Returns

Returns 4 ints indicating the states of the wheels (front left, rear left, front right, rear right). These values can be:

  • 0: Inflated
  • 1: Flat
  • 2: Fallen off
  • 3: Collisionless

Example

Click to collapse [-]
Server

This example displays the states of the vehicle's wheels and changes their states if any arguments were passed.

function scriptWheelStates ( thePlayer, command, newFLeft, newRLeft, newFRight, newRRight )
  local theVehicle = getPedOccupiedVehicle ( thePlayer )
  if ( theVehicle ) then -- check if the player is in a car
  	if ( newFLeft ) then -- if there's at least one argument passed, we change the wheel states
	  if not setVehicleWheelStates ( theVehicle, newFLeft, newRLeft, newFRight, newRRight ) then
	    outputChatBox ( "Bad arguments." )
	  end
	end
    local states = { [0]="inflated", [1]="flat", [2]="fallen off" } -- we store the states in a table
    local frontLeft, rearLeft, frontRight, rearRight = getVehicleWheelStates ( theVehicle )
    outputChatBox ( "Your vehicle's wheel states:", thePlayer ) -- output them in the chatbox
    outputChatBox ( "Front-Left: " .. states [ frontLeft ] .. ", Front-Right: " .. states [ frontRight ]
      .. ", Rear-Left: " .. states [ rearLeft ] .. ", Rear-Right: " .. states [ rearRight ], thePlayer )
  else outputChatBox ( "You have to be in a vehicle to use this command.", thePlayer )
  end
end
addCommandHandler ( "wheelstates", scriptWheelStates )

See Also