Problems creating new array - 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: Problems creating new array (
/showthread.php?tid=301587)
Problems creating new array -
backslash - 04.12.2011
Hi, i got this problem while moving from 0.3c to 0.3d.
The server crashes everytime i type certain commands. Debuggin it i found out the problem
is in this line:
This is inside a stock function. I also noticed that if i create the array with a small size (f.e. 32)
the script won't crash. I don't want to change this, because i would need to change the entire
script.
Does anybody know what is going on? Thanks
Re: Problems creating new array -
[MG]Dimi - 04.12.2011
new price[256];
If you tell me that in price variable you just created you have to enter number(price of something), I will be surprised. Anyway variable with 256 cells is way too much for whatever reason you use it. It means you have 256 spaces for characters (means you can type 'a' on 256 places). That's waste of space
Respuesta: Problems creating new array -
backslash - 04.12.2011
This is the complete function:
Quote:
stock FormatMoneyEx(Float:money)
{
new price[256];
format(price,256,"%.2f",money);
FormatMoney(price);
return price;
}
|
Respuesta: Re: Problems creating new array -
backslash - 04.12.2011
In fact i use this function to format prices (put thousands separators and such).
I know 256 is such a waste of memory, but it would be really annoying for me to change
it everywhere. Beside, in 0.3c i don't have this problem... is kind of weird.
Re: Problems creating new array -
[MG]Dimi - 04.12.2011
Erm. That's...erm...Huge waste of space. That money has around 6 characters which means 256-6=250 cells thrown in recycle bin. :-/
pawn Код:
stock FormatMoneyEx(money)
{
new price[10];
format(price,10,"%.2i",money);
FormatMoney(price);
return price;
}
P.S. Use edit button. Double posting isn't allowed