GetPlayerVehicle

From GT-MP
Jump to: navigation, search
GetPlayerVehicle
Shared Function
Utilities-terminal.png Server-Side System-users.png Client-Side
Csharp.png C# Javascript.png JavaScript

This function returns the NetHandle of the vehicle the given player is currently in.


Syntax

API.getPlayerVehicle(Client player);

Required Arguments

  • player: parameter input should be in Client type.

NOTE: This function returns data in NetHandle type.

Usage example(s)

/repair command:

In C#
Server-Side Function

[Command("repair")]
public void CMD_Repair(Client player)
{
    if (!API.isPlayerInAnyVehicle(player))
    {
        API.sendChatMessageToPlayer(player, "ERROR: You're not in a vehicle.");
        return;
    }

    NetHandle vehicle = API.getPlayerVehicle(player);
    API.repairVehicle(vehicle);
}

References