Raised This Month: $12 Target: $400
 3% 

[HELP] How to align right scored


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
papel
Junior Member
Join Date: Jul 2017
Old 08-23-2020 , 10:12   [HELP] How to align right scored
Reply With Quote #1

Hi, how are you?
I have this ranking on my server and I wonder if it is possible to just align the score to the right, as shown in the figure 2?

Have a great day.



Code:
public SQLQueryTop10(Handle:owner, Handle:hndl, const String:error[], any:data) {
	new client;
	if((client = GetClientOfUserId(data))==0) {
		return;
	}
	if(hndl==INVALID_HANDLE) {
		LogError("Query failed: %s", error);
	} else {
		decl String:qname[64], String:qrating[8], String:buffer[68];
		new i = 0;
		new num = 1;
		new Handle:panel = CreatePanel();
		SetPanelTitle(panel, "Top 10 players:");
		while(SQL_FetchRow(hndl)) {
			SQL_FetchString(hndl, 0, qname, sizeof(qname));
			SQL_FetchString(hndl, 1, qrating, sizeof(qrating));
			Format(buffer, sizeof(buffer), "%02i. %s pts - %s",num, qrating, qname);
			num++;
			DrawPanelText(panel, buffer);
			i++;
		}
		DrawPanelItem(panel, "Close");
		SendPanelToClient(panel, client, PanelHandlerNothing, 15);
		CloseHandle(panel);
	}
}

Last edited by papel; 08-23-2020 at 10:13.
papel is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 08-23-2020 , 12:20   Re: [HELP] How to align right scored
Reply With Quote #2

Here's example but you will need to get string max length for sFormat (if you use ORDER BY <column> DESC then you can get max length from first qrating result and just save it to integer variable).
Attached Images
File Type: jpg Screenshot_1.jpg (46.7 KB, 35 views)
File Type: jpg Screenshot_2.jpg (8.8 KB, 40 views)
__________________

Last edited by MAGNAT2645; 08-23-2020 at 12:27.
MAGNAT2645 is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-23-2020 , 14:04   Re: [HELP] How to align right scored
Reply With Quote #3

PHP Code:
"%02i. %-10s pts - %s" 
__________________
Ilusion9 is offline
papel
Junior Member
Join Date: Jul 2017
Old 08-23-2020 , 15:59   Re: [HELP] How to align right scored
Reply With Quote #4

Quote:
Originally Posted by MAGNAT2645 View Post
Here's example but you will need to get string max length for sFormat (if you use ORDER BY <column> DESC then you can get max length from first qrating result and just save it to integer variable).
Thanks, MAGNAT2645. I'm a beginner in programming. I couldn't do what you asked.

Quote:
Originally Posted by Ilusion9 View Post
PHP Code:
"%02i. %-10s pts - %s" 
Ilusion9, thank you. I changed according to your guidance, but it didn't work. Below is the impression.


Last edited by papel; 08-23-2020 at 16:00.
papel is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-23-2020 , 16:25   Re: [HELP] How to align right scored
Reply With Quote #5

Try this:
PHP Code:
 "%02i. %10s pts - %s" 
__________________
Ilusion9 is offline
papel
Junior Member
Join Date: Jul 2017
Old 08-23-2020 , 17:08   Re: [HELP] How to align right scored
Reply With Quote #6

Quote:
Originally Posted by Ilusion9 View Post
Try this:
PHP Code:
 "%02i. %10s pts - %s" 
Right. I tried, but it didn't work. It was printed in the same way as before, when -10 was used.
papel is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 08-23-2020 , 19:31   Re: [HELP] How to align right scored
Reply With Quote #7

...problem start at beginning with characters in menu. "space" is short and doesn't line well.
So need double spaces.

PHP Code:
public void OnPluginStart()
{
    
RegConsoleCmd("sm_test"test);
}

public 
Action test(int clientint args)
{

    
Panel panel = new Panel();
    
panel.SetTitle("Top Players");

    
char bufferpoints[20];
    
char buffer[200];
    
char names[][] = {"""<- This exceed by one""Harry""Matt""John""Lisa""George""Alpha""Beta""Omega""Apple"};
    
int points[] = {021111100023333002220017700800509751};
    
    for(
int x 1<= 10x++)
    {
        
Format(bufferpointssizeof(bufferpoints), "%8d"points[x]);
        
        
int index FindCharInString(bufferpoints' 'true);
        
PrintToServer("index %i"index);
        
        
// double spaces
        
for(int a 0<= indexa++)
        {
            
Format(bufferpointssizeof(bufferpoints), " %s"bufferpoints);
        }

        
Format(buffersizeof(buffer), "%02i. %s - %s"xbufferpointsnames[x]);
        
panel.DrawText(buffer);
        
PrintToServer("%s"buffer);
    }

    
panel.Send(clientpanel_handler20);
    
delete panel;

    return 
Plugin_Handled;
}

public 
int panel_handler(Menu menuMenuAction actionint param1int param2) {} 
Attached Thumbnails
Click image for larger version

Name:	top10.png
Views:	57
Size:	68.9 KB
ID:	183363  
__________________
Do not Private Message @me

Last edited by Bacardi; 08-23-2020 at 19:32. Reason: delete panel
Bacardi is offline
papel
Junior Member
Join Date: Jul 2017
Old 08-24-2020 , 12:41   Re: [HELP] How to align right scored
Reply With Quote #8

Quote:
Originally Posted by Bacardi View Post
...problem start at beginning with characters in menu. "space" is short and doesn't line well.
So need double spaces.

PHP Code:
public void OnPluginStart()
{
    
RegConsoleCmd("sm_test"test);
}

public 
Action test(int clientint args)
{

    
Panel panel = new Panel();
    
panel.SetTitle("Top Players");

    
char bufferpoints[20];
    
char buffer[200];
    
char names[][] = {"""<- This exceed by one""Harry""Matt""John""Lisa""George""Alpha""Beta""Omega""Apple"};
    
int points[] = {021111100023333002220017700800509751};
    
    for(
int x 1<= 10x++)
    {
        
Format(bufferpointssizeof(bufferpoints), "%8d"points[x]);
        
        
int index FindCharInString(bufferpoints' 'true);
        
PrintToServer("index %i"index);
        
        
// double spaces
        
for(int a 0<= indexa++)
        {
            
Format(bufferpointssizeof(bufferpoints), " %s"bufferpoints);
        }

        
Format(buffersizeof(buffer), "%02i. %s - %s"xbufferpointsnames[x]);
        
panel.DrawText(buffer);
        
PrintToServer("%s"buffer);
    }

    
panel.Send(clientpanel_handler20);
    
delete panel;

    return 
Plugin_Handled;
}

public 
int panel_handler(Menu menuMenuAction actionint param1int param2) {} 

Wow, unbelievable !! Thank you very much Bacardi. I will try now. Have a great day!
MAGNAT2645, Ilusion9, thank you so much for all your help.

Last edited by papel; 08-24-2020 at 12:43.
papel is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode