SA-MP Forums Archive
Having Problem with 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Having Problem with Array (/showthread.php?tid=70424)



Having Problem with Array - tom_jonez - 24.03.2009

Command:
Code:
public UnLoadPlayerVariables(playerid)
{
	for(new i = 0; i < sizeof(Players[playerid][pInfo]); i++) //661
	{
	}
	return 1;
}
Array:
Code:
enum pInfo
{
	score,
	bankcash,
	banned,
	adminlevel,
	regularplayer,
	robrank,
	armyaccess,
	id
};
new Players[MAX_PLAYERS][pInfo];
but i get the following errors with it, not sure how to fix them.
Code:
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\debug.pwn(661) : error 001: expected token: "]", but found "-identifier-"
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\debug.pwn(661) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\debug.pwn(661) : error 029: invalid expression, assumed zero
C:\Program Files\Rockstar Games\GTA San Andreas\server\gamemodes\debug.pwn(661) : fatal error 107: too many error messages on one line
Thank you in advance


Re: Having Problem with Array - Byrner - 24.03.2009

pawn Code:
public UnLoadPlayerVariables(playerid)
{
    for(new i = 0; i < sizeof(Players[playerid][pInfo]; i++)) //661
    {
    }
    return 1;
}
Try that.


Re: Having Problem with Array - tom_jonez - 24.03.2009

Nope, sorry


Re: Having Problem with Array - Nero_3D - 24.03.2009

This
pawn Code:
public UnLoadPlayerVariables(playerid)
{
    for(new i = 0; i < sizeof(Players[]); i++) //661
    {
        Players[playerid][pInfo:i] = 0;
    }
    return 1;
}
or
pawn Code:
public UnLoadPlayerVariables(playerid)
{
    for(new i = 0; pInfo:i < pInfo; i++) //661
    {
        Players[playerid][pInfo:i] = 0;
    }
    return 1;
}
Edit: Finished the unload too, so you dont need to ask how it would work


Re: Having Problem with Array - tom_jonez - 24.03.2009

K, that fixed it
so what i wanted to do is set all of the players variables to 0 so theyll be set up for the next player.
so this is what i got:
Code:
public UnLoadPlayerVariables(playerid)
{

	for(new i = 0; pInfo:i < pInfo; i++) //661
	{
	  Players[playerid][pInfo:i] = 0;
	  return 1;
	}
	return 0;
}
Will that work how i want?


Re: Having Problem with Array - Rks25 - 24.03.2009

remove the return 1; in the loop , else it cn block the loop.


Re: Having Problem with Array - tom_jonez - 24.03.2009

Quote:
Originally Posted by Rk_
remove the return 1; in the loop , else it cn block the loop.
:O how embarrassing :P

fixed. thank you.


thank you for the help guys, really appreciate it