Skip to content

Add events onPlayerWeaponGiven/onPlayerWeaponTaken #2157

@ricksterhd123

Description

@ricksterhd123

Is your feature request related to a problem? Please describe.

I wish to know when a player has been given or taken a weapon(s) with giveWeapon/takeWeapon/takeAllWeapons functions.

Describe the solution you'd like

I would like server-sided events such as 'onPlayerWeaponGiven' and 'onPlayerWeaponTaken' which are triggered before 'giveWeapon' or 'takeWeapon' is executed so that I can cancel the event. For both events the source is obviously a player element and the handler will supply a weapon id. I'm not quite sure how one should handle 'takeAllWeapons' but I assume you could trigger 'onPlayerWeaponTaken' for each weapon in the player's inventory.

Describe alternatives you've considered

The only alternative I could think of is using 'addDebugHook' which according the wiki description "should only be used when debugging scripts as it may degrade script performance" thus it is far from optimal. For most of my usecases I needed to prevent certain weapons from being given whenever a certain condition is met, e.g. when a player is inside a collision shape, etc. I know that for certain bespoke servers it isn't needed but I would like to keep my resources decoupled from eachother (especially freeroam) and I think this event will help with that.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions