Scripting/Squirrel/Functions/Vehicles/FindVehicle
From VC-MP Wiki
This finds a vehicle from an id and returns the pointer
Syntax
vehicle FindVehicle( int id )
Arguments
- id - The ID of the vehicle to find
Example
Now we will create a simple spawncar command. Type /c 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
- CreateVehicle
- FindVehicle
- GetVehicleCount
- GetVehicleModelFromName
- GetVehicleNameFromModel
- Vehicle.Alarm
- Vehicle.Angle
- Vehicle.Colour1
- Vehicle.Colour2
- Vehicle.Driver
- Vehicle.Fix
- Vehicle.Health
- Vehicle.ID
- Vehicle.IsLocked
- Vehicle.KillEngine
- Vehicle.Lights
- Vehicle.Model
- Vehicle.Pos
- Vehicle.Respawn
- Vehicle.RespawnAs
- Vehicle.RespawnAt
- Vehicle.SetFlatTyres
- Vehicle.SpawnPos
- Vehicle.SpawnAngle
- Vehicle.Velocity
- Vehicle.Remove
