GetVehicleWheelStates: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(OOP)
 
(14 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server client function}}
This function returns the current states of all the wheels on the vehicle.
This function returns the current states of all the wheels on the vehicle.


Line 6: Line 7:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">int, int, int, int getVehicleWheelStates ( vehicle theVehicle )</syntaxhighlight>
<syntaxhighlight lang="lua">int, int, int, int getVehicleWheelStates ( vehicle theVehicle )</syntaxhighlight>
 
{{OOP||[[vehicle]]:getWheelStates||setVehicleWheelStates}}
==Required Arguments==
==Required Arguments==
*'''theVehicle:''' A handle to the [[vehicle]] that you wish to know the wheel states of.
*'''theVehicle:''' A handle to the [[vehicle]] that you wish to know the wheel states of.


==Returns==
==Returns==
Returns 4 ints indicating the states of the wheel. These values can be:
Returns 4 [[int]]s indicating the states of the wheels (front left, rear left, front right, rear right). These values can be:
* '''0:''' Inflated
* '''0:''' Inflated
* '''1:''' Flat
* '''1:''' Flat
* '''2:''' Fallen off
* '''2:''' Fallen off
* '''3:''' Collisionless


==Example==
==Example==
This example creates a new vehicle then gets the states of the vehicle's wheels.
<section name="Server" class="server" show="true">
This example displays the states of the vehicle's wheels and changes their states if any arguments were passed.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function scriptWheelStates ( player, command )
function scriptWheelStates ( thePlayer, command, newFLeft, newRLeft, newFRight, newRRight )
   local theVehicle = getPlayerOccupiedVehicle ( player )
   local theVehicle = getPedOccupiedVehicle ( thePlayer )
  if ( theVehicle ) then
  if ( theVehicle ) then -- check if the player is in a car
    local states = { [0]="inflated", [1]="flat", [2]="fallen off" }
  if ( newFLeft ) then -- if there's at least one argument passed, we change the wheel states
    frontLeft, frontRight, rearLeft, rearRight = getVehicleWheelStates ( theVehicle )
  if not setVehicleWheelStates ( theVehicle, newFLeft, newRLeft, newFRight, newRRight ) then
    outputChatBox ( "Wheel states:" )
      outputChatBox ( "Bad arguments." )
    outputChatBox ( "Front-Left: " .. states [ frontLeft ] .. ", Front-Right: " .. states [ frontRight ]
  end
       .. ", Rear-Left: " .. states [ rearLeft ] .. ", Rear-Right: " .. states [ rearRight ] )
end
   else outputChatBox ( "You have to be in a vehicle to use this command." )
    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
end
end
addCommandHandler ( "wheelstates", scriptWheelStates )</syntaxhighlight>
addCommandHandler ( "wheelstates", scriptWheelStates )</syntaxhighlight>
</section>
<section name="Client" class="client" >
This example displays the states of the vehicle's wheels and changes their states if any arguments were passed.
<syntaxhighlight lang="lua">
function scriptWheelStates (command, newFLeft, newRLeft, newFRight, newRRight )
    local theVehicle = getPedOccupiedVehicle ( localPlayer )
    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:", localPlayer )        -- output them in the chatbox
        outputChatBox ( "Front-Left: " .. states [ frontLeft ] .. ", Front-Right: " .. states [ frontRight ] ..
          ", Rear-Left: " .. states [ rearLeft ] .. ", Rear-Right: " .. states [ rearRight ], localPlayer )
    else
        outputChatBox ( "You have to be in a vehicle to use this command.", localPlayer )
    end
end
addCommandHandler ( "wheelstates", scriptWheelStates )</syntaxhighlight>
</section>


==See Also==
==See Also==
{{Vehicle functions}}
{{Vehicle functions}}

Latest revision as of 23:03, 17 December 2014

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 )

OOP Syntax Help! I don't understand this!

Method: vehicle:getWheelStates(...)
Counterpart: setVehicleWheelStates


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 )
Click to expand [+]
Client

See Also