Ayuda Top sqlite
#1

http://imgur.com/a/tiR7c
їPorquй se me ve asi? probe miles de formas y no, no anda, gracias.

Код:
CMD:topc(playerid,params[])
{
    new string[1000], query[256], str[700];
    new string2[500];
    new DBResult:result;
    new DBResult:result2;
    format(query,sizeof(query),"SELECT `NAME` FROM `USERS` ORDER BY (`SCORE` * 1) DESC limit 25");
    result = db_query(ULFDB,query);
    for(new a;a<db_num_rows(result);a++)
    {
    db_get_field(result,0,string,128);
    format(query,sizeof(query),"SELECT `SCORE` FROM `USERS` WHERE `NAME` = '%s'",string);
    result2 = db_query(ULFDB,query);
    db_get_field(result2,0,string2,128);
    format(string,sizeof(string),"{FFFFFF}ID\tNick\tScore\n%d\t%s\t%s\n",a+1,string,string2);
    format(str,sizeof(str),"%s%s\n",str,string);
    db_next_row(result);
    db_free_result(result2);
    }
    ShowPlayerDialog(playerid,UNUSED, DIALOG_STYLE_TABLIST_HEADERS,"{FFFFFF}TOP SCORE - {0077FF}ULF",str,"Aceptar","");
    db_free_result(result);
    return 1;
}
Reply
#2

Porque metiste la definiciуn de los valores en el bucle, me refiero a 'ID', 'Nick' y 'SCORE'.
Reply
#3

No entiendo Parka :/
Reply
#4

Prueba asi:

Quote:

CMD:topc(playerid,params[])
{
new string[128], DBResult:qresult, rows;
format(string, sizeof(string), "SELECT `NAME`,`SCORE` FROM `USERS` ORDER BY (`SCORE` * 1) DESC limit 25");
qresult = db_query(ULFDB, string);
rows = db_num_rows(qresult);
if(rows)
{
new final_string[32 * sizeof(string)], MiInfoNick[MAX_PLAYER_NAME], MiInfoKill;
strcat(final_string, "{FFFFFF}ID\tNick\tScore\n");
for(new i = 0; i < rows; i ++)
{
db_get_field_assoc(qresult, "NAME", MiInfoNick, sizeof(MiInfoNick));
MiInfoKill = db_get_field_assoc_int(qresult, "SCORE");
format(string, sizeof(string), ""COL_ROJO"%d°\t%s\t%d\n", (i + 1), MiInfoNick, MiInfoKill);
strcat(final_string, string);
db_next_row(qresult);
}
ShowPlayerDialog(playerid,UNUSED, DIALOG_STYLE_TABLIST_HEADERS, "{FFFFFF}TOP SCORE - {0077FF}ULF", final_string, "Aceptar", "");
PlayerPlaySound(playerid, 1139, 0.0, 0.0, 0.0);
}
db_free_result(qresult);
return 1;
}

Reply
#5

No me inicia el sv con ese cуdigo, sale runtime.
Reply
#6

La verdad no utilizo mucho sqlite, asi que nose si tendra alguna diferencia con mysql a la hora de hacer top, en todo caso te dejo este codigo.
PHP код:
CMD:topc(playerid,params[])
{
    new 
consulta[126],DBResult:R;
    
format(consulta,sizeof(consulta),"SELECT `NAME`,`SCORE` FROM `USERS` ORBDER BY `SCORE` DESC");
    
db_query(ULFDB,consulta)
    new 
final_string[200],Nombrex[MAX_PLAYER_NAME],Puntaje;
    new 
ct[100];
    
strcat(final_string,"ID\tNick\nScore");
    for(new 
0db_num_rows(R); g++)
    {
        
db_get_field_assoc(R"NAME"Nombrexsizeof(NombreX));
        
Puntaje db_get_field_assoc_int(R"SCORE");
        
format(ct,sizeof(ct),"\n%d\t%q\t%d"iNombrexPuntaje);
        
strcat(final_string,ct);
        
db_next_row(R);
    }
    
ShowPlayerDialog(playerid,UNUSEDDIALOG_STYLE_TABLIST_HEADERS"{FFFFFF}TOP SCORE - {0077FF}ULF"final_string"Aceptar""");
    
PlayerPlaySound(playerid11390.00.00.0);
    
db_free_result(R);
    return 
true;

PD: este codigo aun no esta probado.
Reply
#7

No, tira muchos errores..
Reply
#8

Aqui te dejo el codigo, me compila bien, aunque nose si haga su proposito:
PHP код:
CMD:topc(playerid,params[])
{
    new 
consulta[126],DBResult:R;
    
format(consulta,sizeof(consulta),"SELECT `NAME`,`SCORE` FROM `USERS` ORBDER BY `SCORE` DESC");
    
db_query(SQLite,consulta);
    new 
final_string[200],Nombrex[MAX_PLAYER_NAME],Puntajex;
    new 
ct[100];
    
strcat(final_string,"ID\tNick\nScore");
    for(new 
0db_num_rows(R); g++)
    {
        
db_get_field_assoc(R"NAME"Nombrex25);
        
Puntajex db_get_field_assoc_int(R"SCORE");
        
format(ct,sizeof(ct),"\n%d\t%q\t%d"gNombrexPuntajex);
        
strcat(final_string,ct);
        
db_next_row(R);
    }
    
ShowPlayerDialog(playerid,UNUSEDDIALOG_STYLE_TABLIST_HEADERS"{FFFFFF}TOP SCORE - {0077FF}ULF"final_string"Aceptar""");
    
PlayerPlaySound(playerid11390.00.00.0);
    
db_free_result(R);
    return 
true;

Reply
#9

Tampoco funciona, lo arregle eso de " db_get_field_assoc_int " pero sigue sin abrir el sv.
EDIT:
Код HTML:
[13:14:50] Script[gamemodes/ULF.amx]: Run time error 19: "File or function is not found"
[13:14:50] Number of vehicle models: 0
Reply
#10

PHP код:
CMD:topc(playerid,params[])
{
    new 
string[1000], query[256], str[700], str2[40];
    new 
string2[500];
    new 
DBResult:result;
    new 
DBResult:result2;
    
format(query,sizeof(query),"SELECT `NAME` FROM `USERS` ORDER BY (`SCORE` * 1) DESC limit 25");
    
result db_query(ULFDB,query);
    
strcat(str"{FFFFFF}ID\tNick\tScore\n");
    for(new 
a;a<db_num_rows(result);a++)
    {
        
db_get_field(result,0,string,128);
        
format(query,sizeof(query),"SELECT `SCORE` FROM `USERS` WHERE `NAME` = '%s'",string);
           
result2 db_query(ULFDB,query);
        
db_get_field(result2,0,string2,128);
        
format(str2,sizeof(str2),"%d\t%s\t%s\n",a+1,string,string2);
        
strcat(strstr2);
        
db_next_row(result);
        
db_free_result(result2);
    }
    
ShowPlayerDialog(playerid,UNUSEDDIALOG_STYLE_TABLIST_HEADERS,"{FFFFFF}TOP SCORE - {0077FF}ULF",str,"Aceptar","");
    
db_free_result(result);
    return 
1;

Lo de que no abre el server no tiene nada que ver con este codigo, revisa los plugins quizas sea eso
Reply


Forum Jump:


Users browsing this thread: