SpawnVehicle: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 24: | Line 24: | ||
==Example== | ==Example== | ||
<section name="Server" class="server" show="true"> | |||
With this feature, we spawn vehicle | |||
<syntaxhighlight lang="lua"> | |||
local x, y, z = getElementPosition(source) | |||
function myCommandHandler(source, command) | |||
local RaceVehicle = createVehicle ( 411, 0, 0, 0 ) | |||
local spawnVeh = spawnVehicle ( RaceVehicle, x+3, y+3, z ) end | |||
if spawnVeh then outputChatBox("Vehicle was spawned", source) else outputChatBox("Error",source) end | |||
end | |||
addCommandHandler("spawnvehicle", myCommandHandler) | |||
</syntaxhighlight> | |||
</section> | |||
==Related scripting functions== | ==Related scripting functions== | ||
{{Vehicle functions}} | {{Vehicle functions}} | ||
[[Category:Element Types]] | [[Category:Element Types]] |
Revision as of 10:17, 24 May 2010
Spawns a vehicle at any given position and rotation
Syntax
bool spawnVehicle ( vehicle theVehicle, float x, float y, float z [, float rx, float ry, float rz ] )
Required Arguments
- theVehicle: The vehicle you wish to spawn
- x: The x position you wish to spawn the vehicle at
- y: The x position you wish to spawn the vehicle at
- z: The x position you wish to spawn the vehicle at
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use. For more information on optional arguments, see optional arguments.
- rx: The x rotation you wish to spawn the vehicle at
- ry: The y rotation you wish to spawn the vehicle at
- rz: The z rotation you wish to spawn the vehicle at
Returns
Returns true if the vehicle spawned successfully, false if the passed argument does not exist or is not a vehicle.
Example
Click to collapse [-]
ServerWith this feature, we spawn vehicle
local x, y, z = getElementPosition(source) function myCommandHandler(source, command) local RaceVehicle = createVehicle ( 411, 0, 0, 0 ) local spawnVeh = spawnVehicle ( RaceVehicle, x+3, y+3, z ) end if spawnVeh then outputChatBox("Vehicle was spawned", source) else outputChatBox("Error",source) end end addCommandHandler("spawnvehicle", myCommandHandler)
Related scripting functions
- addVehicleUpgrade
- attachTrailerToVehicle
- blowVehicle
- createVehicle
- detachTrailerFromVehicle
- fixVehicle
- getOriginalHandling
- getTrainDirection
- getTrainPosition
- getTrainSpeed
- getTrainTrack
- getVehicleColor
- getVehicleCompatibleUpgrades
- getVehicleController
- getVehicleDoorOpenRatio
- getVehicleDoorState
- getVehicleEngineState
- getVehicleHandling
- getVehicleHeadLightColor
- getVehicleLandingGearDown
- getVehicleLightState
- getVehicleMaxPassengers
- getVehicleModelFromName
- getVehicleName
- getVehicleNameFromModel
- getVehicleOccupant
- getVehicleOccupants
- getVehicleOverrideLights
- getVehiclePaintjob
- getVehiclePanelState
- getVehiclePlateText
- getVehicleSirenParams
- getVehicleSirens
- getVehicleSirensOn
- getVehicleTowedByVehicle
- getVehicleTowingVehicle
- getVehicleTurretPosition
- getVehicleType
- getVehicleUpgradeOnSlot
- getVehicleUpgradeSlotName
- getVehicleUpgrades
- getVehicleVariant
- getVehicleWheelStates
- isTrainDerailable
- isTrainDerailed
- isVehicleBlown
- isVehicleDamageProof
- isVehicleFuelTankExplodable
- isVehicleLocked
- isVehicleOnGround
- isVehicleTaxiLightOn
- removeVehicleUpgrade
- setTrainDerailable
- setTrainDerailed
- setTrainDirection
- setTrainPosition
- setTrainSpeed
- setTrainTrack
- setVehicleColor
- setVehicleDamageProof
- setVehicleDoorOpenRatio
- setVehicleDoorState
- setVehicleDoorsUndamageable
- setVehicleEngineState
- setVehicleFuelTankExplodable
- setVehicleHandling
- setVehicleHeadLightColor
- setVehicleLandingGearDown
- setVehicleLightState
- setVehicleLocked
- setVehicleOverrideLights
- setVehiclePaintjob
- setVehiclePanelState
- setVehiclePlateText
- setVehicleSirens
- setVehicleSirensOn
- setVehicleTaxiLightOn
- setVehicleTurretPosition
- setVehicleVariant
- setVehicleWheelStates