AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [REQ] Tag Admin (https://forums.alliedmods.net/showthread.php?t=241070)

plazma 05-27-2014 09:05

[REQ] Tag Admin
 
How to make this ex:

in file .ini


plazma = Tag Here
Plazzma 123 = Tag Here


sma

PHP Code:

#include < amxmodx >
#include < amxmisc >
#include < cstrike >

new g_iMsgID_SayText;

new 
g_iAdminChatFlag ADMIN_ALL;

new 
g_szTags[5][10];
new 
Trie:g_tSteamTagIndex;
new 
g_iPlayerTag[33]

public 
plugin_init( )
{
    
register_plugin("pepe_thugs Chat Tags""0.2""Fysiks")
    
register_clcmd"say""CmdSay" );
    
register_clcmd"say_team""CmdSayTeam" );
    
    
g_iMsgID_SayText get_user_msgid"SayText" );
    
    new 
szCommand32 ], iFlags;
    for( new 
0get_concmdiszCommandcharsmaxszCommand ), iFlags""00, -); i++ )
    {
        if( 
equalszCommand"amx_chat" ) )
        {
            
g_iAdminChatFlag iFlags;
            break;
        }
    }
    
    
g_tSteamTagIndex TrieCreate();
    
loadTags();
}

public 
client_connect(id)
{
    
g_iPlayerTag[id] = 0;
}

public 
client_authorized(id)
{
    new 
szSteamID[32];
    
get_user_authid(idszSteamIDcharsmax(szSteamID));
    
TrieGetCell(g_tSteamTagIndexszSteamIDg_iPlayerTag[id] )
}

public 
CmdSayiPlayer )
{
    if( !
g_iPlayerTag[iPlayer] )
    {
        return 
PLUGIN_CONTINUE;
    }

    if( !
is_user_connectediPlayer ) )
    {
        return 
PLUGIN_HANDLED_MAIN;
    }
    
    new 
szArgs194 ];
    
    if( !
IsValidMessageiPlayerfalseszArgscharsmaxszArgs ) ) )
    {
        return 
PLUGIN_HANDLED_MAIN;
    }
    
    new 
iAlive is_user_aliveiPlayer );
    new 
CsTeams:iTeam cs_get_user_teamiPlayer );
    
    new 
iPlayers32 ], iNum;
    
get_playersiPlayersiNum );
    
    new 
szName32 ];
    
get_user_nameiPlayerszNamecharsmaxszName ) );
    
    new const 
szPrefixes][ CsTeams ][ ] =
    {
        {
            
"^1*DEAD* ",
            
"^1*DEAD* ",
            
"^1*DEAD* ",
            
"^1*SPEC* "
        
},
        {
            
"",
            
"",
            
"",
            
""
        
}
    };
    
    new 
szMessage192 ];
    
formatexszMessagecharsmaxszMessage ), "^4%s ^1%s^3%s^1 :  %s"g_szTags[g_iPlayerTag[iPlayer]], szPrefixesiAlive ][ iTeam ], szNameszArgs );
    
    new 
iTarget;
    for( new 
0iNumi++ )
    {
        
iTarget iPlayers];
        
        if( 
iTarget == iPlayer || ( iAlive || is_user_connectediTarget ) ) && is_user_aliveiTarget ) == iAlive )
        {
            
message_beginMSG_ONE_UNRELIABLEg_iMsgID_SayText_iTarget );
            
write_byteiPlayer );
            
write_stringszMessage );
            
message_end( );
        }
    }
    
    return 
PLUGIN_HANDLED_MAIN;
}

public 
CmdSayTeamiPlayer )
{
    if( !
g_iPlayerTag[iPlayer] )
    {
        return 
PLUGIN_CONTINUE;
    }

    if( !
is_user_connectediPlayer ) )
    {
        return 
PLUGIN_HANDLED_MAIN;
    }
    
    new 
szArgs194 ];
    
    if( !
IsValidMessageiPlayertrueszArgscharsmaxszArgs ) ) )
    {
        return 
PLUGIN_HANDLED_MAIN;
    }
    
    new 
iAlive is_user_aliveiPlayer );
    new 
CsTeams:iTeam CsTeams:( ( _:cs_get_user_teamiPlayer ) ) % );
    
    new 
iPlayers32 ], iNum;
    
get_playersiPlayersiNum );
    
    new 
szName32 ];
    
get_user_nameiPlayerszNamecharsmaxszName ) );
    
    new const 
szPrefixes][ CsTeams ][ ] =
    {
        {
            
"(Spectator)",
            
"*DEAD*(Terrorist)",
            
"*DEAD*(Counter-Terrorist)",
            
""
        
},
        {
            
"(Spectator)",
            
"(Terrorist)",
            
"(Counter-Terrorist)",
            
""
        
}
    };
    
    new 
