AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   motd prints all playing players in rows (https://forums.alliedmods.net/showthread.php?t=314142)

TheBladerX 02-05-2019 07:45

motd prints all playing players in rows
 
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
}


OciXCrom 02-05-2019 08:44

Re: motd prints all playing players in rows
 
You're adding the players in the string "formats", but you're not using the string anywhere.

iceeedr 02-05-2019 08:50

Re: motd prints all playing players in rows
 
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?

TheBladerX 02-05-2019 09:35

Re: motd prints all playing players in rows
 
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.

eat1k 02-05-2019 14:58

Re: motd prints all playing players in rows
 
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;



CrazY. 02-05-2019 15:13

Re: motd prints all playing players in rows
 
Code:
iLen += formatex(szMessage, charsmax(szMessage) - iLen, "%n", iPlayers[i]);
:arrow:
Code:
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen, "%n<br>", iPlayers[i]);

DjSoftero 02-05-2019 15:30

Re: motd prints all playing players in rows
 
Quote:

Originally Posted by CrazY. (Post 2638322)
Code:
iLen += formatex(szMessage, charsmax(szMessage) - iLen, "%n", iPlayers[i]);
:arrow:
Code:
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen, "%n<br>", iPlayers[i]);

I don't understand the szMessage[iLen] part.

JocAnis 02-05-2019 15:44

Re: motd prints all playing players in rows
 
I dont understand %n part

eat1k 02-05-2019 15:47

Re: motd prints all playing players in rows
 
Quote:

Originally Posted by CrazY. (Post 2638322)
Code:
iLen += formatex(szMessage, charsmax(szMessage) - iLen, "%n", iPlayers[i]);
:arrow:
Code:
iLen += formatex(szMessage[iLen], charsmax(szMessage) - iLen, "%n<br>", iPlayers[i]);

Yeah, thanks! Fixed. I forgot it.

Quote:

Originally Posted by JocAnis (Post 2638326)
I dont understand %n part

The nickname of the player. Check this - https://github.com/alliedmodders/amxmodx/pull/93

iceeedr 02-05-2019 15:48

Re: motd prints all playing players in rows
 
He wrote whole plugin in Amx 1.9 %n automatically catch user_name of the id, in case iplayers[i]


All times are GMT -4. The time now is 07:30.

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