SQL Error
#1

Here i'm trying to display top ten online players list but fails

pawn Код:
CMD:top10on(playerid, params[])
{
    new full_info[500];
    for(new row, rows = cache_get_row_count(mysql); row < rows; row ++)
    {
        new
            username[MAX_PLAYER_NAME + 1],
            pphour,
            ppmins,
            ID,
            sub_info[50]
        ;
        ID ++;
        cache_get_field_content(row, "user", username, mysql);
        pphour = cache_get_field_content_int(row, "phours", mysql);
        ppmins = cache_get_field_content_int(row, "pminutes", mysql);

        format(sub_info, sizeof(sub_info), "%s"ccwhite"%d. %s with "ccgreen"%d "ccwhite"hours, "ccgreen"%d "ccwhite"minutes\n", row + 1, ID, username, pphour, ppmins);
        strcat(full_info, sub_info);

    }
    ShowPlayerDialog(playerid, 1101, DIALOG_STYLE_MSGBOX, "Top 10 Online", full_info, "OK", "Cancel");
    return 1;
}
This is what shows in the log

Quote:

[22:08:13] [DEBUG] cache_get_row_count - connection: 1
[22:08:13] [WARNING] cache_get_row_count - no active cache

Why is that error, how could it be fixed?
Reply
#2

You aren't sending a query.
Reply
#3

Can ya show how the code would get rearranged
Reply
#4

PHP код:
CMD:top10on(playeridparams[])
{
    new 
query[100];
    
mysql_format(connectionquerysizeof(query), "SELECT * FROM TableName ORDER BY pHours LIMIT 10;");
    
mysql_tquery(connectionquery"top10onQ""d"playerid);
    return 
1;
}
forward top10onQ(playerid);
public 
top10onQ(playerid)
{
    for(new 
i=0i<cache_get_row_count(); i++)
    {
        new
            
username[MAX_PLAYER_NAME 1],
            
pphour,
            
ppmins,
            
sub_info[50]
        ;
        
GetPlayerName(playeridusernamesizeof(username));
        
cache_get_field_content(i"user"username);
        
pphour cache_get_field_content_int(i"phours");
        
ppmins cache_get_field_content_int(i"pminutes");
        
format(sub_infosizeof(sub_info), "%s"ccwhite"%d. %s with "ccgreen"%d "ccwhite"hours, "ccgreen"%d "ccwhite"minutes\n"row 1IDusernamepphourppmins);
        
strcat(full_infosub_info);
    }
    
ShowPlayerDialog(playerid1101DIALOG_STYLE_MSGBOX"Top 10 Online"full_info"OK""Cancel");
    return 
1;

This should work, might have a few typo's but you can correct those I guess... this is pretty fast but yeah.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)