Clan system [ MySql ]
#1

Hello i'm trying to make a simple clan system.

Heres the function:

pawn Код:
public LoadClanMembers(clanid)
{
    printf("%d.",clanid);
    new string[128];
    format(string, sizeof(string), "SELECT * FROM clanmembers WHERE clanid='%d'", clanid);
    mysql_query(string);
    mysql_store_result();
    if(!mysql_num_rows())
    {
        printf("None found");
        mysql_free_result();
    }
    else
    {
        new row[100];
        new field[5][50];
        mysql_fetch_row(row, "|");
        explode(field, row, "|");
        // Fetching
    }
}
Here's the Clan enum's:

pawn Код:
// Group [ Clan ]
enum gInfo
{
    gId,
    gTag[50],
    gPos,
    gSlots,
    gBoss[1],
    gUnderBoss[2],
    gMember[MAX_CLAN_MEMBERS],
}
I need something like this(Obviously don't work..) :

pawn Код:
format(string, sizeof(string), "SELECT username FROM clanmembers WHERE clanid='%d'", clanid);
new Array[MAX_CLAN_MEMBERS] = mysql_query_array(string);

for(new i; i < MAX_CLAN_MEMBERS; i++)
{
     gMember[i] = Array[i];
}
Reply
#2

And the problem is? what is going wrong?
Reply
#3

I need a way to fetch it as a array;

pawn Код:
format(string, sizeof(string), "SELECT username FROM clanmembers WHERE clanid='%d'", clanid);
new Array[MAX_CLAN_MEMBERS] = mysql_query_array(string);

for(new i; i < MAX_CLAN_MEMBERS; i++)
{
     gMember[i] = Array[i];
}
Something like that..
Reply
#4

Replace ''// Fetching'' with something like:

Код:
gId = strval(field[0]);
format(gTag, 50 "%s", field[1]);
gPos = strval(field[2]);
gSlots = strval(field[3]);
Etc..
Reply
#5

Quote:
Originally Posted by WackoX
Посмотреть сообщение
Replace ''// Fetching'' with something like:

Код:
gId = strval(field[0]);
format(gTag, 50 "%s", field[1]);
gPos = strval(field[2]);
gSlots = strval(field[3]);
Etc..
Yeah, but then i would need to do that for all MAX_CLAN_MEMBERS.. that would be really inefficient.
Reply
#6

Cool i'll try to use it for my GM (new 1 ) ok thanks for every thing
Bye
Reply
#7

Quote:
Originally Posted by MBX97
Посмотреть сообщение
Cool i'll try to use it for my GM (new 1 ) ok thanks for every thing
Bye
Hehe.. Enjoy (Y)

Anyway, anyone know how this could be done`?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)