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
EquipmentEditor: Set clip on buy #1499
Conversation
Co-authored-by: Histalek <16392835+Histalek@users.noreply.github.com>
Im opposed to the networking part, can you quickly explain why that is necessary? |
It is needed to update the clip variable on the client as well. This was the easiest solution I could find at least. As @ZenBre4ker said the saved keys are networked, but I have to set |
@saibotk Just to ping you as you did not answer to my comment |
But why does the client need this? What happens if you dont do that? Seems like something that gmod should/would handle. |
The Playerinfo HUD element is bugged and shows the wrong max clip size. GMod does not handle this, GMod sadly has no max clip. This is manually handled by TTT |
Can this be solved via the weapon entity's network variables? Like we do with the sprint system? |
Not sure, hm. It is not something that is updated on the fly though. Maybe I can use the synced data from @ZenBre4ker's settings stuff, but I did not investigate this and he did not yet answer |
So, Im wondering why this is something TTT2 should implement? Otherwise while cliponBuy is synchronized it is just a static setting. |
Yes. But there are multiple weapons that want to have a configurable clip size. Using the I therefore added the
As I said in a previous comment that does not work. If you do not set the MaxClip on the client manually, it ends up showing stuff like "4 / 1" (four out of one) left, which I consider a bug. I'm not sure if I actually answered your question though as I already wrote the same in the description and the previous comments. So you might have to clarify your question a bit more Edit: I think I got your second part. I'm not sure how to use it though. Is there a hook or a callback when the data arrived on the client? I don't want to poll it in a think hook for example |
There should be something in the database you can hook to. |
All I could find is this: https://github.com/TTT-2/TTT2/blob/master/lua/ttt2/libraries/database.lua#L291 But as far as I can see this is only called in the realm where it is stored (the server in this case) and it is also not called when the weapon is initialized and the value from the database is only read, not changed |
Mhh, normally it should be synced. Same way we do it for "database"-element in the ui. |
I've never worked with your synced database stuff. So if you think there is a better solution to my custom syncing, I'd really appreciate pointers that show me what to do because I'm not that motivated to start working through all the database and syncing stuff you did, that was quite a lot. Thanks! |
I Thought about this here, should work the same for your case: TTT2/lua/ttt2/libraries/items.lua Lines 87 to 101 in 297be1b
|
Thank you, I will check it out! |
I simplified the syncing a lot by using the syncing that sven already implemented |
Co-authored-by: ZenBre4ker <72046466+ZenBre4ker@users.noreply.github.com>
Before merging I will probably rename the variable. I also have to test if the UI is working as intended, I think I forgot to set the MaxClip. But that is an easy fix. Just so you are aware and don't merge it yet. |
Tested and works. @ZenBre4ker feel free to merge once your comments are resolved. |
Added
SWEP.SetClipOnBuy
andSWEP.ClipOnBuy
to set the weapon's clip on buy via the equipment editor. I did not want to just use the latter variable to set a clip on buy to all weapons as most "one time use weapons" instantly remove the weapon on use which makes this slider pointless. It is therefore something swep makers have to integrate into their weapon, which is pretty simple.I also reordered some elements in the equipment menu because they were out of place. It now looks like this: