GetWeaponTarget: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 18: Line 18:
function CreateWeapon ()
function CreateWeapon ()
   local weapon = createWeapon ("m4", 0, 0, 0)  --create gun "m4" in 0,0,0 position.
   local weapon = createWeapon ("m4", 0, 0, 0)  --create gun "m4" in 0,0,0 position.
   local weapontarget = GetWeaponTarget ( weapon )
   local weapontarget = getWeaponTarget ( weapon )
     if weapontarget then
     if weapontarget then
     setTimer (function()
     setTimer (function()

Revision as of 09:30, 15 November 2013

Accessories-text-editor.png Script Example Missing Function GetWeaponTarget needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.

Get the target of the custom weapon.

Syntax

element getWeaponTarget ( weapon theWeapon )

Required Arguments

  • theWeapon: The weapon to get the target of.

Returns

Returns the target element of the custom weapon, false otherwise.

Example

Create Weapon and get weapon target.When it founded - fire weapon to the target all time,if it in the weapon sight.

function CreateWeapon ()
  local weapon = createWeapon ("m4", 0, 0, 0)  --create gun "m4" in 0,0,0 position.
  local weapontarget = getWeaponTarget ( weapon )
    if weapontarget then
    setTimer (function()
    fireWeapon ( weapon )
    end,100,0)
    end
end
addEventHandler ("onClientResourceStart",getRootElement(),CreateWeapon)

Requirements

This template will be deleted.

See Also