GetVehicleName

From Liberty Unleashed Wiki
Jump to: navigation, search
Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

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.

Syntax

GetVehicleName can take different lists of parameters:

  1. string GetVehicleName( int model )
  1. string GetVehicleName( Vehicle veh )

Arguments

  • model - The model you wish to return the name for
  • veh - A Vehicle instance you wish to return the name for

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.

  1.  
  2. function onPlayerCommand( pPlayer, szCommand, szText )
  3. {
  4. if ( szCommand == "vehname" )
  5. {
  6. local iID = szText ? szText.tointeger() : VEH_LANDSTALKER;
  7. local szName = GetVehicleName( iID );
  8. MessagePlayer( "Vehicle model id - " + iID + ", name - " + szName, pPlayer );
  9. }
  10. else if ( szCommand == "vehname2" )
  11. {
  12. local pVehicle = pPlayer.Vehicle;
  13. if ( pVehicle )
  14. {
  15. local szName = GetVehicleName( pVehicle )
  16. MessagePlayer( "Vehicle model id - " + pVehicle.Model + ", name " + szName, pPlayer );
  17. }
  18. }
  19. return 1;
  20. }
  21.  

Notes

The functions MessagePlayer, Player.Vehicle and event onPlayerCommand were used in this example. More info about them in the corresponding pages.

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox