createProjectile | Multi Theft Auto: Wiki Skip to content

createProjectile

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

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.

Note

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 .

Syntax

createProjectile ( )

Code Examples

client

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
end
end
addEventHandler("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