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

motd prints all playing players in rows


Post New Thread Reply   
 
Thread Tools Display Modes
eat1k
Senior Member
Join Date: Apr 2018
Old 02-06-2019 , 16:08   Re: motd prints all playing players in rows
Reply With Quote #21

Quote:
Originally Posted by iceeedr View Post
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 
It's easier as I said. Using the method you gave will throw errors depending on the build of AMXX. MAX_PLAYERS was introduced in AMXX 1.8.3, not AMXX 1.8.2. So it's not right to use it like that.
__________________
eat1k is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-06-2019 , 16:09   Re: motd prints all playing players in rows
Reply With Quote #22

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;

Okay, I have a problem with this one too. It seems like "i" goes from -1, which is impossible. Every time I try to add player_class[i] as another string, it shows player's class, which is after this person, if I try [i+1], it does not show the last one. When I try [i], it does not show the first one. I don't get it. Even if I try to add [j] as new, it does not show correctly. And also I use bots to test it. I do not know, if that can cause the problem.

Last edited by TheBladerX; 02-06-2019 at 16:09.
TheBladerX is offline
eat1k
Senior Member
Join Date: Apr 2018
Old 02-06-2019 , 16:16   Re: motd prints all playing players in rows
Reply With Quote #23

Quote:
Originally Posted by TheBladerX View Post
Okay, I have a problem with this one too. It seems like "i" goes from -1, which is impossible. Every time I try to add player_class[i] as another string, it shows player's class, which is after this person, if I try [i+1], it does not show the last one. When I try [i], it does not show the first one. I don't get it. Even if I try to add [j] as new, it does not show correctly. And also I use bots to test it. I do not know, if that can cause the problem.
Show the code you're trying to use.
__________________
eat1k is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-06-2019 , 16:23   Re: motd prints all playing players in rows
Reply With Quote #24

Quote:
Originally Posted by eat1k View Post
Show the code you're trying to use.
PHP Code:
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_PLAYER], iPlayerCountszName[MAX_NAME_LENGTH]; 
    
get_players(iPlayersiPlayerCount"hi"); 
     
    for(new 
iiPlayerCounti++) 
    { 
    
get_user_name(iPlayers[i], szNamecharsmax(szName)); 
    
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen"%s - %s (%i)<br>"szNameclass_name[player_class[i]], player_level[i]);
    }
    
     
    
show_motd(idszMessage"Triedy hracov"); 
    return 
PLUGIN_HANDLED

if I add player_name[i] as string to display in motd, which I mainly use for names in this plugin, it shows one person after szName.

Last edited by TheBladerX; 02-06-2019 at 16:23.
TheBladerX is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 02-06-2019 , 16:23   Re: motd prints all playing players in rows
Reply With Quote #25

Quote:
Originally Posted by eat1k View Post
It's easier as I said. Using the method you gave will throw errors depending on the build of AMXX. MAX_PLAYERS was introduced in AMXX 1.8.3, not AMXX 1.8.2. So it's not right to use it like that.
I'd rather assume that people use the last build thrown ... but looking at it all, I give you reason.
__________________


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/
iceeedr is offline
Send a message via Skype™ to iceeedr
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 02-06-2019 , 16:25   Re: motd prints all playing players in rows
Reply With Quote #26

Quote:
Originally Posted by TheBladerX View Post
PHP Code:
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_PLAYER], iPlayerCountszName[MAX_NAME_LENGTH]; 
    
get_players(iPlayersiPlayerCount"hi"); 
     
    for(new 
iiPlayerCounti++) 
    { 
    
get_user_name(iPlayers[i], szNamecharsmax(szName)); 
    
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen"%s - %s (%i)<br>"szNameclass_name[player_class[i]], player_level[i]);
    }
    
     
    
show_motd(idszMessage"Triedy hracov"); 
    return 
PLUGIN_HANDLED

if I add player_name[i] as string to display in motd, which I mainly use for names in this plugin, it shows one person after szName.
Give a shot

PHP Code:
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen"%s - %s (%i)<br>"szNameclass_name[player_class[iPlayers[i]]], player_level[iPlayers[i]]) 
__________________


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/
iceeedr is offline
Send a message via Skype™ to iceeedr
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-06-2019 , 16:29   Re: motd prints all playing players in rows
Reply With Quote #27

Quote:
Originally Posted by iceeedr View Post
Give a shot

PHP Code:
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen"%s - %s (%i)<br>"szNameclass_name[player_class[iPlayers[i]]], player_level[iPlayers[i]]) 
That was the issue all the time ffs Thank you all. Solved.
TheBladerX is offline
eat1k
Senior Member
Join Date: Apr 2018
Old 02-06-2019 , 16:33   Re: motd prints all playing players in rows
Reply With Quote #28

Change the for() to:
PHP Code:
for(new iiPlayeriPlayerCounti++)  
{
    
iPlayer iPlayers[i];

    
get_user_name(iPlayerszNamecharsmax(szName));  
    
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen"%s - %s (%i)<br>"szNameclass_name[player_class[iPlayer]], player_level[iPlayer]);

__________________
eat1k 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 13:49.


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