GetVehicleRespawnPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
(Replace with the new native function)
Line 1: Line 1:
{{Useful Function}}
{{Server function}}
<lowercasetitle/>
__NOTOC__
__NOTOC__
This function allows you to get the respawn position of a specific [[vehicle]] element.
{{New feature/item|3.0156|1.5.5|14053|This function retrieves the respawn coordinates of a [[vehicle]].}}
'''Note:''' Please insert this code in a file that stands on the top of your meta.xml file to work correctly.


==Syntax==
==Syntax==
<syntaxhighlight lang="lua">float, float, float, float, float, float getVehicleRespawnPosition( element theVehicle )</syntaxhighlight>
<syntaxhighlight lang="lua">
float, float, float getVehicleRespawnPosition ( element theVehicle )
</syntaxhighlight>
{{OOP||[[vehicle]]:getRespawnPosition|respawnPosition|setVehicleRespawnPosition}}


===Required Arguments===
===Required Arguments===
* '''theVehicle''': A vehicle that have been created using [[createVehicle]].
*'''theVehicle:''' The [[vehicle]] which you'd like to retrieve the respawn coordinates of.


===Returns===
===Returns===
Returns 6 variables representing the vehicle's respawn position. (x, y, z, rotx, roty, rotz)
Returns three [[float|floats]] indicating the respawn coordinates of the [[vehicle]], ''x'', ''y'' and ''z'' respectively.
If the vehicle is incorrect or the table is missing, it returns false.
 
==Code==
<section name="Server and Clientside script" class="both" show="true">
<syntaxhighlight lang="lua">
local vehSpawn = {}
 
_createVehicle = createVehicle
_setVehicleRespawnPosition = setVehicleRespawnPosition
 
-- Overwrite the existing functions --
function createVehicle(id, x, y, z, rx, ry, rz, ...)
local veh = _createVehicle(id, x, y, z, rx, ry, rz, ...)
if(veh) then
vehSpawn[veh] = {x, y, z, rx, ry, rz}
return veh
else
return false
end
end
 
 
function setVehicleRespawnPosition(theVehicle, ...)
assert(vehSpawn[theVehicle], "Bad Argument @ setVehicleRespawnPosition (Vehicle respawn position does not exists)")
vehSpawn[theVehicle] = {...}
return _setVehicleRespawnPosition(theVehicle, ...)
end
 
-- Add's the new function --
function getVehicleRespawnPosition(theVehicle)
if(vehSpawn[theVehicle]) then
return vehSpawn[theVehicle][1], vehSpawn[theVehicle][2], vehSpawn[theVehicle][3], vehSpawn[theVehicle][4], vehSpawn[theVehicle][5], vehSpawn[theVehicle][6]
else
return false
end
end
</syntaxhighlight>
</section>


Author: Noneatme
==Example==
{{Example}}


==See Also==
==See Also==
{{Useful_Functions}}
{{Vehicle_functions}}

Revision as of 14:32, 29 August 2018

This function retrieves the respawn coordinates of a vehicle.

Syntax

float, float, float getVehicleRespawnPosition ( element theVehicle )

OOP Syntax Help! I don't understand this!

Method: vehicle:getRespawnPosition(...)
Variable: .respawnPosition
Counterpart: setVehicleRespawnPosition


Required Arguments

  • theVehicle: The vehicle which you'd like to retrieve the respawn coordinates of.

Returns

Returns three floats indicating the respawn coordinates of the vehicle, x, y and z respectively.

Example

Accessories-text-editor.png Script Example Missing Function GetVehicleRespawnPosition needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.
-- TODO


See Also