Raised This Month: $ Target: $400
 0% 

[Help] get Tag by Name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
psychonic

BAFFLED
Join Date: May 2008
Old 10-26-2014 , 08:49   RE: [Help] get Tag by Name
Reply With Quote #1

Quote:
Originally Posted by ghost95v View Post
anyone can make this to set players Tag by their name in this code? current format is by SteamID "STEAM_0:1:123456" "MyTag" , can we make is like this? "Name" "MyTag" ,,, or else Name = MyTag
thank you ;)

PHP Code:

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

new g_iMsgID_SayText;

new 
g_iAdminChatFlag ADMIN_ALL;

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

public 
plugin_init( )
{
    
register_plugin("Chat Tags""0.2xx""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 ], szName,  szArgs );
    
    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 ], szName,  szArgs );
    
    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[64], iTagCount 0szSteamID[32], szTag[sizeof(g_szTags[])];
    while( !
feof(f) )
    {
        
fgets(fdatacharsmax(data))
        
        
trim(data)
        if( !
data[0] || data[0] == ';' || data[0] == '/' && data[1] == '/' || data[1] != 0x53 ) continue;
        
        
parse(dataszSteamIDcharsmax(szSteamID), szTagcharsmax(szTag))
        if( 
szSteamID[0] && szTag[0] )
        {
            
iTagCount++
            
copy(g_szTags[iTagCount], charsmax(g_szTags[]), szTag)
            
TrieSetCell(g_tSteamTagIndexszSteamIDiTagCount)
        }
    }
    
fclose(f)

Read the rules. Do not clear thread content.
psychonic is offline
Old 10-26-2014, 11:49
ghost95v
This message has been deleted by ghost95v.
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 10-26-2014 , 12:13   Re: [Help] get Tag by Name
Reply With Quote #3

Quote:
Originally Posted by psychonic View Post
Read the rules. Do not clear thread content.
There it is. anyway, Alliedmodders not helped me to solve that, and i have my right to remove ;)
__________________
ghost95v is offline
Send a message via Skype™ to ghost95v
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-26-2014 , 12:18   Re: [Help] get Tag by Name
Reply With Quote #4

Quote:
Originally Posted by ghost95v View Post
There it is. anyway, Alliedmodders not helped me to solve that, and i have my right to remove ;)
No. If you want to get help here (by posting a question) you need to leave that question and post the answer if you find it so that it can help others. If you don't want to post the answers to your questions, don't post a question. Quid pro quo.
__________________
fysiks 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 17:36.


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