SendClientMessage(playerid, -1, "dialogid 2 debug asd1");
new row[128]; // The length of 1 'row' total.
SendClientMessage(playerid, -1, "dialogid 2 debug asd2");
new field[54][128]; // [4] = Amount of fields, [24] = Max length of the bigest field.
SendClientMessage(playerid, -1, "dialogid 2 debug asd3");
mysql_fetch_row_format(row, "|");
SendClientMessage(playerid, -1, "dialogid 2 debug asd4");
explode(row, field, "|");
SendClientMessage(playerid, -1, "dialogid 2 debug asd5");
mysql_free_result();
SendClientMessage(playerid, -1, "dialogid 2 debug 3");
// The field starts here with 1, because the field 'Name' = 0, and we already have the name in a variable.
format(UserStats[playerid][pPassword], 32, "%s", field[2]);
UserStats[playerid][pMoney] = strval(field[3]);
UserStats[playerid][pWarns] = strval(field[4]);
UserStats[playerid][pSkin] = strval(field[5]);
UserStats[playerid][pIP] = floatstr(field[6]);
UserStats[playerid][pGender] = strval(field[7]);
UserStats[playerid][pAge] = strval(field[8]);
UserStats[playerid][pAdmin] = strval(field[9]);
UserStats[playerid][pBanned] = strval(field[10]);
format(UserStats[playerid][pBanReason], 128, "%s", field[11]);
format(UserStats[playerid][pBannedBy], 24, "%s", field[12]);
UserStats[playerid][pX] = floatstr(field[13]);
UserStats[playerid][pY] = floatstr(field[14]);
UserStats[playerid][pZ] = floatstr(field[15]);
UserStats[playerid][pInt] = strval(field[16]);
UserStats[playerid][pVW] = strval(field[17]);
UserStats[playerid][pOwner] = strval(field[19]);
UserStats[playerid][pLevel] = strval(field[20]);
UserStats[playerid][pMinutes] = strval(field[21]);
UserStats[playerid][pHours] = strval(field[22]);
UserStats[playerid][pBank] = strval(field[23]);
UserStats[playerid][pOldAdmin] = strval(field[24]);
UserStats[playerid][pFac] = strval(field[25]);
UserStats[playerid][pFacRank] = strval(field[26]);
UserStats[playerid][pFacLeader] = strval(field[27]);
UserStats[playerid][pWeapon][0] = strval(field[28]);
UserStats[playerid][pWeapon][1] = strval(field[29]);
UserStats[playerid][pWeapon][2] = strval(field[30]);
UserStats[playerid][pWeapon][3] = strval(field[31]);
UserStats[playerid][pWeapon][4] = strval(field[32]);
UserStats[playerid][pWeapon][5] = strval(field[33]);
UserStats[playerid][pWeapon][6] = strval(field[34]);
UserStats[playerid][pWeapon][7] = strval(field[35]);
UserStats[playerid][pWeapon][8] = strval(field[36]);
UserStats[playerid][pWeapon][9] = strval(field[37]);
UserStats[playerid][pWeapon][10] = strval(field[38]);
UserStats[playerid][pWeapon][11] = strval(field[39]);
UserStats[playerid][pWeapon][12] = strval(field[40]);
UserStats[playerid][pWeaponAmmo][0] = strval(field[41]);
UserStats[playerid][pWeaponAmmo][1] = strval(field[42]);
UserStats[playerid][pWeaponAmmo][2] = strval(field[43]);
UserStats[playerid][pWeaponAmmo][3] = strval(field[44]);
UserStats[playerid][pWeaponAmmo][4] = strval(field[45]);
UserStats[playerid][pWeaponAmmo][5] = strval(field[46]);
UserStats[playerid][pWeaponAmmo][6] = strval(field[47]);
UserStats[playerid][pWeaponAmmo][7] = strval(field[48]);
UserStats[playerid][pWeaponAmmo][8] = strval(field[49]);
UserStats[playerid][pWeaponAmmo][9] = strval(field[50]);
UserStats[playerid][pWeaponAmmo][10] = strval(field[51]);
UserStats[playerid][pWeaponAmmo][11] = strval(field[52]);
UserStats[playerid][pWeaponAmmo][12] = strval(field[53]);
a) Do you receive any warnings upon compiling the script?
b) Show us your "explode" function. |
Header size: 25716 bytes Code size: 2269044 bytes Data size: 3626860 bytes Stack/heap size: 16384 bytes; estimated max. usage: unknown, due to recursion Total requirements: 5938004 bytes
explode(const sSource[], aExplode[][], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[]) // Created by Westie
{
new
iNode,
iPointer,
iPrevious = -1,
iDelimiter = strlen(sDelimiter);
while(iNode < iVertices)
{
iPointer = strfind(sSource, sDelimiter, false, iPointer);
if(iPointer == -1)
{
strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
break;
}
else
{
strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
}
iPrevious = (iPointer += iDelimiter);
++iNode;
}
return iPrevious;
}
#pragma dynamic 262144
Now he just needs to tell us how he gets 54 fields (the biggest 128 cells long) in one row with 128 character
|
while (mysql_retrieve_row())
{
// ...
}
Yeah, I've just noticed that! Anyways OP, I would use a while loop for that purpose.
pawn Код:
|
new
string[128];
format(string, sizeof(string), "SELECT * FROM `accounts` WHERE `username` = '%s'", ReturnName(playerid));
mysql_query(string);
mysql_store_result();
while (mysql_retrieve_row())
{
mysql_fetch_field_row(string, "Money");
UserStats[playerid][pMoney] = strval(string);
// ...
}
mysql_free_result();
while (mysql_retrieve_row())
{
mysql_fetch_field_row(string, "pPassword");
format(UserStats[playerid][pPassword], 32, "%s", string);
mysql_fetch_field_row(string, "pMoney");
UserStats[playerid][pMoney] = strval(string);
mysql_fetch_field_row(string, "pWarns");
UserStats[playerid][pWarns] = strval(string);
mysql_fetch_field_row(string, "pSkin");
UserStats[playerid][pSkin] = strval(string);
mysql_fetch_field_row(string, "pIP");
UserStats[playerid][pIP] = strval(string);
mysql_fetch_field_row(string, "pGender");
UserStats[playerid][pGender] = strval(string);
mysql_fetch_field_row(string, "pAge");
UserStats[playerid][pAge] = strval(string);
mysql_fetch_field_row(string, "padmin");
UserStats[playerid][pAdmin] = strval(string);
mysql_fetch_field_row(string, "pBanned");
UserStats[playerid][pBanned] = strval(string);
mysql_fetch_field_row(string, "pBanReason");
format(UserStats[playerid][pBanReason], 128, "%s", string);
mysql_fetch_field_row(string, "pBannedBy");
format(UserStats[playerid][pBannedBy], 32, "%s", string);
mysql_fetch_field_row(string, "pX");
UserStats[playerid][pX] = floatstr(string);
mysql_fetch_field_row(string, "pY");
UserStats[playerid][pY] = floatstr(string);
mysql_fetch_field_row(string, "pZ");
UserStats[playerid][pZ] = floatstr(string);
mysql_fetch_field_row(string, "pInt");
UserStats[playerid][pInt] = strval(string);
mysql_fetch_field_row(string, "pVW");
UserStats[playerid][pVW] = strval(string);
mysql_fetch_field_row(string, "pOwner");
UserStats[playerid][pOwner] = strval(string);
mysql_fetch_field_row(string, "pLevel");
UserStats[playerid][pLevel] = strval(string);
mysql_fetch_field_row(string, "pMinutes");
UserStats[playerid][pMinutes] = strval(string);
mysql_fetch_field_row(string, "pHours");
UserStats[playerid][pHours] = strval(string);
mysql_fetch_field_row(string, "pBank");
UserStats[playerid][pBank] = strval(string);
mysql_fetch_field_row(string, "pOldAdmin");
UserStats[playerid][pOldAdmin] = strval(string);
mysql_fetch_field_row(string, "pFac");
UserStats[playerid][pFac] = strval(string);
mysql_fetch_field_row(string, "pFacRank");
UserStats[playerid][pFacRank] = strval(string);
mysql_fetch_field_row(string, "pFacLeader");
UserStats[playerid][pFacLeader] = strval(string);
for(new i; i < 13; i++)
{
new hi[10];
format(hi, sizeof(hi), "pWeapon%d", i);
mysql_fetch_field_row(string, hi);
UserStats[playerid][pWeapon][i] = strval(string);
mysql_fetch_field_row(string, hi);
UserStats[playerid][pWeaponAmmo][i] = strval(string);
}
}