AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with top15 MOTD (https://forums.alliedmods.net/showthread.php?t=337593)

maNIaRO 05-01-2022 12:49

Help with top15 MOTD
 
Hi all,
I have a stats plugin with sql saving.
All good, but I want to improve a little bit the MOTD for /top15
I have 6 columns in the motd, first one is rank number, then nickname and so on.
I just want to add either in the same column with rank, or separate column between rank and name, an image for each row of the top15. Like separate image from csgo ranks.
Can you please help with what and/or how I should change?

Thanks

Code:

public GiveTopInformation(FailState, Handle:Query, Error[], Errcode, DataPlayer[], DataSize)
{
    new id, PlayerName2[32], Number[10], PlayerPoints, iMOTDPos, string[3036], iNumResults;
   
    id = DataPlayer[0], string[0] = EOS;
    iMOTDPos = format(string, charsmax(string), "<html><head><style>body{background:#FFF;font-family:Tahoma}th{background:#056B9E;color:#FFF;padding:3px;text-align:left;border-top:4px solid #3986AC}td{background:#CCCCCC;padding:2px 6px;border-bottom:1px dotted}table{color:#006699;background:#FFF;font-size:15px;border:2px solid #006699}</style></head><body><table width=100%% border=0 align=center cellpadding=0 cellspacing=1>");           
    iMOTDPos += format(string[iMOTDPos], charsmax(string)-iMOTDPos, "<center><img src='https://i.imgur.com/4kypRjN.png'></center><br/><tr><th>Rank<th>Nick<th>Points<th>Kills<th>Deaths<th>HS</tr>");
    iNumResults = SQL_NumResults(Query);

    if(iNumResults)
    {
        for(new i; i < iNumResults; i++)
        {
            SQL_ReadResult(Query, 1, PlayerName2, charsmax(PlayerName2)), PlayerPoints = SQL_ReadResult(Query, 3), AddCommas(PlayerPoints, Number, charsmax(Number));
            iMOTDPos += format(string[iMOTDPos], charsmax(string)-iMOTDPos, "<tr><td>%d<td>%s<td>%s<td>#<td>#<td>#</tr>", i+1, PlayerName2, Number);
            SQL_NextRow(Query);
        }
    }
    copy(string[iMOTDPos], charsmax(string)-iMOTDPos, "</table><center><img src='https://i.imgur.com/XR2ZufG.png'></center></body></html>");
    show_motd(id, string, "PLOIESTI.LaLeagane.Ro");
    return PLUGIN_HANDLED;
}


Bugsy 05-01-2022 12:53

Re: Help with top15 MOTD
 
Try something like this, assuming the rank images are named consistently

"https://i.imgur.com/Rank1.png"
"https://i.imgur.com/Rank2.png"
etc.

PHP Code:

public GiveTopInformation(FailStateHandle:QueryError[], ErrcodeDataPlayer[], DataSize)
{
    new 
idPlayerName2[32], Number[10], PlayerPointsiMOTDPosstring[3036], iNumResults;
    
    
id DataPlayer[0], string[0] = EOS;
    
iMOTDPos format(stringcharsmax(string), "<html><head><style>body{background:#FFF;font-family:Tahoma}th{background:#056B9E;color:#FFF;padding:3px;text-align:left;border-top:4px solid #3986AC}td{background:#CCCCCC;padding:2px 6px;border-bottom:1px dotted}table{color:#006699;background:#FFF;font-size:15px;border:2px solid #006699}</style></head><body><table width=100%% border=0 align=center cellpadding=0 cellspacing=1>");             
    
iMOTDPos += format(string[iMOTDPos], charsmax(string)-iMOTDPos"<center><img src='https://i.imgur.com/4kypRjN.png'></center><br/><tr><th>Rank<th>Nick<th>Points<th>Kills<th>Deaths<th>HS</tr>");
    
iNumResults SQL_NumResults(Query);
    
    if(
iNumResults
    {
        for(new 
iiNumResultsi++)
        {
            
SQL_ReadResult(Query1PlayerName2charsmax(PlayerName2)), PlayerPoints SQL_ReadResult(Query3), AddCommas(PlayerPointsNumbercharsmax(Number));
            
iMOTDPos += format(string[iMOTDPos], charsmax(string)-iMOTDPos"<tr><td><img src='https://i.imgur.com/Rank%d.png'> %d<td>%s<td>%s<td>#<td>#<td>#</tr>"i+i+1PlayerName2Number);
            
SQL_NextRow(Query);
        }
    }
    
copy(string[iMOTDPos], charsmax(string)-iMOTDPos"</table><center><img src='https://i.imgur.com/XR2ZufG.png'></center></body></html>");
    
show_motd(idstring"PLOIESTI.LaLeagane.Ro");
    return 
PLUGIN_HANDLED;



maNIaRO 05-02-2022 06:38

Re: Help with top15 MOTD
 
Quote:

Originally Posted by Bugsy (Post 2778431)
Try something like this, assuming the rank images are named consistently

"https://i.imgur.com/Rank1.png"
"https://i.imgur.com/Rank2.png"
etc.

PHP Code:

public GiveTopInformation(FailStateHandle:QueryError[], ErrcodeDataPlayer[], DataSize)
{
    new 
idPlayerName2[32], Number[10], PlayerPointsiMOTDPosstring[3036], iNumResults;
    
    
id DataPlayer[0], string[0] = EOS;
    
iMOTDPos format(stringcharsmax(string), "<html><head><style>body{background:#FFF;font-family:Tahoma}th{background:#056B9E;color:#FFF;padding:3px;text-align:left;border-top:4px solid #3986AC}td{background:#CCCCCC;padding:2px 6px;border-bottom:1px dotted}table{color:#006699;background:#FFF;font-size:15px;border:2px solid #006699}</style></head><body><table width=100%% border=0 align=center cellpadding=0 cellspacing=1>");             
    
iMOTDPos += format(string[iMOTDPos], charsmax(string)-iMOTDPos"<center><img src='https://i.imgur.com/4kypRjN.png'></center><br/><tr><th>Rank<th>Nick<th>Points<th>Kills<th>Deaths<th>HS</tr>");
    
iNumResults SQL_NumResults(Query);
    
    if(
iNumResults
    {
        for(new 
iiNumResultsi++)
        {
            
SQL_ReadResult(Query1PlayerName2charsmax(PlayerName2)), PlayerPoints SQL_ReadResult(Query3), AddCommas(PlayerPointsNumbercharsmax(Number));
            
iMOTDPos += format(string[iMOTDPos], charsmax(string)-iMOTDPos"<tr><td><img src='https://i.imgur.com/Rank%d.png'> %d<td>%s<td>%s<td>#<td>#<td>#</tr>"i+i+1PlayerName2Number);
            
SQL_NextRow(Query);
        }
    }
    
copy(string[iMOTDPos], charsmax(string)-iMOTDPos"</table><center><img src='https://i.imgur.com/XR2ZufG.png'></center></body></html>");
    
show_motd(idstring"PLOIESTI.LaLeagane.Ro");
    return 
PLUGIN_HANDLED;



Very interesting idea, but unfortunately is not working.
Considering that on imgur I cannot chose what the link name can be, I have put the pics into my webhost, named as you said.

https://i.imgur.com/ETTcnjS.jpg

Showing only 8 rows, I thing is because the
Code:

string[3036]
must be a bigger number right?

But what other option can you give me about the pictures? Because are not shown.

Thanks for your support.

Bugsy 05-02-2022 08:19

Re: Help with top15 MOTD
 
Replace each image name in the array with what it is named on the imgur site. When the code runs, it'll format it accordingly -- https://i.imgur.com/RankImg1.png, etc.

MOTD has a character limit of 1536, so you'll need to take that into consideration.

PHP Code:

new const RankImages[][] = 
{
    
"RankImg1.png",
    
"RankImg2.png",
    
"RankImg3.png",
    
"RankImg4.png",
    
"RankImg5.png",
    
"RankImg6.png",
    
"RankImg7.png",
    
"RankImg8.png",
    
"RankImg9.png",
    
"RankImg10.png",
    
"RankImg11.png",
    
"RankImg12.png",
    
"RankImg13.png",
    
"RankImg14.png",
    
"RankImg15.png"
};

public 
GiveTopInformation(FailStateHandle:QueryError[], ErrcodeDataPlayer[], DataSize)
{
    new 
idPlayerName2[32], Number[10], PlayerPointsiMOTDPosstring[3036], iNumResults;
    
    
id DataPlayer[0], string[0] = EOS;
    
iMOTDPos format(stringcharsmax(string), "<html><head><style>body{background:#FFF;font-family:Tahoma}th{background:#056B9E;color:#FFF;padding:3px;text-align:left;border-top:4px solid #3986AC}td{background:#CCCCCC;padding:2px 6px;border-bottom:1px dotted}table{color:#006699;background:#FFF;font-size:15px;border:2px solid #006699}</style></head><body><table width=100%% border=0 align=center cellpadding=0 cellspacing=1>");             
    
iMOTDPos += format(string[iMOTDPos], charsmax(string)-iMOTDPos"<center><img src='https://i.imgur.com/4kypRjN.png'></center><br/><tr><th>Rank<th>Nick<th>Points<th>Kills<th>Deaths<th>HS</tr>");
    
iNumResults SQL_NumResults(Query);
    
    if(
iNumResults
    {
        for(new 
iiNumResultsi++)
        {
            
SQL_ReadResult(Query1PlayerName2charsmax(PlayerName2)), PlayerPoints SQL_ReadResult(Query3), AddCommas(PlayerPointsNumbercharsmax(Number));
            
iMOTDPos += format(string[iMOTDPos], charsmax(string)-iMOTDPos"<tr><td><img src='https://i.imgur.com/%s'> %d<td>%s<td>%s<td>#<td>#<td>#</tr>"RankImages] , i+1PlayerName2Number);
            
SQL_NextRow(Query);
        }
    }
    
copy(string[iMOTDPos], charsmax(string)-iMOTDPos"</table><center><img src='https://i.imgur.com/XR2ZufG.png'></center></body></html>");
    
show_motd(idstring"PLOIESTI.LaLeagane.Ro");
    return 
PLUGIN_HANDLED;



maNIaRO 05-02-2022 09:51

Re: Help with top15 MOTD
 
Quote:

Originally Posted by Bugsy (Post 2778486)
Replace each image name in the array with what it is named on the imgur site. When the code runs, it'll format it accordingly -- https://i.imgur.com/RankImg1.png, etc.

MOTD has a character limit of 1536, so you'll need to take that into consideration.

PHP Code:

new const RankImages[][] = 
{
    
"RankImg1.png",
    
"RankImg2.png",
    
"RankImg3.png",
    
"RankImg4.png",
    
"RankImg5.png",
    
"RankImg6.png",
    
"RankImg7.png",
    
"RankImg8.png",
    
"RankImg9.png",
    
"RankImg10.png",
    
"RankImg11.png",
    
"RankImg12.png",
    
"RankImg13.png",
    
"RankImg14.png",
    
"RankImg15.png"
};

public 
GiveTopInformation(FailStateHandle:QueryError[], ErrcodeDataPlayer[], DataSize)
{
    new 
idPlayerName2[32], Number[10], PlayerPointsiMOTDPosstring[3036], iNumResults;
    
    
id DataPlayer[0], string[0] = EOS;
    
iMOTDPos format(stringcharsmax(string), "<html><head><style>body{background:#FFF;font-family:Tahoma}th{background:#056B9E;color:#FFF;padding:3px;text-align:left;border-top:4px solid #3986AC}td{background:#CCCCCC;padding:2px 6px;border-bottom:1px dotted}table{color:#006699;background:#FFF;font-size:15px;border:2px solid #006699}</style></head><body><table width=100%% border=0 align=center cellpadding=0 cellspacing=1>");             
    
iMOTDPos += format(string[iMOTDPos], charsmax(string)-iMOTDPos"<center><img src='https://i.imgur.com/4kypRjN.png'></center><br/><tr><th>Rank<th>Nick<th>Points<th>Kills<th>Deaths<th>HS</tr>");
    
iNumResults SQL_NumResults(Query);
    
    if(
iNumResults
    {
        for(new 
iiNumResultsi++)
        {
            
SQL_ReadResult(Query1PlayerName2charsmax(PlayerName2)), PlayerPoints SQL_ReadResult(Query3), AddCommas(PlayerPointsNumbercharsmax(Number));
            
iMOTDPos += format(string[iMOTDPos], charsmax(string)-iMOTDPos"<tr><td><img src='https://i.imgur.com/%s'> %d<td>%s<td>%s<td>#<td>#<td>#</tr>"RankImages] , i+1PlayerName2Number);
            
SQL_NextRow(Query);
        }
    }
    
copy(string[iMOTDPos], charsmax(string)-iMOTDPos"</table><center><img src='https://i.imgur.com/XR2ZufG.png'></center></body></html>");
    
show_motd(idstring"PLOIESTI.LaLeagane.Ro");
    return 
PLUGIN_HANDLED;



Thank you, i will try this option.
Character limit 1536 is maximum for MOTD? Where does it start the counting and where it ends? So in case of showing issues, maybe I can delete some unnecesary rows/columns/text.
Thanks

maNIaRO 05-02-2022 10:24

Re: Help with top15 MOTD
 
Excuse me, but maybe I didn't understood correctly.
Where exactly should I put the imgur links ? :? ...

You mean like this?
https://i.imgur.com/OkjkJUI.jpg

LE. I did it, but doesn't work.
PHP Code:

new const RankImages[][] = 
{
    
"https://i.imgur.com/TNGjSQ1.png",
    
"https://i.imgur.com/3JMJRgP.png",
    
"https://i.imgur.com/XZFnqci.png",
    
"https://i.imgur.com/vQGI3JF.png",
    
"https://i.imgur.com/xarhxL1.png",
    
"https://i.imgur.com/2fYpWcP.png",
    
"https://i.imgur.com/ht9qRjQ.png",
    
"https://i.imgur.com/dNDSg2z.png",
    
"https://i.imgur.com/PV23Sth.png",
    
"https://i.imgur.com/HpnJVGF.png",
    
"https://i.imgur.com/BAsfFx2.png",
    
"https://i.imgur.com/mmxeQs3.png",
    
"https://i.imgur.com/R0My8PY.png",
    
"https://i.imgur.com/TXQiM4t.png",
    
"https://i.imgur.com/jmzaSum.png"
};

public 
GiveTopInformation(FailStateHandle:QueryError[], ErrcodeDataPlayer[], DataSize)
{
    new 
idPlayerName2[32], Number[10], Number2[10], Number3[10], Number4[10], PlayerPointsPlayerKillsPlayerDeathsPlayerHsiMOTDPosstring[3036], iNumResults;
    
    
id DataPlayer[0], string[0] = EOS;
    
iMOTDPos format(stringcharsmax(string), "<html><head><style>body{background:#FFF;font-family:Tahoma}th{background:#056B9E;color:#FFF;padding:3px;text-align:left;border-top:4px solid #3986AC}td{background:#CCCCCC;padding:2px 6px;border-bottom:1px dotted}table{color:#006699;background:#FFF;font-size:15px;border:2px solid #006699}</style></head><body><table width=100%% border=0 align=center cellpadding=0 cellspacing=1>");             
    
iMOTDPos += format(string[iMOTDPos], charsmax(string)-iMOTDPos"<center><img src='https://i.imgur.com/4kypRjN.png'></center><br/><tr><th>Rank<th>Nick<th>Points<th>Kills<th>Deaths<th>HS</tr>");
    
iNumResults SQL_NumResults(Query);

    if(
iNumResults
    {
        for(new 
iiNumResultsi++)
        {
            
SQL_ReadResult(Query1PlayerName2charsmax(PlayerName2)), PlayerPoints SQL_ReadResult(Query3), PlayerKills SQL_ReadResult(Query4), PlayerDeaths SQL_ReadResult(Query5), PlayerHs SQL_ReadResult(Query6), 
            
AddCommas(PlayerPointsNumbercharsmax(Number)), AddCommas(PlayerKillsNumber2charsmax(Number2)), AddCommas(PlayerDeathsNumber3charsmax(Number3)), AddCommas(PlayerHsNumber4charsmax(Number4));
            
iMOTDPos += format(string[iMOTDPos], charsmax(string)-iMOTDPos"<tr><td><img src='https://i.imgur.com/%s'> %d<td>%s<td>%s<td>%s<td>%s<td>%s</tr>"RankImages], i+1PlayerName2NumberNumber2Number3Number4);
            
SQL_NextRow(Query);
        }
    }
    
copy(string[iMOTDPos], charsmax(string)-iMOTDPos"</table><center><img src='https://i.imgur.com/XR2ZufG.png'></center></body></html>");
    
show_motd(idstring"[PLOIESTI] Top 15 Players");
    return 
PLUGIN_HANDLED;


Don't worry anymore. It seems that this is how suppose to be if is not working. I will leave it without images, it was fancy though, but ..

Thank again for your support.

Bugsy 05-02-2022 13:02

Re: Help with top15 MOTD
 
I already accounted for the http part in the formatex, the array should have only the image name, as I showed you in the code: dhhwhsh.png

With what you did, the image is getting formated as:

"https://i.imgur.com/https://i.imgur.com/TNGjSQ1.png"
Which obviously will not work

maNIaRO 05-04-2022 12:30

Re: Help with top15 MOTD
 
Quote:

Originally Posted by Bugsy (Post 2778496)
I already accounted for the http part in the formatex, the array should have only the image name, as I showed you in the code: dhhwhsh.png

With what you did, the image is getting formated as:

"https://i.imgur.com/https://i.imgur.com/TNGjSQ1.png"
Which obviously will not work

Thanks a lot Bugsy for your help.
It looks pretty nice for me.
https://i.imgur.com/yGLYSxA.jpg

Because of the images, not enough string for all top15, but top10 should be ok as well :D

Bugsy 05-04-2022 14:09

Re: Help with top15 MOTD
 
I'd adjust the rank column width, and maybe center points, kills, deaths

maNIaRO 05-05-2022 00:42

Re: Help with top15 MOTD
 
Quote:

Originally Posted by Bugsy (Post 2778651)
I'd adjust the rank column width, and maybe center points, kills, deaths

I did already that, after my last post, with <th width=15%> to all columns, except Nick.


All times are GMT -4. The time now is 21:23.

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