Scripting/Squirrel/Functions/Vehicle.Driver

From Vice City Multiplayer
Revision as of 09:36, 24 November 2017 by Umar4911 (talk | contribs) (Created page with "This function will tell the name of the car driver. == Syntax == <pre>Vehicle.Driver()</pre> == Example == <source lang="squirrel"> function onPlayerCommand( player, cmd,...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing

This function will tell the name of the car driver.

Syntax

Vehicle.Driver()

Example

function onPlayerCommand( player, cmd, text )
{
	if(cmd == "driver")
	{
		if(!text) MessagePlayer("Syntax Error - Syntax: /driver <vehicle ID>", player);
		else if(!IsNum(text)) MessagePlayer("Error - ID must be integer", player);
		else
		{
			local veh = FindVehicle(text.tointeger());
			if(!veh) MessagePlayer("Unknown Vehicle", player);
			else if(!veh.Driver) MessagePlayer("There is no driver in the vehicle", player);
			else if(veh.Driver == player.Name) MessagePlayer("You are the driver", player);
			else
			{
				MessagePlayer(veh.Driver + " is driving the vehicle", player);
			}
		}
	}
}

Notes

Call onPlayerCommand were used in this example. More info about them in the corresponding pages.

Related Functions