Scripting/Squirrel/Functions/FindVehicle: Difference between revisions

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
No edit summary
No edit summary
 
Line 32: Line 32:
=== Notes ===
=== Notes ===
The functions [[Scripting/Squirrel/Functions/Misc/PrivMessage|PrivMessage]], [[Scripting/Squirrel/Functions/Vehicles/Pos|vehicle.Pos]] and call [[Scripting/Squirrel/Events/Player/onPlayerCommand|onPlayerCommand]] were used in in this example. More info about them in the corresponding pages.
The functions [[Scripting/Squirrel/Functions/Misc/PrivMessage|PrivMessage]], [[Scripting/Squirrel/Functions/Vehicles/Pos|vehicle.Pos]] and call [[Scripting/Squirrel/Events/Player/onPlayerCommand|onPlayerCommand]] were used in in this example. More info about them in the corresponding pages.
== Related Functions ==
{{Scripting/Squirrel/Functions/Vehicle_Functions}}
[[Category:Scripting/Squirrel/Functions/Vehicle_Functions]]

Latest revision as of 22:02, 30 January 2017

Retrieve a vehicle object from vehicle's ID.

Syntax

FindVehicle( id )

Arguments

  • integer id - The vehicle's ID.

Example

Now we will create a simple spawncar command. Type /spawn VehicleID. The vehicle will be moved to the player, that uses this command. The FindVehicle function is here very important.

function onPlayerCommand( player, cmd, text )
{
     if ( cmd == "spawn" )
     {
         local veh = FindVehicle( text.tointeger() );
         if ( !veh ) PrivMessage( "Error: Wrong ID of the vehicle.", player );
         else {
             PrivMessage( "Spawning vehicle " + veh + ".", player );
             veh.Pos = Vector( ( player.Pos.x + 2 ), ( player.Pos.y + 1 ),( player.Pos.z - 1.12 ) );
         }
     }

}


Notes

The functions PrivMessage, vehicle.Pos and call onPlayerCommand were used in in this example. More info about them in the corresponding pages.

Related Functions