Raised This Month: $32 Target: $400
 8% 

motd prints all playing players in rows


Post New Thread Reply   
 
Thread Tools Display Modes
thEsp
BANNED
Join Date: Aug 2017
Old 02-05-2019 , 15:51   Re: motd prints all playing players in rows
Reply With Quote #11

This works somewhat

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /allplayers","ShowMOTD")
}

public 
ShowMOTD(id)
{
    new 
iPlayers get_playersnum()
    new 
msgmotd[2048]
    for (new 
0;i<=iPlayers;i++)
    {
        new 
id_name[32]
        
get_user_name(i,id_name,charsmax(id_name))
        new 
htmlcode[256]
        
formatex(htmlcode,charsmax(htmlcode),"<HTML><head></head><body bgcolor=#000000>%s<font color=#FFB000>",id_name)
        
add(msgmotd,charsmax(msgmotd),htmlcode)
    }
    
show_motd(id,msgmotd,"Test")


Last edited by thEsp; 02-05-2019 at 15:52.
thEsp is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 02-05-2019 , 16:37   Re: motd prints all playing players in rows
Reply With Quote #12

Quote:
Originally Posted by DjSoftero View Post
I don't understand the szMessage[iLen] part.
Well, it "copy" the string to the variable from its "free space", otherwise the already stored string would be replaced.

Code:
new szText[5], iLen; iLen = copy(szText, charsmax(szText), "abc"); // So, we have // iLen = 3 (3 chars, abc) // szText[0] would be "a" // szText[1] would be "b" // szText[2] would be "c" // szText[iLen] would be "", could be represented by szText[3] in that example copy(szText[iLen], charsmax(szText) - iLen, "de"); // Now, szText[3] would be "d" and szText[4] would be "e" // Basically we have now // szText[0] = "a" // szText[1] = "b" // szText[2] = "c" // szText[3] = "d" // szText[4] = "e" // Instead of // szText[0] = "a" // szText[1] = "b" // szText[2] = "c" // szText[3] = "" // szText[4] = ""

It's a method similar to the add so to say, but we can format the string.
https://www.amxmodx.org/api/string/add

Someone else may give you a better explanation.
__________________









Last edited by CrazY.; 02-05-2019 at 16:56.
CrazY. is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-05-2019 , 17:09   Re: motd prints all playing players in rows
Reply With Quote #13

None of these you all sent worked properly. Unfortunately, I do not use amxmodx 1.9, however I still have 1.8.2.

edit:
sorry, this one worked.

Quote:
Originally Posted by thEsp View Post
This works somewhat

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /allplayers","ShowMOTD")
}

