Simple changing of string size
#1

Hey guys!
I am currently optimizing my gamemode as I recently read some topics about using 256 as string length is a bad idea, so I am stuck here with a problem.

I use Dini to save and read data from files, and we all know that Dini has that annoying problem with string sizes but I am too lazy to change all 100+ saves/loads in my gm.

One of the things I am loading are reports from my own system. I use enum and arrays to store data about reports and everything works fine, but I don't want my rPoster (name of the player who posted the report) to be 256 length array, because I have a limit of 20k reports and that's why my .amx is over 70Mb big..

One of the ideas I got is to change the MAX_STRING value, but I also use it for different purposes in my whole script and I'm afraid it would cause too much trouble.
Next thing that came to my mind is to smaller the string to the length of the destination array. But, it would be much complicated to do it with, as I already said, over 100+ occurrences. So I have an idea of making my own string smaller function or stock.

Here's what I currently use and it throws errors:
Код:
ReportInfo[reportid][rPoster]  = dini_Get(file, "rPoster");
And here is what I taught might help:
Код:
ReportInfo[reportid][rPoster]  = setlen(dini_Get(file, "rPoster"), 24);
Now, after about 2 hours of googling for such function, I was disappointed and I started to work on my own:
Код:
setlen(str[], len)
{
	new output[len];
	format(output, len, "%s", str);
	return output;
}
This looks very simple, but unfortunately, doesn't work. It throws me errors something like the value should be constant etc.

Could someone please help me and just write that little snippet that would do the job and change the string size?

Thanks very much!
Reply


Messages In This Thread
Simple changing of string size - by leongrdic - 12.02.2014, 17:59
Re: Simple changing of string size - by Golimad - 12.02.2014, 19:34
Re: Simple changing of string size - by Vince - 12.02.2014, 19:42
Re: Simple changing of string size - by leongrdic - 12.02.2014, 20:26
Re: Simple changing of string size - by CuervO - 12.02.2014, 20:40
Re: Simple changing of string size - by leongrdic - 13.02.2014, 08:46

Forum Jump:


Users browsing this thread: 1 Guest(s)