Problem with stock - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Problem with stock (
/showthread.php?tid=392242)
Problem with stock -
Konstantinos - 13.11.2012
Hello everyone,
I haven't made any thread for a while because I did not actually have any problem until today.
I tried to fix it, I had some researches on the ******/samp forum but still nothing.
I made a stock that it reads a value from 0 to 2147483647 and it prints according to the digits. For example, if I type 10000000 (which is 10 millions), it will display that it's '10M'. However, if I define the variables and print them, they got printed, unless I use the 'ConvertMoney( value );', which prints only until 1BN (billion). Even if it is 2 billions, it doesn't get printed for an unknown reason.
pawn Код:
main( )
{
new
a = 1000000000,
b = 2147483647
;
printf( "a = %d, b = %d", a, b );
printf( "a = %s", ConvertMoney( a ) );
printf( "b = %s", ConvertMoney( b ) );
}
The results:
It does not work with over 2 billions and the limit is 2147483647, I can't understand why it doesn't work.
pawn Код:
stock ConvertMoney( value )
{
new
tmp[ 128 ],
val[ 8 ],
val2[ 16 ]
;
if( value >= 0 && value <= 2147483647 )
{
// Converting part
format( tmp, 128, "%s%s", val2, val );
}
else format( tmp, 128, "--" );
return tmp;
}
Re: Problem with stock -
iggy1 - 13.11.2012
You should show your "converting part" because that's where the problem is.
Re: Problem with stock -
Konstantinos - 13.11.2012
Edit: pending..
Re: Problem with stock -
iggy1 - 13.11.2012
Seems like valstr doesn't like numbers that large.
pawn Код:
else if( value >= 1000000000 )
{
format( val, sizeof( val ), "BN" );
valstr( val2, value );//problem line.
if( value >= 1000000000 && value <= 2147483647 ) strdel( val2, 1, 10 );
}
That hangs my server indefinitely when used with the number 2 billion.
EDIT: I thought i remembered correctly, there is a fix in this include by ****** & Co.
https://sampforum.blast.hk/showthread.php?tid=292813
Re: Problem with stock -
Konstantinos - 13.11.2012
Well, I am not able to test it right now, but I will definetely try that include. I show that valstr can crash the server, so I will test it and I'll reply back!
EDIT: I used that include and it works! And I was sure that I didn't do anything incorrect.
Thanks a lot.