Ayuto wrote:Seems like my hook never gets called. :(
What about something like this?
Syntax: Select all
from events import Event
from entities.helpers import index_from_inthandle
from players.entity import Player
from weapons.entity import Weapon
from weapons.manager import weapon_manager
@Event('weapon_reload')
def weapon_reload(event):
player = Player.from_userid(event['userid'])
try:
weapon_index = index_from_inthandle(player.active_weapon)
except (ValueError, OverflowError):
return
weapon = Weapon(weapon_index)
weapon.ammo = weapon_manager[weapon.classname].maxammo
Dang! This way, the ammo will not reset after the weapon has been reloaded, for example with the AK47:
Ammo: 90 (full), Clip: 15
Pressing Reload:
- Ammo: 90
- Clip: 15
... (after the animation)
- Ammo: 75
- Clip: 30
Again pressing reload when clip is 15:
- Ammo: 90
- Clip: 15
...(after the animation)
- Ammo: 75
- Clip: 30
Which would suffice, however that is kinda "ugly" lol. Tried that already :D
I'll stick with the delay method, as this works how I want to. Thank you very much!
Edit: Player.from_userid()? Seems like I can reject my oen implementation for this lol :D