SpawnVehicle: Difference between revisions
Jump to navigation
Jump to search
Syytuvanaema (talk | contribs) |
|||
Line 21: | Line 21: | ||
==Example== | ==Example== | ||
There is currently no example - Do you have one? if so submit it! | |||
<section name="Example: Server" class="server" show="true"> | |||
This script spawns a car 5 units to the right of player (NEEDS CHECKING). | |||
<syntaxhighlight lang="lua"> | |||
function spawncar( source, commandName, carid ) | |||
if ( isPlayerInVehicle ( source ) == false ) then | |||
local x, y, z = getElementPosition ( source ) | |||
local rotZ = getPlayerRotation ( source ) | |||
x = x + ( ( math.cos ( math.rad ( rotZ ) ) ) * 5 ) | |||
y = y + ( ( math.sin ( math.rad ( rotZ ) ) ) * 5 ) | |||
if ( spawnVehicle ( carid, x, y, z, 0, 0, rotZ ) ) then | |||
outputChatBox ( "You spawned a car!", source, 0, 255, 0, true ) | |||
else | |||
outputChatBox ( "Failed to spawn a car!", source, 0, 255, 0, true ) | |||
end | |||
end | |||
end | |||
addCommandHandler ( "car", spawncar ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 19:00, 24 August 2008
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
- 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
There is currently no example - Do you have one? if so submit it! <section name="Example: Server" class="server" show="true"> This script spawns a car 5 units to the right of player (NEEDS CHECKING).
function spawncar( source, commandName, carid ) if ( isPlayerInVehicle ( source ) == false ) then local x, y, z = getElementPosition ( source ) local rotZ = getPlayerRotation ( source ) x = x + ( ( math.cos ( math.rad ( rotZ ) ) ) * 5 ) y = y + ( ( math.sin ( math.rad ( rotZ ) ) ) * 5 ) if ( spawnVehicle ( carid, x, y, z, 0, 0, rotZ ) ) then outputChatBox ( "You spawned a car!", source, 0, 255, 0, true ) else outputChatBox ( "Failed to spawn a car!", source, 0, 255, 0, true ) end end end addCommandHandler ( "car", spawncar )
See Also
- 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