PDA

View Full Version : MySQL load data [R39-6]


FinStar
15/03/2018, 01:00 PM
CMD:team(playerid, params[])
{
if(Player[playerid][Faction] != 0)
{
new query[300];
mysql_format(Database, query, sizeof(query), "SELECT * FROM character WHERE faction='%d'", Player[playerid][Faction]);
mysql_query(Database, query);

new rows, fields, str[300], info[4000+1];
cache_get_data(rows, fields, Database);

printf("[ FIELDS: %d | ROWS: %d ]", fields, rows);

for(new c = 0; c < rows; c++)
{
new pjm[24], hodnostp[100];
cache_get_field_content(c, "name", pjm, Database, 24);
cache_get_field_content(c, "rank_name", hodnostp, Database, 100);

printf("[ ROW: %d | NAME: %s | RANK_NAME: %s ]", c, pjm, hodnostp);

new online = 0;
for(new i = 0; i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(!strcmp(GetName(i), pjm, true))
{
if(Player[i][Faction] == Player[playerid][Faction])
{
online = 1;
}
}
}
}
if(GetCharacterKill(pjm) == 0)
{
if(online) format(str, sizeof(str), "{FFFFFF}%s\t%s\t{00FF88}ONLINE{FFFFFF}\n", pjm, hodnostp);
else format(str, sizeof(str), "{FFFFFF}%s\t%s\t{FF0000}OFFLINE{FFFFFF}\n", pjm, hodnostp);
strcat(info, str);
}
}
new strex[4000+1]; format(strex, sizeof(strex), "Name\tRank Name\tStatus\n%s", info);

if(Player[playerid][Rank] >= 9)
{
ShowPlayerDialog(playerid, DIALOG_TEAM, DIALOG_STYLE_TABLIST_HEADERS, "Team", strex, "Edit", "Close");
}
else
{
ShowPlayerDialog(playerid, DIALOG_NORESPONSE, DIALOG_STYLE_TABLIST_HEADERS, "Team", strex, "Close", "");
}
} else return Error(playerid);
return 1;
}

IN SERVER LOG:
[ FIELDS: 100 | ROWS: 2 ]
[ ROW: 0 | NAME: Mia_Criy | RANK_NAME: - ]
[ ROW: 1 | NAME: NULL | RANK_NAME: NULL ]

IN DATABASE:
Name of ROW 0: Mia_Criy
Name of ROW 1: Steel_Crew

FinStar
15/03/2018, 04:07 PM
SOLVED