Raised This Month: $ Target: $400
 0% 

Modifying allchat plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shiina.Mashiro
Senior Member
Join Date: Sep 2014
Location: Vietnam
Old 08-26-2015 , 03:10   Modifying allchat plugin
Reply With Quote #1

Hi guys, currently I'm using this allchat plugin: All Chat
I want to add a small feature, when player type
Code:
/funname mytag
Then their chat will have a tag next to their name.
Code:
*DEAD* [mytag]Player: This is the tag I want!
This is what I've tried so far:
PHP Code:
/*
AllChat v1.1
Copyright (C) 2006-2007 Ian (Juan) Cammarata

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as  published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; go to http://www.opensource.org/licenses/gpl-license.php


Description:
This plugin does for chat what sv_alltalk does for voice. Dead and alive and spectating players can all see each others chat messages. Team chat is still only visible among your team, but with no regard for whether you are dead or alive. By default this plugin works depending on whether or not sv_alltalk is on. It can be forced to be on all the time, as well as setting custom colors for messages that come from admins.


See it in Action:
Use the following link to find a server that's running this plugin:
http://www.game-monitor.com/search.php?search=allchat_version&type=variable&game=all&country=all


Cvars:
*First value is default

sv_allchat    <1|2|0>
1 - Dependent on sv_alltalk
2 - Always active
0 - Disabled

ac_namecolor <0|1|2>
ac_msgcolor <1|2|0>
0 - Team color
1 - Green
2 - White

ac_hidestatus <0|1>
0 = Show dead/spec status.
1 = Hide status.

ac_teamchat <0|1>
0 = Dead and living can't team chat.
1 = Dead and living can team chat. 


Change Log:
Key (+ added | - removed | f fixed | c changed)

v1.1 (Aug 14, 2007)
+: Cvar ac_hidestatus to show/hide dead/spec status.
+: Cvar ac_teamchat to enable/disable all chat for team chat.

v1.0.1 (June 28, 2007)
f: Replicated messages are now correctly collored based on admin flag.

v1.0 (June 26, 2007)
!Complete rewrite.
f: No longer interferes with other plugins.

v0.5 (June 21, 2007)
+: Tracking cvar.
c: Uses cvar pointers now.

v0.4 (??? ??, 2006) by Ian Cammarata & Dontask
f : Blocking text messages conataining only spaces.

v0.3 (June 23, 2006) by Ian Cammarata & Dontask
+ : Added multiple values to sv_allchat. See details in Cvar section.
+ : Added cvar ac_namecolor to change the color displayed on admins names.
+ : Added cvar ac_msgcolor to change the color displayed on admins msgs.
+ : Added colored messages even if sv_allchat is set to 1 while alltalk is set to 0.
+ : Added equivalent functionality for team say.

v0.2.1 (??? ??, 2006) by Ian Cammarata & Dontask
f : Fixed formatting color issues.

v0.2 (??? ??, 2006) by Ian Cammarata & Dontask
r : Admins name displayed in team color, message text displayed green.
+ : Displays dead status.
+ : Added cvar sv_allchat to enable allchat without alltalk enabled.

v0.1 (April 04, 2006)
+ : Initial release
*/

#include <amxmodx>

#define FLAG ADMIN_RESERVATION
#define VERSION "1.1"

new COLCHAR[3][2] = { "^x03"/*team col*/"^x04"/*green*/"^x01"/*white*/ }

//cvar pointers
new p_allchatp_namecolp_msgcolp_alltalkp_hidestatp_teamchat

//vars to check if message has already been duplicated
new alv_sndralv_str2[26], alv_str4[101]
new 
msg[200]

new 
playerfunname[32][9]

public 
col_changermsg_idmsg_destrcvr )
{
    new 
str2[26]
    
get_msg_arg_string2str225 )
    if( 
equalstr2"#Cstrike_Chat"13 ) )
    {
        new 
str3[22]
        
get_msg_arg_string3str321 )
        
        if( !
strlenstr3 ) )
        {
            new 
str4[101]
            
get_msg_arg_string4str4100 )
            new 
sndr get_msg_arg_int)
            
            new 
bool:is_team_msg = !bool:equalstr2"#Cstrike_Chat_All"17 )
            
            new 
sndr_team get_user_teamsndr )
            
//new bool:is_sndr_spec = !bool:( 0 < sndr_team < 3 )
            
new bool:is_sndr_spec
            
if(get_user_team(sndr) != && get_user_team(sndr) != 2)
                
is_sndr_spec true
            
else
                
is_sndr_spec false
            
            
new namecol clampget_pcvar_num(p_namecol), 0)
            new 
msgcol clampget_pcvar_num(p_msgcol), 0)
            
            new 
bool:same_as_last bool:( alv_sndr == sndr && equalalv_str2str2 ) && equalalv_str4str4) )
            
            if( !
same_as_last )
            {
//Duplicate message once
                
new allchat clampget_pcvar_nump_allchat ), 0)
                if( 
allchat == || ( allchat == && clampget_pcvar_nump_alltalk ), 0) == ) )
                {
                    if( !( 
is_team_msg && ( is_sndr_spec || is_team_msg && get_pcvar_nump_teamchat ) == ) ) )
                    {
//Don't duplicate if it's a spectator team message
                        
new flags[5], team[10]
                        if( 
is_user_alivesndr ) ) flags "bch"
                        
else flags "ach"
                        
                        
if( is_team_msg )
                        {
                            
addflags[strlenflags )], 4"e" )
                            if( 
sndr_team == team "TERRORIST"
                            
else team "CT"
                        
}
                        
                        new 
players[32], num
                        get_players
playersnumflagsteam )

                        if( 
get_user_flagssndr ) & FLAG )
                            
buildmsgsndris_sndr_specis_team_msgsndr_teamnamecolmsgcolstr4 //admin colored, by cvars
                        
else buildmsgsndris_sndr_specis_team_msgsndr_team02str4 //normal colors
                        
                        
for( new i=0numi++ )
                        {
                            
message_beginMSG_ONEget_user_msgid"SayText" ), _players[i] )
                            
write_bytesndr )
                            
write_stringmsg )
                            
message_end()
                        }
                        
                    }
    
                    
alv_sndr sndr
                    alv_str2 
str2
                    alv_str4 
str4
                    
if( task_exists411 ) ) remove_task411 )
                    
set_task0.1"task_clear_antiloop_vars"411 )
                }
            }
            
            if( 
get_user_flagssndr ) & FLAG && ( namecol != || msgcol != ) )
            {
//execute if sndr is admin and cols are not set to engine defaults
                
if( !same_as_last buildmsgsndris_sndr_specis_team_msgsndr_teamnamecolmsgcolstr4 )

                
set_msg_arg_string2msg )
                
set_msg_arg_string4"" )
            }
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
buildmsgsndris_sndr_specis_team_msgsndr_teamnamecolmsgcolstr4[ ] )
{
    new 
sndr_name[33]
    
get_user_namesndrsndr_name32 )
    
    new 
prefix[30] = "^x01"
    
if( get_pcvar_nump_hidestat ) == )
    {
        if( 
is_sndr_spec prefix "^x01*SPEC* "
        
else if( !is_user_alivesndr ) ) prefix "^x01*DEAD* "
    
}
    
    if( 
is_team_msg )
    {
        if( 
is_sndr_spec prefix "^x01(Spectator) "
        
else if( sndr_team == addprefix[strlen(prefix)-1], 29"(Terrorist) " )
        else if( 
sndr_team == addprefix[strlen(prefix)-1], 29"(Counter-Terrorist) " )
    }
    
    
formatmsg199"%s%s%s%s%s :  %s%s",\
        
strlenprefix ) > prefix "",\
        
COLCHAR[1], playerfunname[sndr],\
        
COLCHAR[namecol], sndr_nameCOLCHAR[msgcol], str4 )
    return 
PLUGIN_HANDLED
}

public 
task_clear_antiloop_vars( )
{
    
alv_sndr 0
    alv_str2 
""
    
alv_str4 ""
    
return PLUGIN_HANDLED
}

public 
plugin_init( )
{
    
register_plugin("All Chat",VERSION,"Ian Cammarata")
    
register_cvar("allchat_version",VERSION,FCVAR_SERVER)
    
    
p_allchat register_cvar"sv_allchat""1" )
    
p_namecol register_cvar"ac_namecolor""0" )
    
p_msgcol register_cvar"ac_msgcolor""1" )
    
p_hidestat register_cvar"ac_hidestatus""0" )
    
p_teamchat register_cvar"ac_teamchat""0" )
    
    
p_alltalk get_cvar_pointer"sv_alltalk" )
    
    
register_clcmd("say""handle_say")
    
register_clcmd("say_team""handle_say")
    
register_clcmd("say /myfunname""show_myfunname")
    
    
register_messageget_user_msgid("SayText"), "col_changer" )
    return 
PLUGIN_CONTINUE
}

public 
handle_say(id)
{
    static 
arg[192]
    
read_args(argcharsmax(arg))
    
remove_quotes(arg)
    static 
chatcmd[9]
    static 
nametoget[6]
    
parse(argchatcmdcharsmax(chatcmd), nametogetcharsmax(nametoget))
    if(
equal(chatcmd"/funname"))
    {
        if(!
strlen(nametoget))
            return
        
format(playerfunname[id], charsmax(playerfunname[]), "[%s] "nametoget)
        
client_print(idprint_chat"Your tag is now %s"nametoget)
    }
}
public 
show_myfunname(id)
{
    if(!
strlen(playerfunname[id]))
    {
        
client_print(idprint_chat"[AMXX] You haven't decide your funname yet!")
        return
    }
    else
    {
        
client_print(idprint_chat"[AMXX] Your funname is %s"playerfunname[id])
    }

Tested it, it only work with admin with flag ADMIN_RESERVATION (which is defined in the plugin), and with normal players, it didn't work. I look out the handle_say (get user tag), and it seems like there is no error with that. So I guess the problem is the output of the message. Can anyone give me an idea?
__________________
Shiina.Mashiro is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 08-26-2015 , 16:57   Re: Modifying allchat plugin
Reply With Quote #2

Maybe leak is here ?
PHP Code:
if( get_user_flagssndr ) & FLAG && ( namecol != || msgcol != ) )
            {
//execute if sndr is admin and cols are not set to engine defaults
                
if( !same_as_last buildmsgsndris_sndr_specis_team_msgsndr_teamnamecolmsgcolstr4 )

                
set_msg_arg_string2msg )
                
set_msg_arg_string4"" )
            }
//i think here should be else if i'm not wrong 
I think it should be something like this :

PHP Code:
if( get_user_flagssndr ) & FLAG && ( namecol != || msgcol != ) )
            {
//execute if sndr is admin and cols are not set to engine defaults
                
if( !same_as_last buildmsgsndris_sndr_specis_team_msgsndr_teamnamecolmsgcolstr4 )

                
set_msg_arg_string2msg )
                
set_msg_arg_string4"" )
            }else{
               
set_msg_arg_string(// i have no ideea what u should put here )
                
set_msg_arg_string(// i have no ideea what u should put here  )


siriusmd99 is offline
Shiina.Mashiro
Senior Member
Join Date: Sep 2014
Location: Vietnam
Old 08-27-2015 , 00:42   Re: Modifying allchat plugin
Reply With Quote #3

@siriussmd99
Thanks for the reply, I don't think the problem is there. The player chat is still show, so I guess it is the buildmsg part.
__________________
Shiina.Mashiro 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 06:00.


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