ResetVehicleIdleTime: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: {{Server client function}} __NOTOC__ Resets the vehicle idle time ==Syntax== <syntaxhighlight lang="lua"> bool resetVehicleIdleTime ( vehicle theVehicle ) </syntaxhighlight> ===Required Arguments=== *'''theVeh...)
 
(Replace to predefined variables.)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Server client function}}
{{Server function}}
__NOTOC__
__NOTOC__
Resets the vehicle idle time
Resets the vehicle idle time
Line 15: Line 15:


==Example==
==Example==
This example resets every vehicle's idle time when the resource is stopped.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
--Example here
function resetVehiclesIdleTime ()
local vehicles = getElementsByType ( "vehicle" ) -- Return all the vehicles in a table
for k, vehicle in ipairs ( vehicles ) do -- For every vehicle do the following...
resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time
end
end
-- When this resource is stopped, trigger the resetVehiclesIdleTime function (above).
addEventHandler ( "onResourceStop", resourceRoot, resetVehiclesIdleTime )
</syntaxhighlight>
</syntaxhighlight>
==See Also==
{{Vehicle functions}}
{{Vehicle functions}}
[[Category:Needs_Example]]

Latest revision as of 04:33, 16 May 2023

Resets the vehicle idle time

Syntax

bool resetVehicleIdleTime ( vehicle theVehicle )

Required Arguments

  • theVehicle: The vehicle you wish to reset the idle time from.

Returns

Returns true if the vehicle idle time has been reset, false if it failed to reset the idle time.

Example

This example resets every vehicle's idle time when the resource is stopped.

function resetVehiclesIdleTime ()
	local vehicles = getElementsByType ( "vehicle" ) -- Return all the vehicles in a table
		for k, vehicle in ipairs ( vehicles ) do -- For every vehicle do the following...
			resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time
		end
end
-- When this resource is stopped, trigger the resetVehiclesIdleTime function (above).
addEventHandler ( "onResourceStop", resourceRoot, resetVehiclesIdleTime )

See Also