SetVehicleIdleRespawnDelay: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
 
(6 intermediate revisions by 5 users not shown)
Line 2: Line 2:
{{Server function}}
{{Server function}}
This function sets the time delay (in milliseconds) the vehicle will remain at its position while empty.
This function sets the time delay (in milliseconds) the vehicle will remain at its position while empty.
{{Important Note|[[toggleVehicleRespawn]] must be set to true for this function to have any effect}}


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">bool setVehicleIdleRespawnDelay ( vehicle theVehicle, int timeDelay )</syntaxhighlight>
<syntaxhighlight lang="lua">
bool setVehicleIdleRespawnDelay ( vehicle theVehicle, int timeDelay )
</syntaxhighlight>
 
{{OOP||[[vehicle]]:setIdleRespawnDelay|idleRespawnDelay|getVehicleIdleRespawnDelay}}


===Required Arguments===
===Required Arguments===
Line 18: Line 23:
theVehicle = createVehicle ( 400, 1, 1, 1 )      -- create us a new vehicle
theVehicle = createVehicle ( 400, 1, 1, 1 )      -- create us a new vehicle
if ( theVehicle ) then
if ( theVehicle ) then
    toggleVehicleRespawn ( theVehicle, true ) -- enable vehicle respawn as it is necessary for the idle respawn to function
     setVehicleIdleRespawnDelay ( theVehicle, 20000 ) -- tell the server to respawn the vehicle 20 seconds after it's been left.
     setVehicleIdleRespawnDelay ( theVehicle, 20000 ) -- tell the server to respawn the vehicle 20 seconds after it's been left.
end
end
Line 23: Line 29:


==See Also==
==See Also==
{{Vehicle functions}}
{{Vehicle_functions|server}}

Latest revision as of 23:05, 6 September 2024

This function sets the time delay (in milliseconds) the vehicle will remain at its position while empty.

[[{{{image}}}|link=|]] Important Note: toggleVehicleRespawn must be set to true for this function to have any effect

Syntax

bool setVehicleIdleRespawnDelay ( vehicle theVehicle, int timeDelay )


OOP Syntax Help! I don't understand this!

Method: vehicle:setIdleRespawnDelay(...)
Variable: .idleRespawnDelay
Counterpart: getVehicleIdleRespawnDelay


Required Arguments

  • theVehicle: The vehicle you wish to change the respawn delay of.
  • timeDelay: The number of milliseconds the vehicle will be allowed to remain unused until it respawns.

Returns

Returns true if the vehicle was found and edited.

Example

This example creates a vehicle and sets its respawn delay to 20 seconds.

theVehicle = createVehicle ( 400, 1, 1, 1 )       -- create us a new vehicle
if ( theVehicle ) then
    toggleVehicleRespawn ( theVehicle, true ) -- enable vehicle respawn as it is necessary for the idle respawn to function
    setVehicleIdleRespawnDelay ( theVehicle, 20000 ) -- tell the server to respawn the vehicle 20 seconds after it's been left.
end

See Also