mtasa-blue
mtasa-blue copied to clipboard
Unlimit player money serverside
Is your feature request related to a problem? Please describe.
setPlayerMoney
clientside is not capped to an arbitrary value like 99999999
, it lets you use all the values of the long
type, so you could set up to 2147483647
, which is 21 times larger than the capped version.
On bool CStaticFunctionDefinitions::SetPlayerMoney
in Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
there is this line of code:
// Is it above 99999999? Limit it to it
if (lMoney > 99999999)
lMoney = 99999999;
// Is it below -99999999?
else if (lMoney < -99999999)
lMoney = -99999999;
I am unaware of a reason why we should cap the money. You can already pass a value larger than 99999999
on setPlayerMoney
serverside, but it will be capped. Also, you can set numbers larger than 2147483647
which makes the value revert down to -2147483647
.
If I am not incorrect, you can already have more than 100M in cash on singleplayer
The vanilla HUD can show up to 999M, altought if you don't use the instant
argument it will take a few minutes for it to show it, since it keeps adding money up.
(My real money on this picture is
2147483647
)
Describe the solution you'd like
The money value should not be capped serverside. Or, at least, it should be capped to the biggest value the vanilla HUD can show, which is 999'999.999
and not 99'999.999
.
Describe alternatives you've considered
Cap the value clientside and make it consistent.
Additional context
This can help server-owners that don't use a custom money system and are approaching the 99M value on some of their users accounts.
This is an easy fix and it should not break anything. I do not understand a reason why this is capped, maybe they were trying to save some bandwidth? I don't understand how that would work since the value it's still long
and does not seem to be changed.
If someone knows a problem that could be generated by this, please, let me know.
Security Policy
- [X] I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
If someone knows of a reason why it was done this way please let me know, otherwise I will upload a pr soon.
Or, at least, it should be capped to the biggest value the vanilla HUD can show, which is 999'999.999 and not 99'999.999.
That is a bad idea. What if someone want to modify default hud (SetPlayerHudComponentVisible + dxDraw functions)?
I'd suggest remove limit on the capped money and just leave it as it is (ofc if you pass value larger than 2147483647 then it will cap to the long max number)
That is a bad idea. What if someone want to modify default hud (SetPlayerHudComponentVisible + dxDraw functions)?
If the information stated in this issue is correct, someone implementing their own HUD already had to deal with the inconsistency of the clientside setPlayerMoney
function not being limited, so the higher money values always were a possibility. Of course, it may happen that a HUD only took into account the serverside version of the function, but in that scenario I don't expect the breakage to be significant. Realistically, how many players in a server have so much money? Is drawing an unexpectedly slightly longer money string worth that much bending over backwards, given that you could easily tweak the UI or limit the amount of money players can have yourself with resources?
Edit: I think I missed the point of the comment above a bit, but anyway I don't see custom HUDs as a reason to cap or not cap things.
Or, at least, it should be capped to the biggest value the vanilla HUD can show, which is 999'999.999 and not 99'999.999.
That is a bad idea. What if someone want to modify default hud (SetPlayerHudComponentVisible + dxDraw functions)?
We already have this issue, don't we? Or maybe you are talking about how while having always an 8 number string is consistent and it will become inconsistent the moment we allow a 9 number string? Then the solution would be to not change it. But you suggest to unlimit it anyway so... I don't get the point, could you explain it in another way?
Or, at least, it should be capped to the biggest value the vanilla HUD can show, which is 999'999.999 and not 99'999.999.
That is a bad idea. What if someone want to modify default hud (SetPlayerHudComponentVisible + dxDraw functions)?
We already have this issue, don't we? Or maybe you are talking about how while having always an 8 number string is consistent and it will become inconsistent the moment we allow a 9 number string? Then the solution would be to not change it. But you suggest to unlimit it anyway so... I don't get the point, could you explain it in another way?
I think missed the point of the issue. Nvm my messages then