25.12.2015, 12:56
Someone give me example script for top group Kills SQLite easydb pls
CMD:topgroups(playerid,params[]) { new string[128], query[256]; SendClientMessage(playerid,COLOR_WHITE,"Top Groups"); new DBResult:result; new DBResult:result2; format(query,sizeof(query),"SELECT `GroupName` FROM `Groups` ORDER BY (`GroupKills` * 1) DESC limit 3"); result = DB::Query(query); for(new a;a<db_num_rows(result);a++)//what we have now is 10 rows in the database result, so we'll do a loop to show each one on a new line. { db_get_field(result,0,string,128); format(string,sizeof(string),"%d. %s",a+1,string);//it's a+1 because the result starts at 0, this will display as "1. Name Stat: X". SendClientMessage(playerid,COLOR_WHITE,string); db_next_row(result);//this function changes to the next row down, then when it goes into the next loop cycle it'll get the second top player and so forth. db_free_result(result2);//remember to free any results you don't need anymore } db_free_result(result); return 1; }
db_get_field_assoc(query, "GroupName", gangname, sizeof(gangname)); gangkills = db_get_field_assoc_int(query, "GroupKills");
db_get_field_assoc(result, "GroupName", gangname, sizeof(gangname)); gangkills = db_get_field_assoc_int(result, "GroupKills");
format(query,sizeof(query),"SELECT GroupName, GroupKills FROM Groups ORDER BY GroupName, GroupKills DESC limit 3");
format(query,sizeof(query),"SELECT GroupName, GroupKills FROM Groups ORDER BY GroupKills DESC limit 0,10");
CMD:topgroups(playerid,params[])
{
new
query[256];
new
DBResult:result;
format(query,sizeof(query),"SELECT GroupName, GroupKills FROM Groups ORDER BY GroupName, GroupKills DESC limit 3");
result = DB::Query(query);
new
gangkills,
gangname[30],
string[512];
for (new a; a < db_num_rows(result); a++, db_next_row(result))
{
db_get_field_assoc(query, "GroupName", gangname, sizeof(gangname));
gangkills = db_get_field_assoc_int(query, "GroupKills");
format(string,sizeof(string),"%s\nRank: %d - Name: %s - Kills: %i", string, a + 1, gangname, gangkills);
}
ShowPlayerDialog(playerid, 0xABCD, DIALOG_STYLE_MSGBOX, "Top Groups", string, "Close", "");
db_free_result(result);
return 1;
}
PHP код:
|