/clan -members
#1

I'm working on a clan system and i want to show the clan owner a list with all the members and i tried like this but it won't show me the members,it will show me this message SELECT * FROM `users` WHERE `users`.`Clanid` = 4

case 0:
{
format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `users`.`Clanid` = '%d'", PlayerInfo[playerid][pClanid]);
new Cache: result = mysql_query(mysql, szQuery);
cache_delete(result);
ShowPlayerDialog(playerid, DIALOG_CLANMEMBERS, DIALOG_STYLE_TABLIST_HEADERS, "Clan members:", szQuery, "Select", "Cancel");
}
Reply
#2

You execute query and delete cache. You never retrieve data with cache functions.

R33: https://sampwiki.blast.hk/wiki/MySQL/R3..._field_content
R40: https://sampwiki.blast.hk/wiki/MySQL#cache_get_value_name

If you want only the name of each member, add it in column list for SELECT query. Do not use *
Reply
#3

i 've seen someone do like this

case DIALOG_FACTIONMENU: {
if(!response) return 1;
new
fID = PlayerInfo[playerid][pFaction],
szDialog2[1024] = "Name\tRank\tFW\tStatus\n",
Members, szLocked[256],
szRank[256], szFW[256];

switch(listitem) {
case 0: {
format(szQuery, sizeof(szQuery), "SELECT * FROM `users` WHERE `users`.`Faction` = '%d'", PlayerInfo[playerid][pFaction]); // pFaction
new Cache: result = mysql_query(mysql, szQuery);
for(new i, j = cache_get_row_count (); i != j; ++i)
{
cache_get_field_content(i, "Username", string);
cache_get_field_content(i, "Rank", szRank);
cache_get_field_content(i, "FactionWarns", szFW);
format(DialogSelected[playerid][Members], MAX_PLAYER_NAME, string);
new userID = GetPlayerID(string);
format(szDialog2, sizeof(szDialog2), "%s%s\t%d\t%d\t%s\n", szDialog2, string, strval(szRank), strval(szFW), (userID != INVALID_PLAYER_ID) ? ("online") : ("offline"));
Members++;
}
cache_delete(result);
if(Members == 0) {
if(PlayerInfo[playerid][pLanguage] == 1) return SCM(playerid, COLOR_WHITE, "Factiunea ta nu are membrii.");
else if(PlayerInfo[playerid][pLanguage] == 2) return SCM(playerid, COLOR_WHITE, "Your faction does not have members.");
}
ShowPlayerDialog(playerid, DIALOG_FMEMBERS, DIALOG_STYLE_TABLIST_HEADERS, "Faction Members:", szDialog2, "Select", "Back");
Reply
#4

You should use more tables, one for `gangs` and one for `gang_members`.
You should use threaded queries.
You should use an include that takes care of languages. Modifying many places in case you want to change something on text is not what you would expect.

The example you gave is below:
pawn Code:
case DIALOG_FACTIONMENU:
{
    if (!response) return 1;

    switch (listitem)
    {
        case 0:
        {
            format(szQuery, sizeof(szQuery), "SELECT Username,Rank,FactionWarns FROM users WHERE Faction = %d", PlayerInfo[playerid][pFaction]);
            mysql_tquery(mysql, szQuery, "OnFactionMembersLoad", "d", playerid);
        }
    }
}
pawn Code:
forward OnFactionMembersLoad(playerid);
public OnFactionMembersLoad(playerid)
{
    new rows = cache_get_row_count();

    if (rows)
    {
        new
            member_name[MAX_PLAYER_NAME],
            szDialog2[1024] = "Name\tRank\tFW\tStatus\n";

        for (new i; i < rows; i++)
        {
            cache_get_row(i, 0, member_name);

            format(szDialog2, sizeof(szDialog2), "%s%s\t%d\t%d\t%s\n", szDialog2, member_name, cache_get_row_int(i, 1), cache_get_row_int(i, 2), GetPlayerID(member_name) != INVALID_PLAYER_ID ? ("online") : ("offline"));
        }

        ShowPlayerDialog(playerid, DIALOG_FMEMBERS, DIALOG_STYLE_TABLIST_HEADERS, "Faction Members:", szDialog2, "Select", "Back");
    }
    else
    {
        if (PlayerInfo[playerid][pLanguage] == 1)
        {
            SCM(playerid, COLOR_WHITE, "Factiunea ta nu are membrii.");
        }
        else if (PlayerInfo[playerid][pLanguage] == 2)
        {
            SCM(playerid, COLOR_WHITE, "Your faction does not have members.");
        }
    }
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)