Exiled-Team / EXILED

A high-level plugin framework for SCP: Secret Laboratory servers. It offers an event system for developers to hook in order to manipulate or change game code, or implement their own functions.
https://www.exiled.to/
Other
274 stars 181 forks source link

[BUG] PickingUpItemEventArgs.IsAllowed doesn't work as expected #886

Closed SebasCapo closed 2 years ago

SebasCapo commented 2 years ago

Describe the bug Setting PickingUpItemEventArgs.IsAllowed to false makes the item unable to be grabbed after your first attempt at doing so. (This also causes weird behaviors when trying the same thing on a custom item)

To Reproduce Steps to reproduce the behavior:

  1. Subscribe a method to the PickingUpItemEventArgs, doesn't need anything else other than ev.IsAllowed being set to false.
  2. Attempt to grab an item.
  3. Try grabbing that exact item again.
  4. Item becomes pseudo-locked.

Expected behavior Be able to attempt to grab this item, this is important to allow custom behavior to happen when player interacts with it, something that is not possible when setting Pickup.Locked to true.

Server logs Not necessary

EXILED Version ("latest" is not a version): 3.7.2

Results of show plugins command in console: Not necessary

Additional context Funnily enough, this works differently on custom items (Mainly due to how the base CustomItem.cs pickup logic was made), instead of locking the item, it just lets you grab it. Ideally this would also be fixed in the same PR, but we can't expect god to do all the work. :')

Misaka-ZeroTwo commented 2 years ago

Why are u setting Pickup.Locked to true if you want people to be able to pick it up? Try Pickup.InUse = false; and Pickup.Locked = false; (should be one of them tho)

SebasCapo commented 2 years ago

Why are u setting Pickup.Locked to true if you want people to be able to pick it up?

That is not at all what I said though, I simply mentioned why it's important to fix this, as it's a feature that used to work pre-Parabellum and setting Pickup.Locked to true wouldn't be achieve the same effect.

Try Pickup.InUse = false; and Pickup.Locked = false; (should be one of them tho)

I will try this and see if it works, though it doesn't fix the issue I'm having. Nice thing about fixing the event is that you can have behavior work differently for specific players when, for example, certain conditions are met.

joker-119 commented 2 years ago

Can someone re-verify if this bug still exists please?

SebasCapo commented 2 years ago

Just tested it on 4.1.7, seems to have been fixed, honestly unsure as to why as I don't see anything on the changelog referring to this, must've been base-game? Maybe? Will check again when we rollback to 11.1.0.

Thank you for looking into it regardless. <3