IT/createProjectile

From Multi Theft Auto: Wiki
Jump to navigation Jump to search


Questa funzione crea un proiettile del tipo specificato sulle coordinate specificate.

Sintassi

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 ] )

Argomenti richiesti

  • creator: L'element rappresenta il creatore del proiettile. In caso vuoi che il proiettile sia sincronizzato per tutti, il creatore deve essere getLocalPlayer().
  • weaponType: int rappresenta il proiettile weaponType (caratteristiche). Gli ID validi sono:
« Torna alla Pagina principale italiana .

Gli esplosivi (projectiles) sono dei tipi di arma particolari, usati con la funzione client-side createProjectile.

  • 16: Granata
  • 17: Granata a gas
  • 18: Molotov
  • 19: Razzo (semplice)
  • 20: Razzo (a ricerca termica)
  • 21: Missile di Hydra

Argomenti opzionali

Template:IT/OptionalArg

  • posX,posY,posZ: float starting coordinates for the projectile. They are coordinates of creator by default.
  • force: float representing the starting force of the projectile.
  • target: element target used for heat seeking rockets.
  • rotX,rotY,rotZ: float starting rotation for the projectile.
  • velX,velY,velZ: float starting velocity for the projectile.
  • model: Integer representing the projectile's model, uses default model for weaponType if not specified.

Returns

Returns a projectile element if projectile creation was succesfull. Returns false if unable to create a projectile (wrong weapon ID or projectiles limit was reached).

Example

This example makes a rocket minigun (minigun shooting with rockets).

-- This function gets triggered everytime player shoots.
function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement)
	if weapon == 38 then -- if source is a local player and he uses minigun...
		if not createProjectile(getLocalPlayer(),19,getElementPosition(getLocalPlayer()),200) then -- then we either create a projectile...
			outputChatBox ( "Rocket minigun overheated! Give it a rest pal!", source ) -- or if projectile limit is reached we output player a chat message
		end
	end
end

-- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire.
addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc)

See also