SetVehicleRotorSpeed: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} Sets the rotor speed of a helicopter or plane. This function now applies to both helicopters and planes. {{Note|Setting higher values will cause problems to the client}} ==Syntax== <syntaxhighlight lang="lua"> bool setVehicleRotorSpeed ( vehicle theVehicle, float speed ) </syntaxhighlight> {{OOP||vehicle:setVehicleRotorSpeed|vehicleRotorSpeed|getVehicleRotorSpeed}} ===Required Arguments=== *'''theVehicle:''' the vehicle (helicopter or...")
 
m (Prettified example code)
 
Line 22: Line 22:
<section name="Client" class="client" show="true">
<section name="Client" class="client" show="true">
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function rotorSpeed()  
addCommandHandler("rs", function()
  local theVehicle = getPedOccupiedVehicle (localPlayer)
local theVehicle = getPedOccupiedVehicle(localPlayer)
  if theVehicle then  
if not theVehicle then return end
      local controller = getVehicleController (theVehicle)
 
      if controller == localPlayer then  
local controller = getVehicleController(theVehicle)
        local vehicleType = getVehicleType(theVehicle)
if controller ~= localPlayer then return end
        if vehicleType == "Helicopter" or vehicleType == "Plane" then  
 
            setVehicleRotorSpeed(theVehicle, 10)
local vehicleType = getVehicleType(theVehicle)
        end  
if vehicleType ~= "Helicopter" and vehicleType ~= "Plane" then return end
      end
  setVehicleRotorSpeed(theVehicle, 10)
  end
end)
end
addCommandHandler("rs", rotorSpeed)
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
==See Also==
==See Also==
{{Client vehicle functions}}
{{Client vehicle functions}}

Latest revision as of 14:50, 23 December 2023

Sets the rotor speed of a helicopter or plane. This function now applies to both helicopters and planes.

[[{{{image}}}|link=|]] Note: Setting higher values will cause problems to the client

Syntax

bool setVehicleRotorSpeed ( vehicle theVehicle, float speed )

OOP Syntax Help! I don't understand this!

Method: vehicle:setVehicleRotorSpeed(...)
Variable: .vehicleRotorSpeed
Counterpart: getVehicleRotorSpeed


Required Arguments

  • theVehicle: the vehicle (helicopter or plane) to adjust the rotor of.
  • speed: the new rotor speed. Usual values are 0 if the vehicle is stationary, or 0.2 if the rotor is fully spun up. Higher values than normal will not affect the vehicle's handling. Negative values are allowed and will make the rotor spin in the opposite direction (for helicopters, this pushes it down).

Returns

Returns true if successful, false otherwise.

Example

This example changes the rotor speed of the vehicle the player is in, if it's a helicopter or plane.

Click to collapse [-]
Client
addCommandHandler("rs", function()
	local theVehicle = getPedOccupiedVehicle(localPlayer)
	if not theVehicle then return end

	local controller = getVehicleController(theVehicle)
	if controller ~= localPlayer then return end

	local vehicleType = getVehicleType(theVehicle)
	if vehicleType ~= "Helicopter" and vehicleType ~= "Plane" then return end
   	setVehicleRotorSpeed(theVehicle, 10)
end)

See Also