Help...Loading Groups
#21

nothing shows, but it shows loaded Groupid:1
it actually shows

pawn Код:
[System] Loading Groups's....
[16:15:21] Loading Groupid:1
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:2
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:3
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:4
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:5
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:6
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:7
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:8
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:9
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:10
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:11
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:12
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:13
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:14
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:15
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:16
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:17
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:18
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:19
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] Loading Groupid:20
[16:15:21] Groupid:1 Name: Rank0: Rank1: Rank2: Rank3: Rank4: Rank5: Rank6:
[16:15:21] [System] A Total Of 20 Groups Spawned!
if u use Loadgroup(id) still shows blanks
Reply
#22

I know what the problem is.

pawn Код:
strmid(Groups[i][GroupName], data, false, strlen(Groups[i][GroupName]), 255);
strlen? That's 0 right now. So you're allowing for a string length of 0 characters.

pawn Код:
strmid(Groups[i][GroupName], data, false, sizeof(Groups[i][GroupName]), 255);
I don't think that will work however, so you can use...

pawn Код:
strmid(Groups[i][GroupName], data, false, 70, 255);
Reply
#23

im sure strlen returns the string length of something

https://sampwiki.blast.hk/wiki/Strmid

false = the start = 0 then strlen w/e = the end :O i use strlen for all my strmids s:
Reply
#24

Yes, let's get the string length of an undefined string, GREAT IDEA.

Because obviously a string of "" is 0.

string[50] = "This forum is full of dumbasses";

sizeof(string) = 50
strlen(string) = 31
Reply
#25

i dont understand how its undefined, but ok.

by the way, loadgroup2 never works onyl prints loading groups...

and i did

pawn Код:
strmid(Groups[i][GroupName], Gstr[0], false, 70);
            strmid(Groups[i][RankName0], Gstr[1], false, 70);
            strmid(Groups[i][RankName1], Gstr[2], false, 70);
            strmid(Groups[i][RankName2], Gstr[3], false, 70);
            strmid(Groups[i][RankName3], Gstr[4], false, 70);
            strmid(Groups[i][RankName4], Gstr[5], false, 70);
            strmid(Groups[i][RankName5], Gstr[6], false, 70);
            strmid(Groups[i][RankName6], Gstr[7], false, 70);
but yet, didnt work still

im going to debug the vars before they get strmided
Reply
#26

Paste me your code one more time please, exactly what you have, then when I fix it, you are to copy exactly what I put.
Reply
#27

i think its working..

pawn Код:
Gvar0:1,Gstr0:,Gstr1:Probation,Gstr2:To be tested
i guess its just shitty old strmid..
pawn Код:
stock LoadGroups()
{
    printf("[System] Loading Groups's....");
    for (new i=0; i<MAX_GROUPS; i++)
    {
        format(GlobalQuery, sizeof(GlobalQuery), "SELECT * FROM Groups ORDER BY Groupid");
        mysql_query(GlobalQuery);
        mysql_store_result();
        if(mysql_num_rows() > 0)
        {
        new line[1024];
        if(mysql_fetch_row(line))
        {
            new Gstr[9][255],Gvar[1];
            sscanf(line, "p<|>ds[255]s[255]s[255]s[255]s[255]s[255]s[255]s[255]s[255]",Gvar[0],Gstr[0],Gstr[1],Gstr[2],Gstr[3],Gstr[4],Gstr[5],Gstr[6],Gstr[7],Gstr[8]);
            printf("Gvar0:%d,Gstr0:%s,Gstr1:%s,Gstr2:%s",Gvar[0],Gstr[0],Gstr[1],Gstr[2]);
            Groups[i][Groupid] = Gvar[0];
            strmid(Groups[i][GroupName], Gstr[0], false, 70);
            strmid(Groups[i][RankName0], Gstr[1], false, 70);
            strmid(Groups[i][RankName1], Gstr[2], false, 70);
            strmid(Groups[i][RankName2], Gstr[3], false, 70);
            strmid(Groups[i][RankName3], Gstr[4], false, 70);
            strmid(Groups[i][RankName4], Gstr[5], false, 70);
            strmid(Groups[i][RankName5], Gstr[6], false, 70);
            strmid(Groups[i][RankName6], Gstr[7], false, 70);
            strmid(Groups[i][MOTD], Gstr[8], false, 70);
            GroupCount++;
            printf("Loading Groupid:%d",GroupCount);
            printf("Groupid:%d Name:%s Rank0:%s Rank1:%s Rank2:%s Rank3:%s Rank4:%s Rank5:%s Rank6:%s",
            Groups[i][Groupid],Groups[i][GroupName],Groups[i][RankName0],Groups[i][RankName1],Groups[i][RankName2],
            Groups[i][RankName3],Groups[i][RankName4],Groups[i][RankName5],Groups[i][RankName6],Groups[i][MOTD]);
        }
        }
    }
    printf("[System] A Total Of %d Groups Spawned!",GroupCount);
    //if(GroupCount <= 0 || GroupCount > MAX_GROUPS)
    //{
    //    GroupCount=0;
    //}
    mysql_free_result();
    return 1;
}
Reply
#28

Use this, and only this, no adjusting it.

pawn Код:
stock LoadGroups()
{
    printf("[System] Loading Groups's....");
    new line[1024], GroupCount;
    for (new i=0; i<MAX_GROUPS; i++)
    {
        format(GlobalQuery, sizeof(GlobalQuery), "SELECT * FROM Groups WHERE Groupid = %d", i);
        mysql_query(GlobalQuery);
        mysql_store_result();
        if(mysql_num_rows() > 0)
        {
            mysql_fetch_row(line))
            mysql_fetch_field_row(data, "Groupid");
            Groups[i][Groupid]=strval(data);
            mysql_fetch_field_row(data, "GroupName");
            format(Groups[i][GroupName], 70, "%s", data);
            mysql_fetch_field_row(data, "RankName0");
            format(Groups[i][RankName0], 70, "%s", data);
            mysql_fetch_field_row(data, "RankName1");
            format(Groups[i][RankName1], 70, "%s", data);
            mysql_fetch_field_row(data, "RankName2");
            format(Groups[i][RankName2], 70, "%s", data);
            mysql_fetch_field_row(data, "RankName3");
            format(Groups[i][RankName3], 70, "%s", data);
            mysql_fetch_field_row(data, "RankName4");
            format(Groups[i][RankName4], 70, "%s", data);
            mysql_fetch_field_row(data, "RankName5");
            format(Groups[i][RankName5], 70, "%s", data);
            mysql_fetch_field_row(data, "RankName6");
            format(Groups[i][RankName6], 70, "%s", data);
            mysql_fetch_field_row(data, "MOTD");
            format(Groups[i][MOTD], 70, "%s", data);

            printf("Loading Groupid:%d",GroupCount);
            printf("Groupid:%d Name:%s Rank0:%s Rank1:%s Rank2:%s Rank3:%s Rank4:%s Rank5:%s Rank6:%s",
            Groups[i][Groupid],Groups[i][GroupName],Groups[i][RankName0],Groups[i][RankName1],Groups[i][RankName2],
            Groups[i][RankName3],Groups[i][RankName4],Groups[i][RankName5],Groups[i][RankName6],Groups[i][MOTD]);

            GroupCount++;
        }
        mysql_free_result();
    }
    printf("[System] A Total Of %d Groups Spawned!",GroupCount);
    return 1;
}
Reply
#29

its only trying to load groupid 0, which no id 0 exists..

printf("Loading Groupid:%d",Groups[i][Groupid]);

prints 0
Reply
#30

MAX_GROUPS is set as?
Reply
#31

20 (8char)
Reply
#32

#define MAX_GROUPS 20 ?
Reply
#33

yes.. (8char_
Reply
#34

I do not understand.
Reply
#35

pawn Код:
#define MAX_GROUPS 20

enum GroupData
{
    Groupid,
    GroupName[255],
    RankName0[255],
    RankName1[255],
    RankName2[255],
    RankName3[255],
    RankName4[255],
    RankName5[255],
    RankName6[255],
    ChatDisabled,
    MOTD[255]
};
new Groups[MAX_GROUPS][GroupData];
new GroupCount=0;
i said 8char for the 8 characters limit
Reply
#36

Well it seems you have GroupCount twice. Might want to remove mine from within LoadGroups().
Reply
#37

fixed.
pawn Код:
stock LoadGroups()
{
    printf("[System] Loading Groups's....");
    new line[1024];
    for(new i = 0; i < MAX_GROUPS; i++)
    {
        format(GlobalQuery, sizeof(GlobalQuery), "SELECT * FROM Groups WHERE Groupid = %d", i);
        mysql_query(GlobalQuery);
        mysql_store_result();
        if(mysql_num_rows() > 0)
        {
            if(mysql_fetch_row(line))
            {
                GroupCount++;
                new Gstr[9][70],Gvar[1];
                sscanf(line, "p<|>ds[255]s[255]s[255]s[255]s[255]s[255]s[255]s[255]s[255]",Gvar[0],Gstr[0],Gstr[1],Gstr[2],Gstr[3],Gstr[4],Gstr[5],Gstr[6],Gstr[7],Gstr[8]);
                Groups[i][Groupid] = Gvar[0];
                format(Groups[i][GroupName], 70, "%s", Gstr[0]);
                format(Groups[i][RankName0], 70, "%s", Gstr[1]);
                format(Groups[i][RankName1], 70, "%s", Gstr[2]);
                format(Groups[i][RankName2], 70, "%s", Gstr[3]);
                format(Groups[i][RankName3], 70, "%s", Gstr[4]);
                format(Groups[i][RankName4], 70, "%s", Gstr[5]);
                format(Groups[i][RankName5], 70, "%s", Gstr[6]);
                format(Groups[i][RankName6], 70, "%s", Gstr[7]);
                format(Groups[i][MOTD], 70, "%s", Gstr[8]);
                printf("Loaded Groupid:%d",Groups[i][Groupid]);
                printf("Groupid:%d Name:%s Rank0:%s Rank1:%s Rank2:%s Rank3:%s Rank4:%s Rank5:%s Rank6:%s MOTD:%s",
                Groups[i][Groupid],Groups[i][GroupName],Groups[i][RankName0],Groups[i][RankName1],Groups[i][RankName2],
                Groups[i][RankName3],Groups[i][RankName4],Groups[i][RankName5],Groups[i][RankName6],Groups[i][MOTD]);
            }
        }
        mysql_free_result();
    }
    printf("[System] A Total Of %d Groups Spawned!",GroupCount);
    return 1;
}
thx for all your help.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)