ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Server functions
  3. setWeaponTarget

Function

setWeaponTarget

Aims a scripted weapon at an element or a point. With no target (nil) it stops aiming.

Syntax

Element

bool setWeaponTarget(weapon theWeapon, element target)

Point

bool setWeaponTarget(weapon theWeapon, float x, float y, float z)

Arguments

weaponweapon
The scripted weapon.Not in MTA:SA
targetOrXelement/float, optional = nil
The target element or the X position.Not in MTA:SA
yfloat, optional = nil
Y position (for a point).Not in MTA:SA
zfloat, optional = nil
Z position (for a point).Not in MTA:SA

Differences from MTA:SA

  • In MTA:SA this function is client-side only.
  • Arguments in a different colour differ from MTA:SA.

In MTA:SA

setWeaponTarget()

Returns

true on success.

Example

addEventHandler("onPlayerSpawn", root, function()
    setWeaponTarget(turret, source)
end)

See also