Replace Thing[MAX_PLAYERS][10]; wtih PVars - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Replace Thing[MAX_PLAYERS][10]; wtih PVars (
/showthread.php?tid=164162)
Replace Thing[MAX_PLAYERS][10]; wtih PVars -
ikey07 - 30.07.2010
So how to use PVars if I need to set each player something with 10 subthings,
Now I have for example:
pawn Код:
new Thing[MAX_PLAYERS][10];
OnSomeWhere()
{
Thing[playerid][0] = 23;
Thing[playerid][1] = 34;
}
and how should I make this with PVars?
Re: Replace Thing[MAX_PLAYERS][10]; wtih PVars -
kurta999 - 30.07.2010
Use this:
SetPVarInt(playerid, "Thing1", 23);
SetPVarInt(playerid, "Thing2", 34);
Re: Replace Thing[MAX_PLAYERS][10]; wtih PVars -
ikey07 - 30.07.2010
Hmm.. this is only way?
because than script getting full very fast, because can't use for(new .....
Thing[playerid][i] = 0; etc
Re: Replace Thing[MAX_PLAYERS][10]; wtih PVars -
Jeffry - 30.07.2010
So, why don't you want to use the variables? I always work with them, its easier to script with them, and better for loops.
Re: Replace Thing[MAX_PLAYERS][10]; wtih PVars -
dice7 - 30.07.2010
pawn Код:
for (new i = 0; i < MAX_SOMETHING; i++)
{
new str[20];
format(str, 20, "Thing%d", i);
SetPVarInt(playerid, str, 0);
}
Re: Replace Thing[MAX_PLAYERS][10]; wtih PVars -
ikey07 - 30.07.2010
Well, yeah^^, but I read in Server updates page, that its save a lot of Memory, All Variables set to 0 automaticly after player leaves server, also don't need to spam half of script with new Things many....
EDIT, Thx Dice7, I will try
Re: Replace Thing[MAX_PLAYERS][10]; wtih PVars -
FireCat - 30.07.2010
try to use
SetPVarInt(playerid, "Thing1", 23);
SetPVarInt(playerid, "Thing2", 34);
Re: Replace Thing[MAX_PLAYERS][10]; wtih PVars -
iggy1 - 30.07.2010
Quote:
Originally Posted by dice7
pawn Код:
for (new i = 0; i < MAX_SOMETHING; i++) { new str[20]; format(str, 20, "Thing%d", i); SetPVarInt(playerid, str, 0); }
|
should be
pawn Код:
for (new i = 0; i < MAX_SOMETHING; i++)
{
new str[20];
format(str, 20, "Thing%d", i);
SetPVarInt(i, str, 0);
}

just spotted that
Re: Replace Thing[MAX_PLAYERS][10]; wtih PVars -
Joe_ - 30.07.2010
Only use PVars for things that need to be shared across scripts, if not, why use PVARS?
Functions are SLOWER than varibles, so the pData array would be best.
Re: Replace Thing[MAX_PLAYERS][10]; wtih PVars -
dice7 - 30.07.2010
Quote:
Originally Posted by iggy1
should be
pawn Код:
for (new i = 0; i < MAX_SOMETHING; i++) { new str[20]; format(str, 20, "Thing%d", i); SetPVarInt(i, str, 0); }
 just spotted that
|
No.
That would do the following:
Store zero in 'Thing0' for playerid 0
Store zero in 'Thing1' for playerid 1
Store zero in 'Thing2' for playerid 2
Store zero in 'Thing3' for playerid 3
etc