createProjectile
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
This function creates a projectile of the specified type on the specified coordinates.
Model argument is not synchronized between clients. Clients differs from local player see always standard projectile model. Target argument valid elements are: player , ped , vehicle and object .
OOP Syntax Help! I don't understand this!
- Constructor: Projectile (...)
Syntax
projectile createProjectile ( element creator, int weaponType, float posX, float posY, float posZ, [ float force = 1.0, element target = nil ], float rotX, float rotY, float rotZ, float velX, float velY, float velZ, int model )Required Arguments
- creator: The element representing creator of the projectile. In case you want the projectile to be synced for everybody creator must be the local player or his vehicle.
- weaponType: int representing the projectile weaponType (characteristics). Valid IDs are:
- posX: float starting coordinates for the projectile. They are coordinates of creator by default.
- posY: MISSING_PARAM_DESC
- posZ: MISSING_PARAM_DESC
- rotX: float starting rotation for the projectile.
- rotY: MISSING_PARAM_DESC
- rotZ: MISSING_PARAM_DESC
- velX: float starting velocity for the projectile.
- velY: MISSING_PARAM_DESC
- velZ: MISSING_PARAM_DESC
- model: Integer representing the projectile's model, uses default model for weaponType if not specified.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- force (default: 1.0): float representing the starting force for throwable projectiles.
- target (default: nil): element target used for heat seeking rockets.
Returns
- projectile: value
Returns a projectile element if projectile creation was successful. Returns false if unable to create a projectile (wrong weapon ID or projectiles limit was reached).
Code Examples
This example makes a rocket minigun (minigun shooting with rockets).
function onClientPlayerWeaponFire(weaponID, weaponAmmo, weaponAmmoInClip, hitX, hitY, hitZ, hitElement) local minigunWeapon = (weaponID == 38) -- check if player is using minigun
if (not minigunWeapon) then return false -- he doesn't, so don't continue end
local playerX, playerY, playerZ = getElementPosition(source) -- get position of player local projectileType = 19 -- type of projectile local projectileForce = 200 -- force used for projectile local rocketProjectile = createProjectile(source, projectileType, playerX, playerY, playerZ, projectileForce) -- create rocket projectile
if (not rocketProjectile) then -- if projectile limit is reached outputChatBox("Rocket minigun overheated! Give it a rest pal!", source) -- output a message endendaddEventHandler("onClientPlayerWeaponFire", localPlayer, onClientPlayerWeaponFire)Issues
| ID | Description |
|---|---|
| 584 | createProjectile creates one projectile for every person in the vehicle |
| 616 | Projectile rotation is set exactly opposite for creator |