szMessage192 ];
    
formatexszMessagecharsmaxszMessage ), "^4%s ^1%s^3 %s^1 :  %s"g_szTags[g_iPlayerTag[iPlayer]], szPrefixesiAlive ][ iTeam ], szNameszArgs );
    
    for( new 
0iTeammateiNumi++ )
    {
        
iTeammate iPlayers];
        
        if( 
iTeammate == iPlayer || ( iAlive || is_user_connectediTeammate ) ) && is_user_aliveiTeammate ) == iAlive && CsTeams:( ( _:cs_get_user_teamiTeammate ) ) % ) == iTeam )
        {
            
message_beginMSG_ONE_UNRELIABLEg_iMsgID_SayText_iTeammate );
            
write_byteiPlayer );
            
write_stringszMessage );
            
message_end( );
        }
    }
    
    return 
PLUGIN_HANDLED_MAIN;
}

bool:IsValidMessageiPlayerbool:bTeamSayszMessage[ ], iLen )
{
    
read_argsszMessageiLen );
    
remove_quotesszMessage );

    if( !
szMessage] )
    {
        return 
false;
    }
    
    new 
iPoscChari;
    while( ( 
cChar szMessageiPos ] ) == '@' )
    {
        
i++;
        
iPos++;
    }

    if( 
)
    {
        return ( !( 
bTeamSay ? ( == ) : ( <= <= ) ) || !accessiPlayerg_iAdminChatFlag ) );
    }

    while( 
< ( cChar szMessageiPos++ ] ) <= 255 )
    {
        if( 
cChar != ' ' && cChar != '%' )
        {
            return 
true;
        }
    }

    return 
false;
}

loadTags()
{
    
// load tags from file
    
new szFilePath[128];
    
get_configsdir(szFilePathcharsmax(szFilePath));
    
add(szFilePathcharsmax(szFilePath), "/Admintags.ini");
    
    new 
fopen(szFilePath"rt");
    
    if( !
)
    {
        new 
szMessage[128];
        
formatex(szMessagecharsmax(szMessage), "Unable to open %s"szFilePath);
        
set_fail_state(szMessage);
    }
    
    new 
data[32], iTagCount;
    while( !
feof(f) )
    {
        
fgets(fdatacharsmax(data))
        
        
trim(data);
        if( !
data[0] || data[0] == ';' || data[0] == '/' && data[1] == '/' ) continue;
        
        if( 
data[0] == '[' )
        {
            
iTagCount++
            
copy(g_szTags[iTagCount], charsmax(g_szTags[]), data)
        }
        else
        {
            
TrieSetCell(g_tSteamTagIndexdataiTagCount)
        }
    }
    
fclose(f)



fysiks 05-27-2014 10:51

Re: [REQ] Tag Admin
 
It already uses a .ini file. Simply use it as it is.

Don't post the code when it already exists in another post. Simply post a link to the post. Also, the Scripting Help forum is for people who are going to write the code themselves. If you are not going to do the writing of the code, post in the Suggestions/Requests forum.

plazma 05-27-2014 11:08

Re: [REQ] Tag Admin
 
Upss sory, but you can't help me :( ??

Black Rose 05-27-2014 12:52

Re: [REQ] Tag Admin
 
I don't even understand the question. What's wrong with it as it is now?

plazma 05-27-2014 13:10

Re: [REQ] Tag Admin
 
Quote:

Originally Posted by Black Rose (Post 2143128)
I don't even understand the question. What's wrong with it as it is now?

Bro make this script with admin tag in file Admintags.ini example:

plazma = Tag Here
Plazma123 = tag Here

You understand now... ? :cry:

Black Rose 05-27-2014 13:13

Re: [REQ] Tag Admin
 
But that is what it does already?

plazma 05-27-2014 13:18

Re: [REQ] Tag Admin
 
Quote:

Originally Posted by Black Rose (Post 2143146)
But that is what it does already?

No it did, it only works with Steam ID

ex:
Code:

[Leader]
STEAM_0:0:12345
STEAM_0:0:23456

[MODS]
STEAM_0:0:34567
STEAM_0:0:45678

But I want to work so

plazma = tag here (name of admin, and tag)
....

fysiks 05-27-2014 15:52

Re: [REQ] Tag Admin
 
SteamID is the only reliable/supported method.

Black Rose 05-27-2014 16:18

Re: [REQ] Tag Admin
 
Quote:

Originally Posted by plazma (Post 2143151)
No it did, it only works with Steam ID

ex:
Code:

[Leader]
STEAM_0:0:12345
STEAM_0:0:23456

[MODS]
STEAM_0:0:34567
STEAM_0:0:45678

But I want to work so

plazma = tag here (name of admin, and tag)
....

Asking for support against non-steam servers is against the forum rules.


All times are GMT -4. The time now is 09:48.

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