GetPlayerVehicle

From Onset Developer Wiki
GetPlayerVehicle

Type: Function
Context: Server & Client
Introduced: v1.0

Description

Returns the vehicle identifier the player is in.

Syntax

GetPlayerVehicle(player)

Parameters

  • player
    The player identifier.

Return Value

  • Returns the vehicle identifier the player is in. Returns 0 if not in any vehicle.

Example

AddCommand("colorv", function(playerid, red, green, blue)
	local vehicleid = GetPlayerVehicle(playerid)

	if vehicleid == 0 then
		AddPlayerChat(playerid, "You must be in a vehicle...")
		return
	end

	red = tonumber(red)
	green = tonumber(green)
	blue = tonumber(blue)

	if red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255 then
		AddPlayerChat(playerid, "Usage: /colorv <red> <green> <blue>")
		return
	end

	SetVehicleColor(vehicleid, RGB(red, green, blue, 255))
end)

See also