SetWeaponTarget: Difference between revisions
Jump to navigation
Jump to search
Line 21: | Line 21: | ||
*** '''255''': center of the car (position returned by [[getElementPosition]]). | *** '''255''': center of the car (position returned by [[getElementPosition]]). | ||
** '''[[Ped|Peds]]''' (players '''not''' included; see [[getPedBonePosition]] to know where is located each bone): | ** '''[[Ped|Peds]]''' (players '''not''' included; see [[getPedBonePosition]] to know where is located each bone): | ||
***'''1:''' | ***'''1:''' ''BONE_PELVIS1'' position. | ||
***'''2:''' | ***'''2:''' ''BONE_PELVIS'' position. | ||
***'''3:''' | ***'''3:''' ''BONE_SPINE1'' position. | ||
***'''4:''' | ***'''4:''' ''BONE_UPPERTORSO'' position. | ||
***'''5:''' | ***'''5:''' ''BONE_NECK'' position. | ||
***'''6:''' | ***'''6:''' ''BONE_HEAD2'' position. | ||
***'''7:''' | ***'''7:''' ''BONE_HEAD1'' position. | ||
***'''8:''' | ***'''8:''' ''BONE_HEAD'' position. | ||
***'''21:''' | ***'''21:''' ''BONE_RIGHTUPPERTORSO'' position. | ||
***'''22:''' | ***'''22:''' ''BONE_RIGHTSHOULDER'' position. | ||
***'''23:''' | ***'''23:''' ''BONE_RIGHTELBOW'' position. | ||
***'''24:''' | ***'''24:''' ''BONE_RIGHTWRIST'' position. | ||
***'''25:''' | ***'''25:''' ''BONE_RIGHTHAND'' position. | ||
***'''26:''' | ***'''26:''' ''BONE_RIGHTTHUMB'' position. | ||
***'''31:''' | ***'''31:''' ''BONE_LEFTUPPERTORSO'' position. | ||
***'''32:''' | ***'''32:''' ''BONE_LEFTSHOULDER'' position. | ||
***'''33:''' | ***'''33:''' ''BONE_LEFTELBOW'' position. | ||
***'''34:''' | ***'''34:''' ''BONE_LEFTWRIST'' position. | ||
***'''35:''' | ***'''35:''' ''BONE_LEFTHAND'' position. | ||
***'''36:''' | ***'''36:''' ''BONE_LEFTTHUMB'' position. | ||
***'''41:''' | ***'''41:''' ''BONE_LEFTHIP'' position. | ||
***'''42:''' | ***'''42:''' ''BONE_LEFTKNEE'' position. | ||
***'''43:''' | ***'''43:''' ''BONE_LEFTANKLE'' position. | ||
***'''44:''' | ***'''44:''' ''BONE_LEFTFOOT'' position. | ||
***'''51:''' | ***'''51:''' ''BONE_RIGHTHIP'' position. | ||
***'''52:''' | ***'''52:''' ''BONE_RIGHTKNEE'' position. | ||
***'''53:''' | ***'''53:''' ''BONE_RIGHTANKLE'' position. | ||
***'''54:''' | ***'''54:''' ''BONE_RIGHTFOOT'' position. | ||
*** '''255''': | *** '''255''': center of the ped (position returned by [[getElementPosition]]). | ||
===Returns=== | ===Returns=== |
Revision as of 17:41, 23 December 2014
This function sets the target of a custom weapon. There are 3 different targeting modes, which are explained below.
OOP Syntax Help! I don't understand this!
- Note: Variable is read only.
- Method: weapon:setTarget(...)
- Variable: .target
- Counterpart: getWeaponTarget
Syntax (target an entity)
bool setWeaponTarget ( weapon theWeapon, element theTarget [, int theComponent = 255] )
Required arguments
- theWeapon: The weapon to set the target of.
- theTarget: The element to shoot at. It can be a player, ped or object.
Optional arguments
- theComponent: The component of the target to shoot at. This argument is only relevant when used in the following element types:
- Vehicles:
- 0: front left tire.
- 1: front right tire.
- 2: rear left tire.
- 3: rear right tire.
- 255: center of the car (position returned by getElementPosition).
- Peds (players not included; see getPedBonePosition to know where is located each bone):
- 1: BONE_PELVIS1 position.
- 2: BONE_PELVIS position.
- 3: BONE_SPINE1 position.
- 4: BONE_UPPERTORSO position.
- 5: BONE_NECK position.
- 6: BONE_HEAD2 position.
- 7: BONE_HEAD1 position.
- 8: BONE_HEAD position.
- 21: BONE_RIGHTUPPERTORSO position.
- 22: BONE_RIGHTSHOULDER position.
- 23: BONE_RIGHTELBOW position.
- 24: BONE_RIGHTWRIST position.
- 25: BONE_RIGHTHAND position.
- 26: BONE_RIGHTTHUMB position.
- 31: BONE_LEFTUPPERTORSO position.
- 32: BONE_LEFTSHOULDER position.
- 33: BONE_LEFTELBOW position.
- 34: BONE_LEFTWRIST position.
- 35: BONE_LEFTHAND position.
- 36: BONE_LEFTTHUMB position.
- 41: BONE_LEFTHIP position.
- 42: BONE_LEFTKNEE position.
- 43: BONE_LEFTANKLE position.
- 44: BONE_LEFTFOOT position.
- 51: BONE_RIGHTHIP position.
- 52: BONE_RIGHTKNEE position.
- 53: BONE_RIGHTANKLE position.
- 54: BONE_RIGHTFOOT position.
- 255: center of the ped (position returned by getElementPosition).
- Vehicles:
Returns
Returns true on success, false otherwise.
Syntax (target a position)
Fires the weapon at the specified position.
bool setWeaponTarget ( weapon theWeapon, float targetX, float targetY, float targetZ )
Required Arguments
- theWeapon: The weapon to set the target of.
- targetX: The target X.
- targetY: The target Y.
- targetZ: The target Z.
Returns
Returns true on success, false otherwise.
Syntax (rotational target)
Sets the weapon back to rotation based targeting.
bool bool setWeaponTarget ( weapon theWeapon, nil )
Required Arguments
- theWeapon: The weapon to clear the target of.
Returns
Returns true on success, false otherwise.
Requirements
This template will be deleted.
See also
- createWeapon
- fireWeapon
- getWeaponAmmo
- getWeaponClipAmmo
- getWeaponFiringRate
- getWeaponFlags
- getWeaponOwner
- getWeaponProperty
- getWeaponState
- getWeaponTarget
- resetWeaponFiringRate
- setWeaponAmmo
- setWeaponClipAmmo
- setWeaponFiringRate
- setWeaponFlags
- setWeaponProperty
- setWeaponState
- setWeaponTarget