AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   show rank on connection (https://forums.alliedmods.net/showthread.php?t=325589)

The RaiD. 06-28-2020 09:10

show rank on connection
 
Hello can someone edit this plugin, i want that this plugin shows the rankstats too from connected player example: Player connected. [Rank 20]. (using StatsX Shell plugin)
Code:

#include <amxmodx>

#define        PLUGIN        "Connect Announce"
#define        VERSION        "0.2"
#define        AUTHOR        "v3x"

new g_iMsgSayText, g_szSoundFile[] = "buttons/blip1.wav";

public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR);
        g_iMsgSayText = get_user_msgid("SayText");
}

public plugin_precache()
{
        precache_sound(g_szSoundFile);
}

public client_authorized(id)
{
        if(is_user_bot(id)) return PLUGIN_CONTINUE;

        new szUserName[33];
        get_user_name(id, szUserName, 32);

        new szAuthID[33];
        get_user_authid(id , szAuthID , 32);

        new iPlayers[32], iNum, i;
        get_players(iPlayers, iNum);

        for(i = 0; i <= iNum; i++)
        {
                new x = iPlayers[i];

                if(!is_user_connected(x) || is_user_bot(x)) continue;

                client_cmd(x, "spk %s", g_szSoundFile);

                new szMessage[164];
                format(szMessage, 163, "^x04%s (^x01%s^x04) connected", szUserName , szAuthID);

                message_begin( MSG_ONE, g_iMsgSayText, {0,0,0}, x );
                write_byte  ( x );
                write_string( szMessage );
                message_end ();
        }

        return PLUGIN_CONTINUE;
}


alferd 06-28-2020 12:47

Re: show rank on connection
 
Code:
#include <amxmodx> #include <csstats> #define PLUGIN   "Connect Announce" #define VERSION  "0.2" #define AUTHOR   "v3x" new g_iMsgSayText, g_szSoundFile[] = "buttons/blip1.wav"; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     g_iMsgSayText = get_user_msgid("SayText"); } public plugin_precache() {     precache_sound(g_szSoundFile); } public client_authorized(id) {     if(is_user_bot(id)) return PLUGIN_CONTINUE;     new szUserName[33];     get_user_name(id, szUserName, 32);     new szAuthID[33];     get_user_authid(id , szAuthID , 32);     new iPlayers[32], iNum, i;     get_players(iPlayers, iNum);     for(i = 0; i <= iNum; i++)     {         new x = iPlayers[i];         if(!is_user_connected(x) || is_user_bot(x)) continue;         client_cmd(x, "spk %s", g_szSoundFile);                 new szRank;         new szStats[8];         new szBody[8];                 szRank = get_user_stats(id, szStats, szBody);         new szMessage[164];         format(szMessage, 163, "^x04%s ^x01Rank^x04:^x04[^x01%d^x04] (^x01%s^x04) connected", szUserName , szRank, szAuthID);         message_begin( MSG_ONE, g_iMsgSayText, {0,0,0}, x );         write_byte  ( x );         write_string( szMessage );         message_end ();     }     return PLUGIN_CONTINUE; }

The RaiD. 06-28-2020 13:47

Re: show rank on connection
 
i have many errors i cant compile it
undefined smybol iRank
expression has not effect
expected token ";" but found "
too many error messages on one line

alferd 06-28-2020 14:35

Re: show rank on connection
 
fixed

The RaiD. 06-28-2020 16:53

Re: show rank on connection
 
it works now but if someone connects it shows always Rank: 0 on all Players ..

ZaX 06-28-2020 17:34

Re: show rank on connection
 
Code:
#include <amxmodx> #include <csx>   #define PLUGIN "Connect Announce" #define VERSION "0.2" #define AUTHOR "v3x" new g_iMsgSayText ,g_szSoundFile[] = "buttons/blip1.wav";   public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);     g_iMsgSayText = get_user_msgid("SayText"); }   public plugin_precache() {     precache_sound(g_szSoundFile); }   public client_connect(id) {     set_task(0.5, "client_joined", id); } public client_joined(id) {     if(is_user_bot(id))     {         return PLUGIN_CONTINUE;     }       new szUserName[33];     get_user_name(id, szUserName, 32);       new szAuthID[33];     get_user_authid(id, szAuthID, 32);       new izStats[8], izBody[8];     new iRankPos = get_user_stats(id, izStats, izBody);     new iRankMax = get_statsnum();        new iPlayers[32], iNum, i;     get_players(iPlayers, iNum);     for(i = 0; i <= iNum; i++)     {         new x = iPlayers[i];           if(!is_user_connected(x) || is_user_bot(x))         {             continue;         }           client_cmd(x, "spk %s", g_szSoundFile);           new szMessage[164];         format(szMessage, 163, "^x04%s (^x01%s^x04) connected ^x01(RANK: %d of %d)", szUserName, szAuthID, iRankPos, iRankMax);           message_begin(MSG_ONE, g_iMsgSayText, {0,0,0}, x);         write_byte(x);         write_string(szMessage);         message_end();     }       return PLUGIN_CONTINUE; }

The RaiD. 06-28-2020 17:48

Re: show rank on connection
 
G | S.W.A.T (STEAM_1:0:2121689914) connected (RANK: 0 of 11129) still same rank 0

iceeedr 06-28-2020 19:33

Re: show rank on connection
 
The rank is only updated after the player spawns, use a task of 0.5 to guarantee and everything is fine.

The RaiD. 06-29-2020 03:41

Re: show rank on connection
 
there is already a task of 0.5 but still the same problem

Supremache 06-29-2020 04:20

Re: show rank on connection
 
Quote:

Originally Posted by The RaiD. (Post 2707768)
there is already a task of 0.5 but still the same problem

Try This:
PHP Code:

#include <amxmodx>
#include <csstats>


public plugin_init() 
{
    
register_plugin("InfoMessage""1.0""MrAbdoO");
}

public 
client_putinserver(iPlayer)
{
    
set_task(8.0"go_info"iPlayer""0""0);
}

public 
go_info(id)
{
    new 
stats], body], szName32 ], szAuth32 ];
    new 
rank_pos get_user_statsidstatsbody )
    new 
rank_max get_statsnum( )
    
get_user_nameidszName31 )
    
get_user_authid(id szAuth 31)
    
ChatColor(0"!tPlayer !t%s !g(%s) !nhas connected to server. Rank is !g%d!nfrom !g%d!n."szNameszAuthrank_posrank_max);
    return 
0;
}

// Colour Chat
stock ChatColor(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);
    
    
replace_all(msg190"!g""^x04"); // Green Color
    
replace_all(msg190"!n""^x01"); // Default Color
    
replace_all(msg190"!t""^x03"); // Team Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch");
    
    for (new 
0counti++)
    {
        if (
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);
            
write_byte(players[i]);
            
write_string(msg);
            
message_end();
        }
    }




All times are GMT -4. The time now is 22:20.

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