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

current player ranks


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 11-30-2019 , 12:23   current player ranks
Reply With Quote #1

can some one code to get current server player ranks in a motd.
command: /playerranks

Example:
# Nick Rank
1. Player1 23232

Ty.
__________________

Last edited by Sanjay Singh; 11-30-2019 at 13:40.
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-30-2019 , 12:55   Re: SOlved
Reply With Quote #2

You shouldn't change your post to 'solved' when you solve it. Leave your question in the original post and then do a reply with your solution. It can help others who may have the same issue.
__________________
Bugsy is offline
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 11-30-2019 , 13:41   Re: SOlved
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
You shouldn't change your post to 'solved' when you solve it. Leave your question in the original post and then do a reply with your solution. It can help others who may have the same issue.
its not solved , i thought i solved it but didnt worked.
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
thEsp
BANNED
Join Date: Aug 2017
Old 11-30-2019 , 13:54   Re: SOlved
Reply With Quote #4

Quote:
Originally Posted by Sanjay Singh View Post
its not solved , i thought i solved it but didnt worked.
See? You need this community to look after your problems, so don't blank your threads. ;) ;)

Karma++.
thEsp is offline
AmXDusT
Member
Join Date: Feb 2019
Location: Italy / Albania
Old 11-30-2019 , 20:03   Re: current player ranks
Reply With Quote #5

Hi, there might be better solutions. Try this.
PHP Code:
#include <amxmodx>
#include <csstats>


public plugin_init()
{
        
register_plugin"Testing" "1.0" "DusT" );

        
register_clcmd"say /getranks""GetRanks" );
}

public 
GetRanksid )
{
        new 
iPlayersMAX_PLAYERS ], iNum;
        new 
iStatsSTATSX_MAX_STATS ], iBodyhitsMAX_BODYHITS ];
        new 
ijszTmp32 ], iTmp;
        new 
StatsMAX_PLAYERS ][ 32 ];
        new 
iPosMAX_PLAYERS ];

        
get_playersiPlayersiNum );
        
        for( 
0iNumi++ )
        {
                
iPos] = get_user_statsiPlayers], iStatsiBodyhits );
                
get_user_nameiPlayers], Stats], 31 );

                
// sorting based on insertion sort
                
for( i&& iPos] > iPos]; j-- )
                {
                        
iTmp iPos];
                        
iPos] = iPos];
                        
iPos] = iTmp;
                        
copyszTmpcharsmaxszTmp ), Stats] );
                        
copyStats], 31Stats] );
                        
copyStats], 31szTmp );
                }
        }

        new 
szMotd2000 ];
        new 
iLen;
        
// keeping the amxx style for the motd design
        
iLen formatexszMotdcharsmaxszMotd ), "<meta charset=utf-8><body bgcolor=#000000><font color=#FFB000><pre>" );
        
iLen += formatexszMotdiLen ], charsmaxszMotd ), "%2s %-22.22s %6s ^n""#""Nick""Rank" );

        for( new 
0iNumi++ )
        {
                
replace_allStats], 31"<""[" );
                
replace_allStats], 31">""]" );
                
iLen += formatexszMotdiLen ], charsmaxszMotd ), "%2d %-22.22s %6d^n", ( ), Stats], iPos] );
        }
        
        
show_motdidszMotd"Player Ranks" );

        return 
PLUGIN_HANDLED;


Last edited by AmXDusT; 11-30-2019 at 20:06.
AmXDusT is offline
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 12-01-2019 , 01:29   Re: current player ranks
Reply With Quote #6

what is this for
%2d %-22.22s %6d
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-01-2019 , 10:55   Re: current player ranks
Reply With Quote #7

Quote:
Originally Posted by Sanjay Singh View Post
what is this for
%2d %-22.22s %6d
String formatting to keep columns aligned in the MOTD.
__________________
Bugsy is offline
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 12-06-2019 , 02:29   Re: current player ranks
Reply With Quote #8

Quote:
Originally Posted by Bugsy View Post
String formatting to keep columns aligned in the MOTD.
can you explain the string spacing or alignment? so i can do by myself.
__________________

Last edited by Sanjay Singh; 12-06-2019 at 02:33.
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
Sanjay Singh
Veteran Member
Join Date: Sep 2016
Old 12-06-2019 , 02:33   Re: current player ranks
Reply With Quote #9

And also is it possible to create table data like a HTML format?
__________________
Sanjay Singh is offline
Send a message via AIM to Sanjay Singh
AmXDusT
Member
Join Date: Feb 2019
Location: Italy / Albania
Old 12-06-2019 , 03:47   Re: current player ranks
Reply With Quote #10

Quote:
Originally Posted by Sanjay Singh View Post
can you explain the string spacing or alignment? so i can do by myself.
It's mostly taken from the amxx's top15 motd.

The "-" says to align left.
The number before the dot is the width, which should be the minimum number of printed chars (if less than that it leaves empty characters).
the number after the dot is the precision. It's the maximum chars available. Names longer than 22 will be cut.

The MOTD is made in HTML.
AmXDusT is offline
Reply



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 19:34.


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