Problems creating new array
#1

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:

Quote:

new price[256];

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
Reply
#2

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
Reply
#3

This is the complete function:

Quote:

stock FormatMoneyEx(Float:money)
{
new price[256];
format(price,256,"%.2f",money);
FormatMoney(price);
return price;
}

Reply
#4

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.
Reply
#5

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

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)