RespawnVehicle: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Server function}}
{{Server function}}
__NOTOC__
__NOTOC__
This function respawns a vehicle according to its set respawn position, set by [[setVehicleRespawnPosition]]. To spawn to a specific location, [[spawnVehicle]] can be used..
This function respawns a vehicle according to its set respawn position, set by [[setVehicleRespawnPosition]] or the position and rotation it was created on. To spawn a vehicle to a specific location just once, [[spawnVehicle]] can be used.


==Syntax==  
==Syntax==  
Line 7: Line 7:
bool respawnVehicle ( vehicle theVehicle )
bool respawnVehicle ( vehicle theVehicle )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[vehicle]]:respawn}}
===Required Arguments===  
===Required Arguments===  
*'''theVehicle:''' The vehicle you wish to respawn
*'''theVehicle:''' The vehicle you wish to respawn
Line 16: Line 16:
==Example==  
==Example==  
<!-- Explain what the example is in a single sentance -->
<!-- Explain what the example is in a single sentance -->
This example makes an exploded vehicle re-spawn after 5 seconds!
This example makes an exploded vehicle re-spawn after 5 seconds.
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized -->
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
Line 22: Line 22:
setTimer(respawnVehicle, 5000, 1, source)
setTimer(respawnVehicle, 5000, 1, source)
end
end
addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle)
addEventHandler("onVehicleExplode", root, respawnExplodedVehicle)
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Vehicle functions}}
{{Vehicle functions}}

Latest revision as of 06:33, 13 October 2023

This function respawns a vehicle according to its set respawn position, set by setVehicleRespawnPosition or the position and rotation it was created on. To spawn a vehicle to a specific location just once, spawnVehicle can be used.

Syntax

bool respawnVehicle ( vehicle theVehicle )

OOP Syntax Help! I don't understand this!

Method: vehicle:respawn(...)


Required Arguments

  • theVehicle: The vehicle you wish to respawn

Returns

Returns true if the vehicle respawned successfully, false if the passed argument does not exist or is not a vehicle.

Example

This example makes an exploded vehicle re-spawn after 5 seconds.

function respawnExplodedVehicle()
	setTimer(respawnVehicle, 5000, 1, source)
end
addEventHandler("onVehicleExplode", root, respawnExplodedVehicle)

See Also