SmartlyDressedGames / Unturned-3.x-Community

Community portion of the Unturned-3.x repo. If you have access to the source code you can find it here:
https://github.com/SmartlyDressedGames/Unturned-3.x/
84 stars 18 forks source link

Crafting mysteriously showing the wrong number of items #3844

Open hannes213 opened 1 year ago

hannes213 commented 1 year ago

I was in the Russia map when I wanted to craft a pump jack. Not noticing that I didn't have all the required materials in my inventory, but rather in crates beside me, I tried to craft it (the crafting place showed that I could craft it. Like the amount of things I actually had in my inventory were showed as doubled there), but when I looked into my inventory and crates and on the ground I couldn't find it anywhere and half of the materials I needed to craft it were completely gone (the metal sheets and bars). The same thing happened when i tried to craft the industrial gas can right after to test and then my gas cans were gone.

SDGNelson commented 1 year ago

I tried recreating this in both singleplayer and multiplayer by placing a crate and putting a portion or all of the crafting materials inside the crate, but the crafting list correctly showed the item as non-craftable. Are you able to reproduce the bug?

hannes213 commented 1 year ago

It seems to me that all the time when I have stuff in my inventory like 1 flashlight and i go to crafting to scrap it it first shows that I have got 2 flashlights and it is like that with everything

hannes213 commented 1 year ago

But it goes to normal after I no longer have any of that material in my inventory

hannes213 commented 1 year ago

image Like in that image it shows that i have 2/2 chemicals, but i only have 1 in my inventory. And like that It would allow me to "craft" the item even though i dont actually have enough materials

SDGNelson commented 1 year ago

Is the second chemical in a crate? I'll see if I can reproduce it.

SDGNelson commented 1 year ago

I tested what I think is your example - one chemicals in inventory and one either nearby or in storage - and the Horde Beacon crafting entry only showed one chemicals available. Does that sound correct or was something different in your case?

hannes213 commented 1 year ago

No I didnt even have it in a storage container I only had 1 chemical in my inv and one on the ground far away from me, so that it wouldnt affect me. It seems to be like that with most things that I try to craft.

SDGNelson commented 1 year ago

I just tried reproducing by chemicals on the ground nearby, but it still only counted the one in my inventory. Closing this for the meantime sorry because I can't reproduce it, but if you run into it again and have some steps for how I can reproduce the bug please feel free to comment and I will re-open.

Dyna1One commented 1 year ago

Having this same exact issue and found a lot of very old posts about it, I've been running into this issue as well on my server (Russia map) I've tried recreating it in singleplayer but haven't found success yet. Been trying to find the cause for hours now and it got me scratching my head, are you using any mods Hannes213?

https://github.com/SmartlyDressedGames/Unturned-3.x-Community/assets/134254563/35a359e9-85d1-4460-a9c1-032fa5cbe555

https://github.com/SmartlyDressedGames/Unturned-3.x-Community/assets/134254563/5e4c35f9-a3e1-4c41-826f-33c93ad43d3e

Dyna1One commented 1 year ago

image This is the error message that pops up on my server,

SDGNelson commented 1 year ago

That is very interesting and weird that it's showing the wrong number of items! Thanks for the videos and error. I'll read through the related code and see if anything comes to mind.

Dyna1One commented 1 year ago

Sure thing! Let me know if I can provide anything, I could also test it on a different client from my laptop to see if it happens for other players, I'm not sure if it's a character related issue, server or map (Though it's interesting that we're both on Russia)

SDGNelson commented 1 year ago

So bizarre, I even tried re-creating the same loadout as yours in multiplayer on Russia: image but it showed 1/1 Bulldog rather than 2/1

The inventory/crafting code is pretty old and bad so it's certainly possible there's something going wrong. Maybe a good incentive to make rewriting it higher priority. Just in case though: do you have any plugins on that server, or is it only vanilla?

Dyna1One commented 1 year ago

So I've been using the following workshop mods:

No other mods or plugins (there's some weird plugin selling websites or lack of documentation/descriptions which I'm really not about haha

I've ran a server for a few days on Arid (pure vanilla otherwise, no mods/plugins) which had the same issue after a while of playing.. Also would like to add that I've been running the game with these mods when I tested it in singleplayer myself, with the same items in my inventory and it was working just fine which is... Bizarre haha

hannes213 commented 1 year ago

I think I should specify that I was playing vanilla singleplayer so I don't think it's due to any plugins or mods ect.

hannes213 commented 1 year ago

But I dont know, maybe it is due to them and I have something different.

Dyna1One commented 1 year ago

Yeah it's a strange one, I was kind of hoping it was just a mod issue but it seems to be happening on vanilla for some people as well (most posts I've found are a lot older however)

