12.01.2014, 12:40
The idnex (index*) is wrong I think too. It will start: kill[0] but id[1] instead of 0. Make sure about the datatype as Vince said and then try:
it works fine to me.
By the way, use LIMIT clause in the query because if you get more than 30 rows, it will exceed the array's indexes (out of bounds).
pawn Код:
db_get_field_assoc (sys_result, "kills", sys_field, 20),
kills [i] = strval(sys_field);
db_get_field_assoc (sys_result, "id", sys_field, 20),
id [i] = strval(sys_field);
db_next_row (sys_result);
pawn Код:
// Output:
[15:48:06] rows: 9
[15:48:06] id 5, kills 3300
[15:48:06] id 6, kills 789
[15:48:06] id 4, kills 120
[15:48:06] id 3, kills 110
[15:48:06] id 2, kills 99
[15:48:06] id 1, kills 90
[15:48:06] id 0, kills 88
[15:48:06] id 7, kills 55
[15:48:06] id 8, kills 33
pawn Код:
sys_result = db_query (Database, "SELECT * FROM `players` ORDER BY `kills` DESC LIMIT 30"); // change to the top N you want.