SA-MP Forums Archive
valstr() Bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP (https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: Bug Reports (https://sampforum.blast.hk/forumdisplay.php?fid=20)
+--- Thread: valstr() Bug (/showthread.php?tid=461038)



valstr() Bug - BigETI - 31.08.2013

I've been struggling for days now why my script keeps hanging during runtime, and found out that the native called valstr() was hanging my whole script.
If you actually try to convert large numbers into strings using valstr(), you can hang your script.

pawn Код:
new my_string[11];
print(" Debug 1");
valstr(my_string, 2080374655); // Valid number, hangs
print(" Debug 2");
prints
Код:
 Debug 1
After that the server becomes not enterable, and this appears:
Код:
Incoming connection: <IP>:<port>
Kicking <IP> because they didn't logon to the game.
I had to avoid this issue by using something like
pawn Код:
format(my_string, sizeof my_string, "%d", 2080374655);
which works fine.

Best Regards

~ BigETI



Re: valstr() Bug - Niko_boy - 31.08.2013

thanks for the inforamation though i mostly used format for int to str


Re: valstr() Bug - iZN - 31.08.2013

High values passed to this function can cause the server to freeze for no apparent reason. If this happens, then use format instead.


Re: valstr() Bug - General Abe - 31.08.2013

The highest value it accepts is 1874919423. For this reason I wouldn't use it at all; having to add checks to stop these errors outweighs the penalty of resorting to format.


AW: valstr() Bug - BigETI - 31.08.2013

This is nonsense. It should atleast support all values between -2147483648 and 2147483647.


Re: valstr() Bug - Misiur - 31.08.2013

https://sampforum.blast.hk/showthread.php?pid=1790300#pid1790300

I'm trying some custom functions now, but I doubt they'll be faster.

E: Yup, up to 5x slower.