MySQL Problem.
#1

I'm having an issue loading families. They create and save correctly, They just don't load anything.

pawn Код:
public OnLoadFamilies() {
    new rows, fields;
    cache_get_data(rows,fields);
   
    new id_string[128];

    for(new i=0;i<rows;i++) {  
       
        cache_get_row(i,0,id_string);      
       
        Families[i][EFamilySQLID] = strval(id_string);
       
        cache_get_row(i,1,Families[i][EFamilyName]);
       
        cache_get_row(i,2, id_string);
        Families[i][EFamilyColour] = strval(id_string);
       
        cache_get_row(i,3,Families[i][EFamilyMOTD]);
       
        cache_get_row(i,4,Families[i][EFamilyOwner]);
       
        GiveNameSpace(Families[i][EFamilyOwner]);

        cache_get_row(i,5,FamilyRanks[i][0]); //rank1text
        cache_get_row(i,6,id_string); //rank1perms
        Families[i][EFamilyRankPerms][0] = EFamilyPermissions:strval(id_string);
       
        cache_get_row(i,7,FamilyRanks[i][1]); //rank2text
        cache_get_row(i,8,id_string); //rank2perms
        Families[i][EFamilyRankPerms][1] = EFamilyPermissions:strval(id_string);
       
        cache_get_row(i,9,FamilyRanks[i][2]); //rank3text
        cache_get_row(i,10,id_string); //rank3perms
        Families[i][EFamilyRankPerms][2] = EFamilyPermissions:strval(id_string);
       
        cache_get_row(i,11,FamilyRanks[i][3])//rank4text
        cache_get_row(i,12,id_string); //rank4perms
        Families[i][EFamilyRankPerms][3] = EFamilyPermissions:strval(id_string);
       
        cache_get_row(i,13,FamilyRanks[i][4]); //rank5perms
        cache_get_row(i,14,id_string); //rank5perms
        Families[i][EFamilyRankPerms][4] = EFamilyPermissions:strval(id_string);
       
        cache_get_row(i,15,FamilyRanks[i][5]); //rank5perms
        cache_get_row(i,16,id_string); //rank5perms
        Families[i][EFamilyRankPerms][5] = EFamilyPermissions:strval(id_string);
       
        cache_get_row(i,17,id_string); //hq
        Families[i][EFamilyHQID] = strval(id_string);
       
        cache_get_row(i,18,id_string); //hqx
        Families[i][EFamilyHQX] = floatstr(id_string);
       
        cache_get_row(i,19,id_string); //hqy
        Families[i][EFamilyHQY] = floatstr(id_string);
       
        cache_get_row(i,20,id_string); //hqz
        Families[i][EFamilyHQZ] = floatstr(id_string);
       
        LoadFamilyCars(Families[i][EFamilySQLID]);
       
    }
    pointsOnGameModeInit();
    loadFamilySafes();
}
pawn Код:
loadFamilies() {
    query[0] = 0;
    format(query, sizeof(query), "SELECT `families`.`id`, `name`, `colour`,`motd`,`characters`.`username`,`rank1text`,`rank1perms`,`rank2text`,`rank2perms`,`rank3text`,`rank3perms`,`rank4text`,`rank4perms`,`rank5text`,`rank5perms`,`rank6text`,`rank6perms`,`hq`,`hqx`,`hqy`,`hqz` FROM `families` INNER JOIN `characters` ON `owner` = `characters`.`id`");
    mysql_function_query(g_mysql_handle, query, true, "OnLoadFamilies", "");
}
Reply
#2

While I did not review your load code I am going to ask an important question before others can check: are you sure the query array is big enough to hold such query string?
Reply
#3

Why are you doing this

pawn Код:
query[0] = 0;
before using format()? It is useless. format() overwrites the entire string. You only need to do that for strcat.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)