FixVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(6 intermediate revisions by 6 users not shown)
Line 1: Line 1:
__NOTOC__  
__NOTOC__
This function will set a [[vehicle]]'s health to full and fix it's damage model. If you wish to just change the vehicle's health, without affecting it's damage model, use [[setVehicleHealth]].
{{Server client function}}
This function will set a [[vehicle]]'s health to full and fix its damage model. If you wish to only change the vehicle's health, without affecting its damage model, use [[setElementHealth]].


==Syntax==  
==Syntax==  
Line 6: Line 7:
bool fixVehicle ( vehicle theVehicle )             
bool fixVehicle ( vehicle theVehicle )             
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[vehicle]]:fix}}
===Required Arguments===  
===Required Arguments===  
*'''theVehicle:''' The vehicle you wish to fix
*'''theVehicle:''' the vehicle you wish to fix


===Returns===
===Returns===
Returns ''true'' if the vehicle was fixed, ''false'' if ''theVehicle'' is invalid.
Returns ''true'' if the vehicle was fixed, ''false'' if '''theVehicle''' is invalid.


==Example==  
==Example==  
Line 17: Line 18:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- Retrieve a table containing all the vehicles that exist
-- Retrieve a table containing all the vehicles that exist
vehicles = getElementsByType ( "vehicle" )
local vehicles = getElementsByType("vehicle")
-- Loop through the list, storing the vehicle from the table in the variable vehicleValue
 
for vehicleKey, vehicleValue in blips do
-- Loop through the table, storing the vehicle from the table in a variable called "vehicle"
-- fix the vehicle
for _, vehicle in pairs(vehicles) do
fixVehicle( vehicleHealth )
-- Fix the vehicle
fixVehicle(vehicle)
end
end
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 13:34, 7 May 2018

This function will set a vehicle's health to full and fix its damage model. If you wish to only change the vehicle's health, without affecting its damage model, use setElementHealth.

Syntax

bool fixVehicle ( vehicle theVehicle )             

OOP Syntax Help! I don't understand this!

Method: vehicle:fix(...)


Required Arguments

  • theVehicle: the vehicle you wish to fix

Returns

Returns true if the vehicle was fixed, false if theVehicle is invalid.

Example

This example fixes all the vehicles that exist in the map.

-- Retrieve a table containing all the vehicles that exist
local vehicles = getElementsByType("vehicle")

-- Loop through the table, storing the vehicle from the table in a variable called "vehicle"
for _, vehicle in pairs(vehicles) do
	-- Fix the vehicle
	fixVehicle(vehicle)
end

See Also