SA-MP Forums Archive
[Solved] ResetPlayerInfo + Loop - 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: [Solved] ResetPlayerInfo + Loop (/showthread.php?tid=144119)



[Solved] ResetPlayerInfo + Loop - Miguel - 25.04.2010

In the past I used to reset the player data by this way:
pawn Код:
ResetPlayerData(playerid)
{
  Var[playerid][ID] = 0;
  Var[playerid][Name] = EOS;
}
But it takes too long to add because there are a lot of cells for "Var". Then I thought, what if I use a loop? so I tried this:
pawn Код:
ResetPlayerData(playerid)
{
  for(new i = 0; i < MAX_P_VAR; i ++)
  {
    switch(i)
    {
      case 1..8: Var[playerid][i] = EOS; // this line error
      case 9, 15, 20: Var[playerid][i] = -1; // if I added this it would show another error
    }  
  }
}
But it returns an error.
Код:
mygm.pwn(168) : warning 213: tag mismatch
Is there a way to do what I want?


Re: ResetPlayerInfo + Loop - smeti - 25.04.2010

Quote:
Originally Posted by SAWC™
pawn Код:
ResetPlayerData(playerid)
{
  for(new i = 0; i < MAX_P_VAR; i ++)
  {
    switch(i)
    {
      case: 1..8: Var[playerid][i] = EOS; // this line error
      case: 9, 15, 20: Var[playerid][i] = -1; // if I added this it would show another error
    }  
  }
}

case: 1..8: wrong
pawn Код:
case 1..8:



Re: ResetPlayerInfo + Loop - Miguel - 25.04.2010

Quote:
Originally Posted by Phento
Quote:
Originally Posted by SAWC™
pawn Код:
ResetPlayerData(playerid)
{
  for(new i = 0; i < MAX_P_VAR; i ++)
  {
    switch(i)
    {
      case: 1..8: Var[playerid][i] = EOS; // this line error
      case: 9, 15, 20: Var[playerid][i] = -1; // if I added this it would show another error
    }  
  }
}

case: 1..8: wrong
pawn Код:
case 1..8:
My bad, but that's not the error.


Re: ResetPlayerInfo + Loop - woot - 25.04.2010

Try;
pawn Код:
case 1..8: strcpy(Var[playerid][i], EOS);
strcpy if you don't have it (******);
pawn Код:
stock strcpy(dest[], src[])
{
    new i = 0;
    while ((dest[i] = src[i])) i++;
}



Re: ResetPlayerInfo + Loop - Miguel - 25.04.2010

It doesn't work, still returning the same error...

pawn Код:
enum pinfo{id, name, pass}
pawn Код:
new Var[MAX_PLAYERS][pinfo];
pawn Код:
ResetPlayerData(playerid)
{
  for(new i = 0; i < 3; i ++) // 0 == id, 1 == name, 2 == pass
  {
    switch(i)
    {
      case 0: Var[playerid][i] = -1;
      case 1, 2: Var[playerid][i] = EOS;
    }
  }
}
That's why I'm trying to do...


Re: ResetPlayerInfo + Loop - smeti - 25.04.2010

Not tested.

Try it so:
pawn Код:
enum pinfo
{
    id,
    name[MAX_PLAYER_NAME],
    pass[32]
};

new Var[MAX_PLAYERS][pinfo];

stock ResetPlayerData(playerid)
{
    for(new i = 0; pinfo:i < pinfo; i++)
    {
        switch(i)
        {
          case 0: Var[playerid][pinfo:i] = -1; // Decimal -- enum pinfo id
          case 1..2: Var[playerid][pinfo:i] = EOS; // string -- enum pinfo name, pass,
        }
    }
}



Re: ResetPlayerInfo + Loop - Miguel - 25.04.2010

Quote:
Originally Posted by Phento
Not tested.

Try it so:
pawn Код:
enum pinfo
{
    id,
    name[MAX_PLAYER_NAME],
    pass[32]
};

new Var[MAX_PLAYERS][pinfo];

stock ResetPlayerData(playerid)
{
    for(new i = 0; pinfo:i < pinfo; i++)
    {
        switch(i)
        {
          case 0: Var[playerid][pinfo:i] = -1; // Decimal -- enum pinfo id
          case 1..2: Var[playerid][pinfo:i] = EOS; // string -- enum pinfo name, pass,
        }
    }
}
Amazing!

Thank you so much!