Scripting/Squirrel/Functions/FindVehicle: Difference between revisions
Jump to navigation
Jump to search
This wiki is using an old backup from 2020
Some information may be old/missing
(Created page with "__NOTOC__ This finds a vehicle from an id and returns the pointer == Syntax == <code>vehicle FindVehicle( int id )</code> == Arguments == * '''id''' - The ID of the vehicl...") |
No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Retrieve a vehicle object from vehicle's ID. | |||
== Syntax == | == Syntax == | ||
<code> | <code>FindVehicle( id )</code> | ||
== Arguments == | == Arguments == | ||
* '''id''' - The ID | * ''integer'' '''id''' - The vehicle's ID. | ||
== Example == | == Example == | ||
Now we will create a simple spawncar command. Type / | 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. | ||
< | <source lang=squirrel> | ||
function onPlayerCommand( player, cmd, text ) | function onPlayerCommand( player, cmd, text ) | ||
{ | { | ||
Line 28: | Line 27: | ||
} | } | ||
</ | </source> | ||
Line 35: | Line 34: | ||
== Related Functions == | == Related Functions == | ||
{{Scripting/Squirrel/Functions/Vehicle_Functions}} | |||
{{Scripting/Squirrel/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
- ResetAllVehicleHandling
- IsHandlingRuleSet
- SetHandlingRule
- GetHandlingRule
- ResetHandlingRule
- ResetVehicleHandling
- Vehicle.AddRelTurnSpeed
- Vehicle.AddSpeed
- Vehicle.AddTurnSpeed
- Vehicle.Alarm
- Vehicle.Angle
- Vehicle.Colour1
- Vehicle.Colour2
- Vehicle.Damage
- Vehicle.Delete
- Vehicle.Driver
- Vehicle.EulerAngle
- Vehicle.EulerSpawnAngle
- Vehicle.Fix
- Vehicle.GetHandlingData
- Vehicle.GetOccupant
- Vehicle.GetPart
- Vehicle.GetTyre
- Vehicle.Health
- Vehicle.ID
- Vehicle.Immunity
- Vehicle.IsGhost
- Vehicle.IsHandlingSet
- Vehicle.Kill
- Vehicle.Lights
- Vehicle.Locked
- Vehicle.Model
- Vehicle.Pos
- Vehicle.Radio
- Vehicle.RadioLocked
- Vehicle.RelativeSpeed
- Vehicle.RelativeTurnSpeed
- Vehicle.ResetAllHandling
- Vehicle.ResetHandlingData
- Vehicle.Respawn
- Vehicle.RespawnTimer
- Vehicle.Rotation
- Vehicle.SetFlatTyres
- Vehicle.SetHandlingData
- Vehicle.SetPart
- Vehicle.SetTyre
- Vehicle.Siren
- Vehicle.SpawnAngle
- Vehicle.SpawnPos
- Vehicle.Speed
- Vehicle.StreamedForPlayer
- Vehicle.SyncSource
- Vehicle.SyncType
- Vehicle.TurnSpeed
- Vehicle.TurretRotation
- Vehicle.World
- Vehicle.Wrecked