SA-MP Forums Archive
Clan system [ MySql ] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Clan system [ MySql ] (/showthread.php?tid=170861)



Clan system [ MySql ] - Cameltoe - 24.08.2010

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];
}



Re: Clan system [ MySql ] - playbox12 - 24.08.2010

And the problem is? what is going wrong?


Re: Clan system [ MySql ] - Cameltoe - 24.08.2010

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..


Re: Clan system [ MySql ] - WackoX - 24.08.2010

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

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


Re: Clan system [ MySql ] - Cameltoe - 24.08.2010

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.


Re: Clan system [ MySql ] - MBX97 - 24.08.2010

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


Re: Clan system [ MySql ] - Cameltoe - 24.08.2010

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`?