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

motd prints all playing players in rows


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-05-2019 , 07:45   motd prints all playing players in rows
Reply With Quote #1

Hello, what am I missing here? I would like to print all players into motd, this is the code:

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

#include <amxmodx>

new player_name[33][64];
new g_maxplayers;

public plugin_init() {
	register_clcmd("say /hraci", "player_skills");
	g_maxplayers = get_maxplayers();
}

public client_connect(id)
{
	get_user_name(id, player_name[id], 63);
}	
	
public player_skills(id){
		
	new message[2048]
	new formats[128]

	add(message,2047,"<HTML><head></head><body bgcolor=#000000><font color=#FFB000>")

	for (id=1; id<=g_maxplayers; id++) {
		format(formats, 127, "%s",  player_name[id])
	}
	return PLUGIN_HANDLED
}
TheBladerX is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-05-2019 , 08:44   Re: motd prints all playing players in rows
Reply With Quote #2

You're adding the players in the string "formats", but you're not using the string anywhere.
__________________

Last edited by OciXCrom; 02-05-2019 at 08:44.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 02-05-2019 , 08:50   Re: motd prints all playing players in rows
Reply With Quote #3

To begin with, the name is a string limited to 32 characters, not 64. Use charsmax () as a good practice. Did you create motd where?
__________________


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-05-2019 , 09:35   Re: motd prints all playing players in rows
Reply With Quote #4

Code:
new player_name[33][32];

format(formats, charsmax(player_name), "%s",  player_name[id])
Like this?

.. I mean, wouldn't this open a motd? Not like file.txt but these values in it.

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

PHP Code:
#include <amxmodx>
#include <amxmisc>

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], iPlayerCount;
    
get_players_ex(iPlayersiPlayerCountGetPlayers_ExcludeHLTV|GetPlayers_ExcludeBots);

    for(new 
iiPlayerCounti++)
        
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen"%n<br>"iPlayers[i]);

    
show_motd(idszMessage"Info players");
    return 
PLUGIN_HANDLED;

__________________

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

Code:
iLen += formatex(szMessage, charsmax(szMessage) - iLen, "%n", iPlayers[i]);

Code:
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen, "%n<br>", iPlayers[i]);
__________________









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

Quote:
Originally Posted by CrazY. View Post
Code:
iLen += formatex(szMessage, charsmax(szMessage) - iLen, "%n", iPlayers[i]);

Code:
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen, "%n<br>", iPlayers[i]);
I don't understand the szMessage[iLen] part.

Last edited by DjSoftero; 02-05-2019 at 16:20. Reason: nvm
DjSoftero is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 02-05-2019 , 15:44   Re: motd prints all playing players in rows
Reply With Quote #8

I dont understand %n part
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
eat1k
Senior Member
Join Date: Apr 2018
Old 02-05-2019 , 15:47   Re: motd prints all playing players in rows
Reply With Quote #9

Quote:
Originally Posted by CrazY. View Post
Code:
iLen += formatex(szMessage, charsmax(szMessage) - iLen, "%n", iPlayers[i]);

Code:
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen, "%n<br>", iPlayers[i]);
Yeah, thanks! Fixed. I forgot it.

Quote:
Originally Posted by JocAnis View Post
I dont understand %n part
The nickname of the player. Check this - https://github.com/alliedmodders/amxmodx/pull/93
__________________
eat1k is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 02-05-2019 , 15:48   Re: motd prints all playing players in rows
Reply With Quote #10

He wrote whole plugin in Amx 1.9 %n automatically catch user_name of the id, in case 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
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 15:29.


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