CreateVehicle: Difference between revisions
No edit summary |
|||
Line 6: | Line 6: | ||
'''Important Note:''' Vehicles created client side are only seen by the client that creates, them, aren't synced and players cannot enter them. They are essentially for display only. | '''Important Note:''' Vehicles created client side are only seen by the client that creates, them, aren't synced and players cannot enter them. They are essentially for display only. | ||
==Syntax== | ==Syntax== | ||
Line 27: | Line 28: | ||
===Returns=== | ===Returns=== | ||
Returns the [[vehicle]] element that was created. Returns ''false'' if the arguments are incorrect, or if the vehicle limit of 65535 is exceeded. | Returns the [[vehicle]] element that was created. Returns ''false'' if the arguments are incorrect, or if the vehicle limit of 65535 is exceeded. | ||
==Using trains== | ==Using trains== | ||
Trains are created using the createVehicle function. They are placed at the nearest point of the GTASA train pathing (railroad tracks) from their spawning point. | Trains are created using the createVehicle function. They are placed at the nearest point of the GTASA train pathing (railroad tracks) from their spawning point. | ||
==Example== | ==Example== | ||
Line 60: | Line 63: | ||
</section> | </section> | ||
<section name="Example 3: Server" class="server" show=" | <section name="Example 3: Server" class="server" show="false"> | ||
This example creates a vehicle five units to the right of a player when they type ''createvehicle'' and its name in the console: | This example creates a vehicle five units to the right of a player when they type ''createvehicle'' and its name in the console: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
Line 97: | Line 100: | ||
==See Also== | ==See Also== | ||
{{IDs}} | {{IDs}} | ||
{{Vehicle functions}} | {{Vehicle functions}} |
Revision as of 22:37, 30 March 2009
This function creates a vehicle at the specified location.
Its worth noting that the position of the vehicle is the center point of the vehicle, not its base. As such, you need to ensure that the z value (vertical axis) is some height above the ground. You can find the exact height using the client side function getElementDistanceFromCentreOfMassToBaseOfModel, or you can estimate it yourself and just spawn the vehicle so it drops to the ground.
Important Note: Vehicles created client side are only seen by the client that creates, them, aren't synced and players cannot enter them. They are essentially for display only.
Syntax
vehicle createVehicle ( int model, float x, float y, float z, [float rx, float ry, float rz, string numberplate] )
Required Arguments
- model: The vehicle ID of the vehicle being created.
- x: A floating point number representing the X coordinate on the map.
- y: A floating point number representing the Y coordinate on the map.
- z: A floating point number representing the Z coordinate on the map.
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: A floating point number representing the rotation about the X axis in degrees.
- ry: A floating point number representing the rotation about the Y axis in degrees.
- rz: A floating point number representing the rotation about the Z axis in degrees.
- numberplate: A string that will go on the number plate of the car (max 8 characters). This is only applicable to cars.
Returns
Returns the vehicle element that was created. Returns false if the arguments are incorrect, or if the vehicle limit of 65535 is exceeded.
Using trains
Trains are created using the createVehicle function. They are placed at the nearest point of the GTASA train pathing (railroad tracks) from their spawning point.
Example
This script spawns a Rhino on top of one lucky individual.
function scriptCreateTank ( player, command ) local luckyBugger = getRandomPlayer() -- get a random player local x, y, z = getElementPosition ( luckyBugger ) -- retrive the player's position createVehicle ( 432, x, y, z + 10 ) -- create the tank 10 units above them outputChatBox ( "You got Tank'd!", luckyBugger ) end --Attach the 'scriptCreateTank' function to the "tank" command addCommandHandler ( "tank", scriptCreateTank )
This script spawns a Rhino on top of the local player.
function scriptCreateTank ( commandName ) local luckyBugger = getLocalPlayer() -- get the local player local x, y, z = getElementPosition ( luckyBugger ) -- retrive the player's position createVehicle ( 432, x, y, z + 10 ) -- create the tank 10 units above them outputChatBox ( "You got Tank'd!", luckyBugger ) end --Attach the 'scriptCreateTank' function to the "tank" command addCommandHandler ( "tank", scriptCreateTank )
See Also
GTASA IDs (vehicles, weapons, weathers, characters, colors): http://info.vces.net/ (Special thanks to Brophy and Ratt for making these lists)
- 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