Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing a book with the inventory full drops it onto the ground #3176

Open
Zughy opened this issue Jan 12, 2025 · 5 comments
Open

Writing a book with the inventory full drops it onto the ground #3176

Zughy opened this issue Jan 12, 2025 · 5 comments

Comments

@Zughy
Copy link
Contributor

Zughy commented Jan 12, 2025

In my server people can't drop items in the main area (register_allow_player_inventory_action returning 0). However, I'm not sure there is a way I can prevent this from happening (see video below). I think the action should be stopped earlier, somehow. I noticed when a user dropped a lot of empty written books in the area

books.mp4
@sfan5
Copy link
Contributor

sfan5 commented Jan 12, 2025

Realistically I think your only option is to override core.add_item. Dropping from inventory is simply not the only way to create dropped items.

@Zughy
Copy link
Contributor Author

Zughy commented Jan 12, 2025

uhm, is there a way to know what called the function? Like, how can I differentiate between a minigame spawning a book (we don't have that, just saying) and people spamming books in the lobby? I should check both pos (lobby) and item (book) ..?

@NathanSalapat
Copy link
Contributor

How exactly would you handle the book's content. In your example of course it's empty, but if a player had a book with content should it just be destroyed because they didn't have an empty inventory slot?
Also not sure why this issue is MTG, as you have a custom game here, but maybe change the book to only allow writing in it if the player has a slot to put the book in. This way you don't have players loosing their content.
Could you just restrict players getting books in the lobby? In your video it looks like the player has creative, so I'm not sure how a player would normally go about getting enough empty book to make this be a problem.

@Zughy
Copy link
Contributor Author

Zughy commented Jan 12, 2025

not sure why this issue is MTG, as you have a custom game here

The base of our server is MTG and books belong to default, soo.. (see next point)

maybe change the book to only allow writing in it if the player has a slot to put the book in

This is something MTG could do. However, there can also be a case where they initially had a slot and then somehow it got filled whilst they were writing

Could you just restrict players getting books in the lobby?

They get an empty book every time they hit a button. There's creative in the video because I was the one recording (admin), normal users don't have it

@appgurueu
Copy link
Contributor

appgurueu commented Jan 13, 2025

uhm, is there a way to know what called the function?

This is possible using debug.getinfo, but likely not what you want.

Like, how can I differentiate between a minigame spawning a book (we don't have that, just saying) and people spamming books in the lobby?

I would recommend giving your minigames an API, say arena_lib.add_item_raw (just making this up, not sure if it makes sense given your conventions), to spawn dropped items which bypasses whichever checks you plan to add to core.add_item.


As for what MTG can do, you raise an interesting point: By directly calling core.add_item, we deprive modders of the ability to hook and control (or at least report) such "littering"; there is no responsible player anymore (well, you could do hacks such as looking for the nearest player, but eh).

It could make sense to add something like a default.try_give_to(player, item) function which is more hookable, say it uses a hookable default.drop_for(player, item) function internally which could then bail out (though the question of what to do with the book contents in such a case remains).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants