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)
Parameter
Type
Description

ped

number

Ped entity handle

Returns table | nil

Field
Type
Description

weaponHash

number

Hash of the current weapon

ammoInClip

number

Bullets remaining in the current magazine

totalAmmo

number

Total 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:

Last updated