SDGNelson commented 1 year ago

In the meantime I'll put a potential fix for the server exception, and hopefully the underlying cause comes to light. :confused:

GazziFX commented 1 year ago

I think some of your items has amount not equal to 1, I had crafting issues with stacked items and patched them with plugin

Alniroza commented 6 months ago

I got the same now, but got no real information to how to replicat, it just "happened". The only strange thing i do is change Config.json, so i can set up my server properly. I dont see nothing there that will let me think why this error could happen.

I have a Almost vanilla Arid server, with just some plugins and a kill feed mod.

Any insights how to fix it??

Thanks!!

Alniroza commented 6 months ago

I will give some insights that maybe could be useful:

First, in Arid, i first noticed that gummed tape sometimes counted as 2 on all recipes related to gummed tape. image

Also, i can see that there only some Gummad Tapes that count as 2, not every one, its like a property of the item itself. I tested this droping and picking up GT. I had 3, and seeing 4 on crafting. 2 Of them counted as one on the crafting recipe, but one in specific was bugged, and counted as 2.

Also, when i trade with merchants, some items that i sell count as 2, this is really strange. For example, i had a Motor, and the trader let me sell that motor twice, and i got the EXP for both of the trades. This also happens with some other items, but i dont know if with everyone.

In the next example, i had 5 wrenches that counted as 9, and 1 photo, that counted as 2. image

This only let me guess that the double count is bound to the object in some way or another. The only property i changed that could been related is this: "Resource_Drops_Multiplier": 1.0. I once changed it to 1.5, so maybe that affected in someway, and bounded some items to count as twice?? Anyway, even when i set this back to 1.0 the problem persisted.

I hope that this help you with something.

EDIT: I tested a bit more, and didnt matter if the drop waas from a zombie or from the floor, some objects counted as 2. This happened on Weapons and resources at least.

EDIT 2: Looks like that items obtained via crafting dont get bugged. Like staked objets or salvaged items dont count as 2 on crafting recipes. Tried like 10 times salvaging and crafting items, and got no dupped ones. Only the objects i pick up count as 1 or 2. Items like Dogtags always counted as 2, dont know why, but i picked 8, and all 8 counted as 2, with other items only some. Also, trading with NPCs i think the objects that can be sold always count as 2.

Alniroza commented 6 months ago

Aditional info: I have trying changing a lot of thing on the server, and the bugged persisted. Also explored the .dat files of the objects on arid, everything seem normal.

Also, i tried reinstaling and nothing changed. This could mean the problem is how items are saved on inventory??

Lastly, my server console show no errors.

SDGNelson commented 6 months ago

@Alniroza from your description it sounds like the item has an amount/quantity other than 1, but the client is only showing 1. I don't think it's caused by any of your config. Maybe a server-to-client item syncing bug. I'll make a note to double-check that the client should show the amount label if not 1 🤔

Alniroza commented 6 months ago

I would really like to help with this, dont know if you could need any particular information. Or even, you can enter my server to test it yourself, is currently on the server list as "LATAM | DESIERTO DE ATACAMA ... ". I know this aint happening only to myself, but i dont know if the players are as aware as me, i would have to ask.

Its becoming quite anoying and i really dont want to have to restart the whole server even to test if it got fixed.

If not, there is anything i can try myself to fix it or to give more insights??

Alniroza commented 6 months ago

Hi, just wanting to give some more insights after weeks playing on my bugged server.

  1. Definitely all players are being affected by this bug.
  2. I tested if remaking the server will fix it. So, i did a clean Arid server and it did worked perfect, no bugs. Then, i copied all "Levels" and "Players" information to the same clean Arid, from my previous Arid server with the bugs. And the bug cameback instantly.
  3. Almost all items are affected by it, with no real way to know if it will count as 1 or 2 items. Some items like dogtags i think they always counted as 2, but for other items, hard to know.
  4. Item obtained from Scraping or crafting always count as the correct quantity (Maybe because crafting always give a correct quantity)
  5. Crafting recipe cant work properly if you don have the corrent amount asked on the recipe, but, looks like quest and trades works the opossite way. For Example, if in crafting recipe appears as having 5 items (with only 3), any quest or trade that require 2 of those items, will let you accept/complete the quest twice (if its repeatable) or trade twice as if you indeed had 5 of those items.
Alniroza commented 5 months ago

Looks like the problem was Quality_Multiplier. I had it on 1.2, and when i switched back to 1.0 or less, it got fixed.

Previous items kept being bugged, but not new picked up ones.