#1

Hello, i am trying to show a dialog, DIALOG_STYLE_MSGBOX, but its not aligned...

here's the format:

PHP код:
format(ganglistsizeof(ganglist), "%s%d. {%s}%s {FFFFFF}- Score : %d  \t\t\t\t{23ffaa}Gang Kills: %d \tGang Deaths: %d\n" /* stuff here, but we dont care */



How can i align kills / deaths ?
Reply
#2

Don't use that style but DIALOG_STYLE_TABLIST or DIALOG_STYLE_TABLIST_HEADERS. Keep only one \t to separate them and it will align itself. The limit is 4 columns so you can pretty much organize them as "rank (position-name of gang) - score - kills - deaths".
Reply
#3

My current command is like this:

PHP код:
COMMAND:topgang(playeridparams[])
{
    new 
query[128];
    
mysql_format(connectionquerysizeof(query), "SELECT * FROM `cnr_gang` ORDER BY `score` DESC LIMIT 20");
    
mysql_query(connectionquerytrue);
    new 
ganglist[2500], count cache_num_rows(), TempColor[7], TempName[30];
    if(
count != 0)
    {
        for(new 
0counti++)
        {
            
cache_get_field_content(i"color"TempColor);
            
cache_get_field_content(i"name"TempName);
            new 
gangkills cache_get_field_content_int(0"Kills");
            new 
gangdeaths cache_get_field_content_int(0"Deaths");
            
format(ganglistsizeof(ganglist), "%s%d. {%s}%s {FFFFFF}- Score : %d  \t\t\t\t{23ffaa}Gang Kills: %d \tGang Deaths: %d\n"ganglist, (i+1), TempColorTempNamecache_get_field_content_int(i"score"), gangkillsgangdeaths);
        }
        
format(ganglistsizeof(ganglist), "%s\n* This top list updated every %d minutes"ganglistAUTOSAVE);
        
ShowPlayerDialog(playeridDIALOG_UNUSEDDIALOG_STYLE_MSGBOX"Top Gangs"ganglist"Close""");
    }
    else
        
SendClientMessage(playerid, -1"{FF0000}There's no gangs present!");
    return 
1;

So can i do it like:
PHP код:
format(ganglistsizeof(ganglist), "%s\n Gang Name\tGang Score\tGang Kills\tGang Deaths\n\",ganglist); 
PHP код:
format(ganglistsizeof(ganglist), "%s {%s}%s \t{FFFFFF}%d\t{23ffaa}%d \t%d\n\", ganglist,  TempColor, TempName, cache_get_field_content_int(i, "score"), gangkills, gangdeaths);
format(ganglist, sizeof(ganglist), "
%s\nThis top list updated every %d minutes", ganglist, AUTOSAVE); 
PHP код:
ShowPlayerDialog(playeriddialogidDIALOG_STYLE_TABLIST_HEADERS"Top Gangs",ganglist"Select""Cancel"); 
?
Reply
#4

The first thing I noticed is that you don't delete the cache and you may experience memory leaks. Threaded queries are always recommended as well.

When retrieving kills/deaths you have rowid as 0 instead of "i" so it will get the data of the first gang returned. Colors are integers so you can save them as such and when load them you can color embedding as:
pawn Код:
"{%06x} ...", color >>> 8, ...
---

Yes, like that but the headers should be outside:
pawn Код:
ganglist = "Gang Name\tGang Score\tGang Kills\tGang Deaths\n";

for (new i = 0; i < count; i++)
{
    cache_get_field_content(i, "color", TempColor);
    cache_get_field_content(i, "name", TempName);
   
    format(ganglist, sizeof(ganglist), "%s{%s}%s\t{FFFFFF}%d\t{23ffaa}%d\t%d\n", ganglist, TempColor, TempName, cache_get_field_content_int(i, "score"), cache_get_field_content_int(i, "Kills"), cache_get_field_content_int(i, "Deaths"));
}
---

Since you select them from the database, why don't you update score, kills and deaths directly so it will always be updated and not like 30 minutes you mention.
Reply
#5

Thanks, it works.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)