Having Problem with Array
#1

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

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

Nope, sorry
Reply
#4

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

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?
Reply
#6

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)