29.06.2009, 12:37
Well i've been thinking that an array which does not posses enum as a its size can be done very nicely with a loop by doing (for example for palyer stat)
pInfo[playerid][i] = /*get a value which has an index and is a part of a string, using strtok function f.e.*/
now the question is can I still process an array (multi or single dimensional) which had enum using values to represent parts of it? example:
i cut this part from moderntopia script and removed what wasn't needed. I want to know whether the while could be done this way. and if it cannot is there any other way without enum to define values of an array?
pInfo[playerid][i] = /*get a value which has an index and is a part of a string, using strtok function f.e.*/
now the question is can I still process an array (multi or single dimensional) which had enum using values to represent parts of it? example:
pawn Код:
// in code where I need it
#define MAX_STATS 3
enum stats
{
Name,
Password,
Money
}
new pInfo[MAX_PLAYERS][stats];
for(new i = 0; i < MAX_STATS; i++)
{
// this code was taken from moderntopia script
new Data[1024];
new Field[64];
new rcnt = 1;
MySQLFetchAcctRecord(PlayerInfo[playerid][pSQLID], Data);
samp_mysql_strtok(Field, "|", Data);
while (samp_mysql_strtok(Field, "|", "")==1)
{
pInfo[playerid][rcnt] = strval(Field);
rcnt++;
}
samp_mysql_free_result();
}
}