Raised This Month: $32 Target: $400
 8% 

Solved help me with colorchat


Post New Thread Reply   
 
Thread Tools Display Modes
theuser
Member
Join Date: Jul 2020
Old 07-09-2020 , 10:18   Re: help me with colorchat
Reply With Quote #11

Quote:
Originally Posted by OciXCrom View Post
Show the full code.
PHP Code:
public spec(idlevelcid)
{
    if(
cmd_access(id,levelcid1))
            {
            new 
name[32]
            
get_user_info(id"name"name31)
            {    
    new 
players[32], pnumtempid
    get_players
(playerspnum)
    
    for( new 
ii<pnumi++ ) 
    {
        
tempid players[i]
        
user_kill(tempid)
        
cs_set_user_team(tempidCS_TEAM_SPECTATOR)
    }
            }
            
server_cmd("sv_restart 1")
            if(
cs_get_user_team(id) == CS_TEAM_T )
                
ColorChat(0RED,"%s%s: ^x04/spec",is_user_alive(id) ? "" "*Dead* ",name)
            else if(
cs_get_user_team(id) == CS_TEAM_CT )
                
ColorChat(0BLUE,"%s%s: ^x04/spec",is_user_alive(id) ? "" "*Dead* ",name)
            else if(
cs_get_user_team(id) == CS_TEAM_SPECTATOR )
                
ColorChat(0GREY,"%s%s: ^x04/spec",is_user_alive(id) ? "" "*Dead* ",name)
            }
    return 
PLUGIN_HANDLED

theuser is offline
ZaX
Senior Member
Join Date: Jan 2015
Old 07-09-2020 , 10:44   Re: help me with colorchat
Reply With Quote #12

What are you trying to do ? If someone types /spec in chat it executes?
You need to hook say, check if the arguments equals to what you want, stop the function and replace it with the colored message

Code:
#include <amxmodx> #include <cromchat> #define ADMIN_FLAG ADMIN_LEVEL_H public plugin_init() {     register_clcmd("say", "HookSayCommand"); } public HookSayCommand(id) {     if(get_user_flags(id) & ADMIN_FLAG)     {         new szArgs[64];         read_args(szArgs, charsmax(szArgs));         remove_quotes(szArgs);         if(equal( szArgs, "/spec" ) )         {             // Do your thing //             // .............. //             // Do your thing //             new szName[32]; get_user_name(id, szName, charsmax(szName));             CC_SendMatched(0, id, "%s %s : /spec", is_user_alive(id) ? "" : "*DEAD*", szName);             // Stop normal message from showing             return PLUGIN_HANDLED;         }     }     // Dont disable chat x)     return PLUGIN_CONTINUE; }
ZaX is offline
theuser
Member
Join Date: Jul 2020
Old 07-09-2020 , 11:59   Re: help me with colorchat
Reply With Quote #13

Quote:
Originally Posted by ZaX View Post
What are you trying to do ? If someone types /spec in chat it executes?
You need to hook say, check if the arguments equals to what you want, stop the function and replace it with the colored message

Code:
#include <amxmodx> #include <cromchat> #define ADMIN_FLAG ADMIN_LEVEL_H public plugin_init() {     register_clcmd("say", "HookSayCommand"); } public HookSayCommand(id) {     if(get_user_flags(id) & ADMIN_FLAG)     {         new szArgs[64];         read_args(szArgs, charsmax(szArgs));         remove_quotes(szArgs);         if(equal( szArgs, "/spec" ) )         {             // Do your thing //             // .............. //             // Do your thing //             new szName[32]; get_user_name(id, szName, charsmax(szName));             CC_SendMatched(0, id, "%s %s : /spec", is_user_alive(id) ? "" : "*DEAD*", szName);             // Stop normal message from showing             return PLUGIN_HANDLED;         }     }     // Dont disable chat x)     return PLUGIN_CONTINUE; }

The code I put in does the right thing.
But if the admin is alive and the player is dead, or vice versa, it displays the message / spec twice, once with the color I set with ColorChat and once with the default color!
But if the admin and the player are both alive, the plugin will show Chen correctly !!!!!
theuser is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-09-2020 , 13:27   Re: help me with colorchat
Reply With Quote #14

What is the point of manually displaying the message after blocking it deliberately?
What's with the unaligned code and extra brackets?
__________________

Last edited by OciXCrom; 07-09-2020 at 13:28.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
theuser
Member
Join Date: Jul 2020
Old 07-09-2020 , 15:16   Re: help me with colorchat
Reply With Quote #15

Quote:
Originally Posted by OciXCrom View Post
What is the point of manually displaying the message after blocking it deliberately?
What's with the unaligned code and extra brackets?
exp : admin alive and player is dead

admin type /r

sherver show 2 message

admin: /r (green)
admin: /r (def-yello)

but when both alive dont have problem.
theuser is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-09-2020 , 16:43   Re: help me with colorchat
Reply With Quote #16

Quote:
What is the point of manually displaying the message after blocking it deliberately?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
theuser
Member
Join Date: Jul 2020
Old 07-09-2020 , 18:44   Re: help me with colorchat
Reply With Quote #17

Quote:
Originally Posted by OciXCrom View Post
Show the full code.

I don't understand your purpose
Do I need to show you the chat mode with a screenshot?
theuser is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 07-09-2020 , 18:55   Re: help me with colorchat
Reply With Quote #18

I am asking you why are you trying to display that message when it can automatically be displayed if you remove "return PLUGIN_HANDLED" in the end of the function. You're trying to fix a problem that you created yourself.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
theuser
Member
Join Date: Jul 2020
Old 07-10-2020 , 05:28   Re: help me with colorchat
Reply With Quote #19

Quote:
Originally Posted by OciXCrom View Post
I am asking you why are you trying to display that message when it can automatically be displayed if you remove "return PLUGIN_HANDLED" in the end of the function. You're trying to fix a problem that you created yourself.
Yes, you are absolutely right.
Maybe I can't express myself in a clear way.
If we delete that code line, the message will be displayed twice, but if it is, the message will be displayed twice under certain conditions.
Could other plugins be the reason for this?
Can I solve this problem by testing the plugins one by one?
i can upload screenshot sooooooon !
theuser is offline
theuser
Member
Join Date: Jul 2020
Old 07-10-2020 , 06:06   Re: help me with colorchat
Reply With Quote #20

Quote:
Originally Posted by OciXCrom View Post
I am asking you why are you trying to display that message when it can automatically be displayed if you remove "return PLUGIN_HANDLED" in the end of the function. You're trying to fix a problem that you created yourself.

It turned out, the problem was other plugins
the plugin who alive players can here dead players team message whas created the problem
theuser 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:59.


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