Squirrel/Server/Functions/Vehicles/GetVehicleName
From Liberty Unleashed Wiki
(Difference between revisions)
(→Example) |
(Made the examples more general, optimisation) |
||
Line 14: | Line 14: | ||
== Example == | == Example == | ||
+ | |||
+ | These two example commands return the name of the vehicle from model ID or the name of the vehicle the player is currently occupying. | ||
<code lang="squirrel"> | <code lang="squirrel"> | ||
Line 20: | Line 22: | ||
if ( szCommand == "vehname" ) | if ( szCommand == "vehname" ) | ||
{ | { | ||
− | local | + | local iID = szText ? szText.tointeger() : VEH_LANDSTALKER; |
− | + | local szName = GetVehicleName( iID ); | |
+ | MessagePlayer( "Vehicle model id - " + iID + ", name - " + szName, pPlayer ); | ||
} | } | ||
− | if ( szCommand == "vehname2" ) | + | else if ( szCommand == "vehname2" ) |
{ | { | ||
− | local pVehicle = | + | local pVehicle = pPlayer.Vehicle; |
if ( pVehicle ) | if ( pVehicle ) | ||
{ | { | ||
− | szName = | + | local szName = GetVehicleName( pVehicle ) |
− | + | MessagePlayer( "Vehicle model id - " + pVehicle.Model + ", name " + szName, pPlayer ); | |
} | } | ||
} | } | ||
Line 40: | Line 43: | ||
=== Notes === | === Notes === | ||
− | The functions [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] | + | The functions [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]], [[Squirrel/Server/Functions/Players/Vehicle|Player.Vehicle]] and event [[Squirrel/Server/Events/Player/onPlayerCommand|onPlayerCommand]] were used in this example. More info about them in the corresponding pages. |
== Related Functions == | == Related Functions == | ||
{{Squirrel/Server/Functions/Vehicles}} | {{Squirrel/Server/Functions/Vehicles}} |
Latest revision as of 19:14, 29 September 2010
This function returns the name of the vehicle. The function can be used to retrieve the name of a specific vehicle or return the name of a model ID.
[edit] Syntax
GetVehicleName can take different lists of parameters:
string GetVehicleName( int model )
string GetVehicleName( Vehicle veh )
[edit] Arguments
- model - The model you wish to return the name for
- veh - A Vehicle instance you wish to return the name for
[edit] Example
These two example commands return the name of the vehicle from model ID or the name of the vehicle the player is currently occupying.
function onPlayerCommand( pPlayer, szCommand, szText ) { if ( szCommand == "vehname" ) { local iID = szText ? szText.tointeger() : VEH_LANDSTALKER; local szName = GetVehicleName( iID ); MessagePlayer( "Vehicle model id - " + iID + ", name - " + szName, pPlayer ); } else if ( szCommand == "vehname2" ) { local pVehicle = pPlayer.Vehicle; if ( pVehicle ) { local szName = GetVehicleName( pVehicle ) MessagePlayer( "Vehicle model id - " + pVehicle.Model + ", name " + szName, pPlayer ); } } return 1; }
[edit] Notes
The functions MessagePlayer, Player.Vehicle and event onPlayerCommand were used in this example. More info about them in the corresponding pages.
[edit] Related Functions
- CreateVehicle
- FindVehicle
- GetClosestVehicle
- GetVehicleCount
- GetVehicleHandlingData
- GetVehicleIDFromName
- GetVehicleName
- SetVehicleHandlingData
- Vehicle.Alpha
- Vehicle.Angle
- Vehicle.Colour1
- Vehicle.Colour2
- Vehicle.Driver
- Vehicle.EngineDamage
- Vehicle.Explode
- Vehicle.Fix
- Vehicle.GetAddon
- Vehicle.GetPassenger
- Vehicle.GetHandlingData
- Vehicle.GetWheelStatus
- Vehicle.Health
- Vehicle.ID
- Vehicle.IdleRespawnTime
- Vehicle.IdleTime
- Vehicle.LightState
- Vehicle.Locked
- Vehicle.Marker
- Vehicle.MarkerScale
- Vehicle.MarkerSprite
- Vehicle.Model
- Vehicle.OneTime
- Vehicle.PassengerCount
- Vehicle.Pos
- Vehicle.Remove
- Vehicle.Respawn
- Vehicle.RespawnTime
- Vehicle.RGBColour1
- Vehicle.RGBColour2
- Vehicle.SetHandlingData
- Vehicle.SetWheelStatus
- Vehicle.SpawnAngle
- Vehicle.SpawnPos
- Vehicle.SetAddon
- Vehicle.SetEngineState
- Vehicle.SetRadio
- Vehicle.Siren
- Vehicle.SirenLight
- Vehicle.TaxiLight
- Vehicle.Velocity
- Vehicle.VirtualWorld
- Vehicle.Wrecked