SA-MP Forums Archive
Top Groups SQLITE - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Top Groups SQLITE (/showthread.php?tid=596993)



Top Groups SQLITE - SilverStand - 25.12.2015

Someone give me example script for top group Kills SQLite easydb pls


Re: Top Groups SQLITE - SilverStand - 25.12.2015

yeah, i know i have make this script

Код:
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;
}
but i want make it to dialog msgbox and the text will be :

1. GroupName With Kills GroupKills
2. GroupName With Kills GroupKills


can you help me ?


Re: Top Groups SQLITE - SilverStand - 25.12.2015

Oh man ty so much :> +REP

i have fixed
Код:
        db_get_field_assoc(query, "GroupName", gangname, sizeof(gangname));
        gangkills = db_get_field_assoc_int(query, "GroupKills");
to
Код:
        db_get_field_assoc(result, "GroupName", gangname, sizeof(gangname));
        gangkills = db_get_field_assoc_int(result, "GroupKills");
and changed

Код:
format(query,sizeof(query),"SELECT GroupName, GroupKills FROM Groups ORDER BY GroupName, GroupKills DESC limit 3");
to
Код:
format(query,sizeof(query),"SELECT GroupName, GroupKills FROM Groups ORDER BY GroupKills DESC limit 0,10");



Re: Top Groups SQLITE - iKarim - 25.12.2015

PHP код:
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 
adb_num_rows(result); a++, db_next_row(result))
    {
        
db_get_field_assoc(query"GroupName"gangnamesizeof(gangname));
        
gangkills db_get_field_assoc_int(query"GroupKills");
        
format(string,sizeof(string),"%s\nRank: %d - Name: %s - Kills: %i"string1gangnamegangkills);
    }
    
ShowPlayerDialog(playerid0xABCDDIALOG_STYLE_MSGBOX"Top Groups"string"Close""");
    
db_free_result(result);
    return 
1;




Re: Top Groups SQLITE - SilverStand - 25.12.2015

Quote:
Originally Posted by PawnHunter
Посмотреть сообщение
PHP код:
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 
adb_num_rows(result); a++, db_next_row(result))
    {
        
db_get_field_assoc(query"GroupName"gangnamesizeof(gangname));
        
gangkills db_get_field_assoc_int(query"GroupKills");
        
format(string,sizeof(string),"%s\nRank: %d - Name: %s - Kills: %i"string1gangnamegangkills);
    }
    
ShowPlayerDialog(playerid0xABCDDIALOG_STYLE_MSGBOX"Top Groups"string"Close""");
    
db_free_result(result);
    return 
1;

Ty for make it to be a dialog :> REP+ for you too