Koja Scripts
KOJA-LIB

Weapon

Utility function for reading the player's current weapon state.

Weapon

Utility function for reading the player's current weapon state.


getCurrentWeaponInfo

Returns information about the weapon the ped currently has equipped.

local info = KOJA.Client.getCurrentWeaponInfo(ped)
ParameterTypeDescription
pednumberPed entity handle

Returns table | nil

FieldTypeDescription
weaponHashnumberHash of the current weapon
ammoInClipnumberBullets remaining in the current magazine
totalAmmonumberTotal ammo carried for this weapon

Returns nil if the ped has no weapon equipped.


Example

local ped = PlayerPedId()
local info = KOJA.Client.getCurrentWeaponInfo(ped)

if info then
    print('Weapon hash:', info.weaponHash)
    print('Clip ammo:', info.ammoInClip)
    print('Total ammo:', info.totalAmmo)
else
    print('No weapon equipped')
end

With weapon name lookup:

local info = KOJA.Client.getCurrentWeaponInfo(PlayerPedId())
if info then
    local name = GetDisplayNameFromVehicleModel(info.weaponHash)  -- works for weapons too
    print('Equipped:', name)
end
  • Getting Started — Configuration and Installation for Getting Started.
  • API Reference — Client API and Server API for API Reference.
  • Frameworks — Custom Framework and Overview for Frameworks.
  • Inventory — Custom Inventory and Overview for Inventory.
  • Text UI — A small on-screen prompt that shows an action key and a label.
  • Vehicle — Utility functions for reading vehicle state on the client.