GetVehicleRespawnPosition: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Replace with the new native function)
Line 16: Line 16:


==Example==
==Example==
{{Example}}
This example outputs the player's current vehicle respawn position.
<syntaxhighlight lang="lua">
function getRespawnPosition(plr)
    if (not plr) then
        return false
    end
    local veh = getPedOccupiedVehicle(plr)
    if (not veh) then
        return false
    end
    local x, y, z = getVehicleRespawnPosition(veh)
    return x, y, z
end
</syntaxhighlight>


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

Revision as of 12:09, 14 December 2020

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

This example outputs the player's current vehicle respawn position.

function getRespawnPosition(plr)
    if (not plr) then
        return false
    end
    local veh = getPedOccupiedVehicle(plr)
    if (not veh) then
        return false
    end
    local x, y, z = getVehicleRespawnPosition(veh)
    return x, y, z
end

See Also