- Documentation
- Server functions
- createProjectile
Function
createProjectile
Creates a projectile element on the server (grenade, rocket, Molotov, satchel charge, etc.) with a creator, type, force and target. Fires onProjectileCreation. The type is a weapon ID, e.g. 16 grenade, 17 tear gas, 18 Molotov, 19 rocket, 20 heat-seeking rocket, 39 satchel.
Syntax
projectile createProjectile(element creator, int weaponType [, float x = pozycja twórcy, float y = pozycja twórcy, float z = pozycja twórcy, float force = 1, element target = nil, float rx = 0, float ry = 0, float rz = 0, float vx = nil, float vy = 0, float vz = 0])Arguments
creatorelement- Who fired it (player, ped, vehicle).
weaponTypeint- Projectile type (weapon ID).
xfloat, optional = pozycja twórcy- Start X.
yfloat, optional = pozycja twórcy- Start Y.
zfloat, optional = pozycja twórcy- Start Z.
forcefloat, optional = 1- Launch force.
targetelement, optional = nil- Homing projectile target.
rxfloat, optional = 0- Rotation X.
ryfloat, optional = 0- Rotation Y.
rzfloat, optional = 0- Rotation Z.
vxfloat, optional = nil- Velocity X.
vyfloat, optional = 0- Velocity Y.
vzfloat, optional = 0- Velocity Z.
Differences from MTA:SA
- These MTA:SA arguments are not here:
int model
In MTA:SA
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)Returns
The new projectile, or false.
Example
addCommandHandler("granat", function(player)
local x, y, z = getElementPosition(player)
local grenade = createProjectile(player, 16, x, y + 5, z)
setProjectileCounter(grenade, 3000)
end)
Notes
Limitation. The projectile is not drawn in the game yet and does not fly by itself. The explosion is triggered by setProjectileCounter or detonateSatchels (via createExplosion at the projectile's position).
See also
setProjectileCounterSets the projectile's time to explosion in ms. When it runs out, an explosion matching the projectile type happens at its position and the projectile disappears.getProjectileTypeReturns the projectile type (weapon ID).detonateSatchelsDetonates all satchel charges (type 39 projectiles) placed by a player; without a player, all on the server. Each explodes at its position and disappears.createExplosionCreates an explosion at a spot. On the server every player sees it and it hurts like in the game; on the client the explosion is only in that game (it triggersonClientExplosion, which can cancel it). Types 0-12: 0 grenade, 1 molotov, 2 rocket, 3 weak rocket, 4 car, 5 quick car explosion, 6 boat, 7 helicopter, 8 mine, 9 object, 10 tank shell, 11 small, 12 tiny.