TASK_SHOOT_AT_ENTITY
Entity aimedentity; Player player = PLAYER::PLAYER_ID(); in practical usage, getting the entity the player is aiming at and then task the peds to shoot at the entity, at a button press event would be better.
Signature
void TASK_SHOOT_AT_ENTITY(Entity entity, Entity target, int duration, Hash firingPattern);Parameters
| Name | Type | Description |
|---|---|---|
entity | Entity | — |
target | Entity | — |
duration | int | — |
firingPattern | Hash | — |
Returns void
Description
//this part of the code is to determine at which entity the player is aiming, for example if you want to create a mod where you give orders to peds
Entity aimedentity;
Player player = PLAYER::PLAYER_ID();
PLAYER::_GET_AIMED_ENTITY(player, &aimedentity);
//bg is an array of peds
TASK::TASK_SHOOT_AT_ENTITY(bg[i], aimedentity, 5000, MISC::GET_HASH_KEY("FIRING_PATTERN_FULL_AUTO"));
in practical usage, getting the entity the player is aiming at and then task the peds to shoot at the entity, at a button press event would be better.
Firing Pattern Hash Information: https://pastebin.com/Px036isBThis is the server-side RPC native equivalent of the client native TASK_SHOOT_AT_ENTITY.
Usage
TaskShootAtEntity(entity, target, duration, firingPattern)
-- always works, by hash
Citizen.InvokeNative(0xac0631c9, entity, target, duration, firingPattern)JavaScript and C#
TaskShootAtEntity(entity, target, duration, firingPattern);
// by hash
Citizen.invokeNative('0xac0631c9', entity, target, duration, firingPattern);Function.Call((Hash)0xac0631c9, entity, target, duration, firingPattern);- Hash parameters: the named function also accepts a string and hashes it for you;
Citizen.InvokeNativeneeds the number — passjoaat("name")or a backtick literal like`name`.
Sources
Something wrong or missing? Contribute a verified note — corrections ship through pull requests.