Large per player strings -
Incubator - 15.07.2011
I have encountered a situation when I needed a "MAX_PLAYERS" string with a length of about 500 characters.
Normally I'd never even create more than a single per player string but no matter how I do this, in the end I find myself needing such a string. I thought of simply storing the text in files (file for each player) and access the files instead of accessing any variables, but it's really really slow when I will do this multiple times for different players at once.
There's another way I thought of which would be PVars, I don't really get their memory usage, also they seem really comfortable as they don't increase the amx size at all.
Anyway, how should I create a per-player ~500 character string?
Thanks.
Re: Large per player strings -
The.Sandman - 15.07.2011
pVars is the way to go
EDIT:
pawn Код:
//top
#undef MAX_PLAYERS
#define MAX_PLAYERS 500//change 500 to your server slot count
new string[MAX_PLAYERS] = 0;
//code
string[playerid] = 1;
//etc etc
Is that what u mean?
Re: Large per player strings -
Miguel - 15.07.2011
This might be useful:
https://sampwiki.blast.hk/wiki/SetPVarString
Re: Large per player strings -
Kyosaur - 15.07.2011
Quote:
Originally Posted by The.Sandman
pVars is the way to go
|
I completely disagree. Why sacrifice speed for pvars if the variable isnt used by other scripts?
There's nothing wrong with creating that many strings if you have the memory. Though if you dont want to, you could just use ONE global string for each player. PAWN is single threaded, so there will never be a time when two players need the same string. You can simply format the single string with the information for said player before using it.
Re: Large per player strings -
Incubator - 15.07.2011
I'm talking about a better version of:
new string[MAX_PLAYERS][500];
Which is just crazy.
Is there a way to store such things without wasting so much memory? Is PVar the best way?
Re: Large per player strings -
Ricop522 - 15.07.2011
Quote:
Originally Posted by Miguel
|
No, this isn't..
PVar's isn't so useful.. and not recommended
Re: Large per player strings -
Incubator - 15.07.2011
Quote:
Originally Posted by Kyosaur
I completely disagree. Why sacrifice speed for pvars if the variable isnt used by other scripts?
There's nothing wrong with creating that many strings if you have the memory. Though if you dont want to, you could just use ONE global string for each player. PAWN is single threaded, so there will never be a time when two players need the same string. You can simply format the single string with the information for said player before using it.
|
I use these strings globally, and access them randomly during commands and such- each string of mine stores other data of the player.
Re: Large per player strings -
Incubator - 16.07.2011
Still need help please.
Re: Large per player strings -
wups - 16.07.2011
new string[MAX_PLAYERS][500];
According to my calculations, this string will use 1mb of ram
Is it so bad for you?
Re: Large per player strings -
Macluawn - 17.07.2011
Quote:
Originally Posted by Incubator
each string of mine stores other data of the player.
|
You can't really store it in any other way better than variables. Why should you give up speed just because of 2kilobites of memory (amx file)?