{$CLEO}
0000:NOP
// Disable automatic reload when scrolling weapons.
0A8C: write_memory 0x0060B4DA size 4 value 0xEB08C483 virtual_protect 1
0A8C: write_memory 0x0060B4DE size 1 value 0x21 virtual_protect 1

const
   FIRETYPE_MELEE = 0
   FIRETYPE_INSTANT_HIT = 1
   FIRETYPE_PROJECTILE = 2
   FIRETYPE_AREA_EFFECT = 3
   FIRETYPE_CAMERA = 4
   FIRETYPE_USE = 5
end

const
   FIRESTATE_IDLE = 0
   FIRESTATE_FIRING = 1
   FIRESTATE_RELOADING = 2
   // There are probably more.
end

while true
wait 0 ms
    gosub @WeaponBase
    gosub @Firetype
    if
    4@ == FIRETYPE_INSTANT_HIT
    then
        gosub @AmmoInClip
        if
        0039:   6@ == 0
        then
            if
            00E1:   player 0 pressed_key 17
            then
            0AAC: 10@ = load_audiostream "CLEO\CLEO_SOUNDS\EmptyClip.mp3"
                if
                8039:   NOT   10@ ==  -1
                then
                0AAD: set_mp3 10@ perform_action 1
                0ABC: set_audiostream 10@ volume 1.0
                0AAF: 10@ = get_mp3_length 11@
                32@ = 0
                repeat
                wait 0 ms
                until 80E1:   not player 0 pressed_key 17
                repeat
                wait 0 ms
                until 002D:   32@ >= 11@  // (int)
                0AAE: release_mp3 10@
                end
            end
        end
    end
end

:WeaponBase
0A96: 0@ = actor $PLAYER_ACTOR struct
0AA8: call_function_method 0x5E6580 struct 0@ num_params 0 pop 0 cSkillIndex 2@ // CPed__getWeaponSkillIndex
0470: 1@ = actor $PLAYER_ACTOR current_weapon
0AA7: call_function 0x743C60 num_params 2 pop 2 cSkillIndex 2@ sWeaponType 1@ pclWeaponInfo 3@ // getWeaponInfo
return

:FireType
0A8E: 4@ = 3@ + 0x00 // CWeaponInfo.m_eFireType
0A8D: 4@ = read_memory 4@ size 4 virtual_protect 0
return

:AmmoInClip
0A8E: 7@ = 0@ + 0x0718 // CPed.m_cWeaponSlot
0A8D: 7@ = read_memory 7@ size 1 virtual_protect 0
7@ *= 0x1C // sizeof(CWeaponSlot)
0A8E: 8@ = 0@ + 0x5A0 // CPed.m_aclWeaponSlots
005A: 8@ += 7@
0A8E: 8@ = 8@ + 0x08 // CWeaponSlot.m_iClipAmmo
0A8D: 6@ = read_memory 8@ size 1 virtual_protect 0    
return