public 
ShowMOTD(id)
{
    new 
iPlayers get_playersnum()
    new 
msgmotd[2048]
    for (new 
0;i<=iPlayers;i++)
    {
        new 
id_name[32]
        
get_user_name(i,id_name,charsmax(id_name))
        new 
htmlcode[256]
        
formatex(htmlcode,charsmax(htmlcode),"<HTML><head></head><body bgcolor=#000000>%s<font color=#FFB000>",id_name)
        
add(msgmotd,charsmax(msgmotd),htmlcode)
    }
    
show_motd(id,msgmotd,"Test")

Thanks.

Last edited by TheBladerX; 02-05-2019 at 17:26.
TheBladerX is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 02-06-2019 , 10:19   Re: motd prints all playing players in rows
Reply With Quote #14

Quote:
Originally Posted by CrazY. View Post
Well, it "copy" the string to the variable from its "free space", otherwise the already stored string would be replaced.

Code:
new szText[5], iLen; iLen = copy(szText, charsmax(szText), "abc"); // So, we have // iLen = 3 (3 chars, abc) // szText[0] would be "a" // szText[1] would be "b" // szText[2] would be "c" // szText[iLen] would be "", could be represented by szText[3] in that example copy(szText[iLen], charsmax(szText) - iLen, "de"); // Now, szText[3] would be "d" and szText[4] would be "e" // Basically we have now // szText[0] = "a" // szText[1] = "b" // szText[2] = "c" // szText[3] = "d" // szText[4] = "e" // Instead of // szText[0] = "a" // szText[1] = "b" // szText[2] = "c" // szText[3] = "" // szText[4] = ""

It's a method similar to the add so to say, but we can format the string.
https://www.amxmodx.org/api/string/add

Someone else may give you a better explanation.
I'm grateful to you for an explanation.

Last edited by DjSoftero; 02-06-2019 at 10:28.
DjSoftero is offline
shauli
Member
Join Date: Jun 2018
Old 02-06-2019 , 13:14   Re: motd prints all playing players in rows
Reply With Quote #15

Quote:
Originally Posted by TheBladerX View Post
None of these you all sent worked properly. Unfortunately, I do not use amxmodx 1.9, however I still have 1.8.2.

edit:
sorry, this one worked.

Thanks.
This one has many problems. It's probably works fine when you test it alone but no way it will work when your server is full. It doesn't check all players.

You should use the one eat1k posted. Try this in 1.8.2:
PHP Code:
#include <amxmodx>
#include <amxmisc>

#define MAX_MOTD_LENGTH 1536
#define MAX_PLAYERS 32
#define MAX_NAME_LENGTH 32

public plugin_init()
{
    
register_clcmd("say /hraci""player_skills");
}

public 
player_skills(id)
{
    new 
szMessage[MAX_MOTD_LENGTH], iLen;
    
    
iLen formatex(szMessagecharsmax(szMessage), "<HTML><head></head><body bgcolor=#000000><font color=#FFB000>");
    
    new 
iPlayers[MAX_PLAYERS], iPlayerCountszName[MAX_NAME_LENGTH];
    
get_players(iPlayersiPlayerCount"ch");
    
    for(new 
iiPlayerCounti++)
    {
        
get_user_name(iPlayers[i], szNamecharsmax(szName));
        
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen"%s<br>"szName);
    }
    
    
show_motd(idszMessage"Info players");
    return 
PLUGIN_HANDLED;

shauli is offline
eat1k
Senior Member
Join Date: Apr 2018
Old 02-06-2019 , 14:01   Re: motd prints all playing players in rows
Reply With Quote #16

Better:

PHP Code:
#if !defined MAX_PLAYERS
    #define MAX_PLAYERS 32
#endif

#if !defined MAX_NAME_LENGTH
    #define MAX_NAME_LENGTH 32
#endif

#if !defined MAX_MOTD_LENGTH
    #define MAX_MOTD_LENGTH 1536
#endif 
__________________

Last edited by eat1k; 02-06-2019 at 14:01.
eat1k is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-06-2019 , 14:28   Re: motd prints all playing players in rows
Reply With Quote #17

Quote:
Originally Posted by shauli View Post
This one has many problems. It's probably works fine when you test it alone but no way it will work when your server is full. It doesn't check all players.

You should use the one eat1k posted. Try this in 1.8.2:
PHP Code:
#include <amxmodx>
#include <amxmisc>

#define MAX_MOTD_LENGTH 1536
#define MAX_PLAYERS 32
#define MAX_NAME_LENGTH 32

public plugin_init()
{
    
register_clcmd("say /hraci""player_skills");
}

public 
player_skills(id)
{
    new 
szMessage[MAX_MOTD_LENGTH], iLen;
    
    
iLen formatex(szMessagecharsmax(szMessage), "<HTML><head></head><body bgcolor=#000000><font color=#FFB000>");
    
    new 
iPlayers[MAX_PLAYERS], iPlayerCountszName[MAX_NAME_LENGTH];
    
get_players(iPlayersiPlayerCount"ch");
    
    for(new 
iiPlayerCounti++)
    {
        
get_user_name(iPlayers[i], szNamecharsmax(szName));
        
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen"%s<br>"szName);
    }
    
    
show_motd(idszMessage"Info players");
    return 
PLUGIN_HANDLED;

Yes, unfortunately I found some bugs, but I managed to fix them on my own, however I already bothered you all too many times. This one works perfectly, thank you many times.

Quote:
Originally Posted by eat1k View Post
Better:

PHP Code:
#if !defined MAX_PLAYERS
    #define MAX_PLAYERS 32
#endif

#if !defined MAX_NAME_LENGTH
    #define MAX_NAME_LENGTH 32
#endif

#if !defined MAX_MOTD_LENGTH
    #define MAX_MOTD_LENGTH 1536
#endif 
What exactly does this one do? I mean what are the advantages?

Last edited by TheBladerX; 02-06-2019 at 14:30.
TheBladerX is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 02-06-2019 , 14:40   Re: motd prints all playing players in rows
Reply With Quote #18

Quote:
Originally Posted by TheBladerX View Post
What exactly does this one do? I mean what are the advantages?
Everyone is saying how 1.8.3 version doesnt have the includes and 1.9 or whatever version has.
the code checks if variable exists. if it does, then cool. if it doesn't, then it gets defined.
DjSoftero is offline
eat1k
Senior Member
Join Date: Apr 2018
Old 02-06-2019 , 14:49   Re: motd prints all playing players in rows
Reply With Quote #19

Quote:
Originally Posted by TheBladerX View Post
What exactly does this one do? I mean what are the advantages?
It keeps compatibility. So it will work both in AMXX 1.8.2 and in AMXX 1.10.0. Because these defines were already introduced in AMXX 1.9.0.
__________________

Last edited by eat1k; 02-06-2019 at 14:50.
eat1k is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 02-06-2019 , 15:59   Re: motd prints all playing players in rows
Reply With Quote #20

Quote:
Originally Posted by eat1k View Post
It keeps compatibility. So it will work both in AMXX 1.8.2 and in AMXX 1.10.0. Because these defines were already introduced in AMXX 1.9.0.
I am almost sure that it is only necessary to check first, since by obvious if you have not defined max_players we can already establish that it is not amxx > 1.8.2

PHP Code:
#if !defined MAX_PLAYERS
    #define MAX_PLAYERS 32
    #define MAX_NAME_LENGTH 32
    #define MAX_MOTD_LENGTH 1536
#endif 
Or, check directly the version of amxx

PHP Code:
#if AMXX_VERSION_NUM < 190
    #define MAX_PLAYERS 32
    #define MAX_NAME_LENGTH 32
    #define MAX_MOTD_LENGTH 1536
#endif 
__________________


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/

Last edited by iceeedr; 02-06-2019 at 16:01.
iceeedr is offline
Send a message via Skype™ to iceeedr
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 21:57.


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