I want to print all members from certain faction. This what I will post works but it prints only one player from database. I think callback CheckOrgPlayers isn't working properly.
PHP Code:
YCMD:members(playerid, params[], help)
{
#pragma unused help
new string[50];
if(PlayerInfo[playerid][pMember] < 1) return SendClientMessage(playerid, COLOR_ERROR, "You are not in faction.");
new teamnumber;
if(PlayerInfo[playerid][pMember] != 0) teamnumber = PlayerInfo[playerid][pMember];
SendClientMessage(playerid, 0x00FF00FF, "List of faction members:");
new DB_Query[250];
mysql_format(Database, DB_Query, sizeof(DB_Query), "SELECT * FROM `PLAYERS` WHERE `Member` = %d LIMIT 1", teamnumber);
mysql_tquery(Database, DB_Query, "CheckOrgPlayers", "ii", playerid, teamnumber);
return 1;
}
PHP Code:
forward public CheckOrgPlayers(playerid, teamnumber);
public CheckOrgPlayers(playerid, teamnumber)
{
if(cache_num_rows() > 0)
{
for(new i; i < cache_num_rows(); i++)
{
new string[50];
new Nick[24], Rank, Status;
cache_get_value(0, "Name", Nick, 24);
cache_get_value_int(0, "Rank", Rank);
cache_get_value_int(0, "LoggedIn", Status);
if(Status == 0)
{
format(string, sizeof(string), " %s (%d) OFFLINE", Nick, Rank);
SendClientMessage(playerid, -1, string);
}
else if(Status == 1)
{
format(string, sizeof (string)," %s (%d) ONLINE", Nick, Rank);
SendClientMessage(playerid, -1, string);
}
}
}
else
{
print("Couldn't find anything.");
}
return 1;
}