SetVehicleWheelStates: Difference between revisions
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
| m (→Example) | |||
| Line 22: | Line 22: | ||
| ==Example== | ==Example== | ||
| This example  | This example displays the states of the vehicle's wheels and changes their states if any arguments were passed. | ||
| <syntaxhighlight lang="lua">local  | <syntaxhighlight lang="lua">function scriptWheelStates ( player, command, newFLeft, newRLeft, newFRight, newRRight ) | ||
| local  |   local theVehicle = getPlayerOccupiedVehicle ( player ) | ||
|   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, frontRight, rearLeft, rearRight = getVehicleWheelStates ( theVehicle ) | |||
|     outputChatBox ( "Wheel states:" ) -- output them in the chatbox | |||
|     outputChatBox ( "Front-Left: " .. states [ frontLeft ] .. ", Front-Right: " .. states [ frontRight ] | |||
|       .. ", Rear-Left: " .. states [ rearLeft ] .. ", Rear-Right: " .. states [ rearRight ] ) | |||
|   else outputChatBox ( "You have to be in a vehicle to use this command." ) | |||
|   end | |||
| end | |||
| addCommandHandler ( "wheelstates", scriptWheelStates ) | |||
| </syntaxhighlight> | </syntaxhighlight> | ||
| ==See Also== | ==See Also== | ||
| {{Vehicle functions}} | {{Vehicle functions}} | ||
Revision as of 15:16, 1 August 2007
This function sets the state of wheels on the vehicle.
Internally, no vehicles have more than 4 wheels. If they appear to, they will be duplicating other wheels.
Syntax
setVehicleWheelStates ( vehicle theVehicle, int frontLeft, [ int rearLeft = -1, int frontRight = -1, int rearRight = -1 ])
Required Arguments
- theVehicle: A handle to the vehicle that you wish to change the wheel states of.
- frontLeft: A whole number representing the wheel state (-1 for no change)
Optional Arguments
- rearLeft: A whole number representing the wheel state (-1 for no change)
- frontRight: A whole number representing the wheel state (-1 for no change)
- rearRight: A whole number representing the wheel state (-1 for no change)
Wheel-State values
- 0: Inflated
- 1: Flat
- 2: Fallen off
Example
This example displays the states of the vehicle's wheels and changes their states if any arguments were passed.
function scriptWheelStates ( player, command, newFLeft, newRLeft, newFRight, newRRight )
  local theVehicle = getPlayerOccupiedVehicle ( player )
  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, frontRight, rearLeft, rearRight = getVehicleWheelStates ( theVehicle )
    outputChatBox ( "Wheel states:" ) -- output them in the chatbox
    outputChatBox ( "Front-Left: " .. states [ frontLeft ] .. ", Front-Right: " .. states [ frontRight ]
      .. ", Rear-Left: " .. states [ rearLeft ] .. ", Rear-Right: " .. states [ rearRight ] )
  else outputChatBox ( "You have to be in a vehicle to use this command." )
  end
end
addCommandHandler ( "wheelstates", scriptWheelStates )
See Also
- addVehicleUpgrade
- addVehicleSirens
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- setVehicleNitroActivated
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- removeVehicleSirens
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates