GetPlayerVehicle: Difference between revisions

From Onset Developer Wiki
28days (talk | contribs)
No edit summary
28days (talk | contribs)
No edit summary
 
Line 34: Line 34:


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
{{Template:VehicleFunctions}}

Latest revision as of 09:58, 12 December 2019

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