Getting all members of club in a dialog problem
#1

Hello, i'm wanting to get all members of a club into a dialog and i got this code:
pawn Код:
Dialog_ClubOwner(playerid, response, listitem)
{
    if(!response) return 1;
    switch(listitem)
    {
        case 0:
        {
            new string[256];
            for(new i = 0; i < MAX_CLUBS; i++)
            {
                if(IsPlayerInRangeOfPoint(playerid, 2.5, AClubData[i][ClubX], AClubData[i][ClubY], AClubData[i][ClubZ]))
                {
                    format(string, sizeof(string), "SELECT Name FROM Users WHERE Club = '%s'", AClubData[i][ClubName]);
                    mysql_function_query(Handle, string, true, "ClubMemberList", "i", playerid);
                }
            }
        }
    }
    return 1;
}
forward ClubMemberList(playerid);
public ClubMemberList(playerid)
{
    new rows, fields, string[1000];
    cache_get_data(rows, fields, Handle);
    for(new i; i < Max_ClubMembers; i++)
    {
        format(string, sizeof(string), "%s%s\n", string, fields);
    }
    ShowPlayerDialog(playerid, DialogClubMembers, DIALOG_STYLE_LIST, "Club members", string, "Ok", "Cancel");
    return 1;
}
But this doesnt give any names. Just weird thingys. Does anyone know how to actually get the names?
Reply
#2

Try..

pawn Код:
forward ClubMemberList(playerid);
public ClubMemberList(playerid)
{
    new name[MAX_PLAYER_NAME+1];
    GetPlayerName(playerid, name, sizeof(name));

    new rows, fields, string[1000];
    cache_get_data(rows, fields, Handle);
    for(new i; i < Max_ClubMembers; i++)
    {
        format(string, sizeof(string), "%s%s\n", name, fields);
    }
    ShowPlayerDialog(playerid, DialogClubMembers, DIALOG_STYLE_LIST, "Club members", string, "Ok", "Cancel");
    return 1;
}
Reply
#3

It should be format(string, sizeof(string), "%s%s\n", string, A name thing here);
But how do i get the names that i have gotted from the query?
Reply
#4

Quote:
Originally Posted by thimo
Посмотреть сообщение
It should be format(string, sizeof(string), "%s%s\n", string, A name thing here);
But how do i get the names that i have gotted from the query?
If you add

pawn Код:
format(string, sizeof(string), "%s%s\n", string, fields);
We will leave strange characters, because it is not specified what you get .. therefore should get the name of the row or players online.
Reply
#5

How do i get the name of the row?
Reply
#6

Okay i got this now:
pawn Код:
forward ClubMemberList(playerid);
public ClubMemberList(playerid)
{
    new rows, fields, string[1000], pName[MAX_PLAYER_NAME];
    cache_get_data(rows, fields, Handle);
    for(new i; i < Max_ClubMembers; i++)
    {
        cache_get_row( i, 0, pName, Handle, 32 );
        format(string, sizeof(string), "%s%s\n", string, pName);
    }
    ShowPlayerDialog(playerid, DialogClubMembers, DIALOG_STYLE_LIST, "Club members", string, "Ok", "Cancel");
    return 1;
}
But this shows 100 lines. It does give the right names of people in the club but there are only two members. After that every row shows NULL. How to break the loop when no data is found anymore?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)