Scripting/Squirrel/Functions/Vehicle.Driver

From Vice City Multiplayer
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