Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions code/components/extra-natives-five/src/WeaponExtraNatives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ static int PedOffset = 0x10;
static int CurrentPitchOffset = 0x1CC;
static int NetworkObjectOffset = 0xD0;
static int IsCloneOffset = 0x4B;
static int RangeOffset = 0x28C;

static uint16_t* g_weaponCount;
static uint64_t** g_weaponList;
Expand Down Expand Up @@ -461,6 +462,25 @@ static HookFunction hookFunction([]()
}
});

fx::ScriptEngine::RegisterNativeHandler("GET_WEAPON_RANGE", [](fx::ScriptContext& context)
{
float weaponRange = 0.0f;
if (uintptr_t weapon = getWeaponFromHash(context))
{
weaponRange = reinterpret_cast<hook::FlexStruct*>(weapon)->Get<float>(RangeOffset);
}
context.SetResult<float>(weaponRange);
});

fx::ScriptEngine::RegisterNativeHandler("SET_WEAPON_RANGE", [](fx::ScriptContext& context)
{
if (uintptr_t weapon = getWeaponFromHash(context))
{
float weaponRange = context.GetArgument<float>(1);
reinterpret_cast<hook::FlexStruct*>(weapon)->Set<float>(RangeOffset, weaponRange);
}
});

fx::ScriptEngine::RegisterNativeHandler("SET_FLASH_LIGHT_KEEP_ON_WHILE_MOVING", [](fx::ScriptContext& context)
{
bool value = context.GetArgument<bool>(0);
Expand Down
21 changes: 21 additions & 0 deletions ext/native-decls/GetWeaponRange.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
ns: CFX
apiset: client
game: gta5
---

## GET_WEAPON_RANGE

```c
float GET_WEAPON_RANGE(Hash weaponHash);
```

A getter for the range of a weapon.

## Parameters

- **weaponHash**: Weapon name hash.

## Return value

The range of the weapon as a float.
18 changes: 18 additions & 0 deletions ext/native-decls/SetWeaponRange.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
ns: CFX
apiset: client
game: gta5
---

## SET_WEAPON_RANGE

```c
void SET_WEAPON_RANGE(Hash weaponHash, float range);
```

A setter for the range of a weapon.

## Parameters

- **weaponHash**: Weapon name hash.
- **range**: Ramge.
Loading