Raised This Month: $51 Target: $400
 12% 

Solved Normal Chat not working


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 05-05-2018 , 00:51   Normal Chat not working
Reply With Quote #1

Here is my code ( Totally Hardcoded not for public use )
PHP Code:
#include <amxmodx>
#include <amxmisc>

#define OWNER(%0) (get_user_flags(%0) & ADMIN_RCON)
#define HEADMIN(%0) (get_user_flags(%0) & ADMIN_IMMUNITY)
#define ADMIN(%0) (get_user_flags(%0) & ADMIN_BAN)
#define VIP(%0) (get_user_flags(%0) & ADMIN_RESERVATION)

#define xOWNER "^1[^4OWNER^1]"
#define xHEADMIN "^1[^4HEAD ADMIN^1]"
#define xADMIN "^1[^4ADMIN^1]"
#define xVIP "^1[^4VIP^1]"

#define ALIVE(%0) is_user_alive(%0)

public plugin_init()
{
    
register_plugin("Simple Chat Prefixes""1.1 - BETA""DiGiTaL")
    
register_clcmd("say""handleSay")
    
register_clcmd("say_team""handleTeamSay")
}

public 
handleSay(id) return checkMsg(idfalse)
public 
handleTeamSay(id) return checkMsg(idtrue)

public 
checkMsg(idbool:teamSay)
{
    if(
OWNER(id)) ALIVE(id) ? setMsg(idtruexOWNERtrueteamSay) : setMsg(idtruexOWNERfalseteamSay)
    else if(
HEADMIN(id)) ALIVE(id) ? setMsg(idtruexHEADMINtrueteamSay) : setMsg(idtruexHEADMINfalseteamSay)
    else if(
ADMIN(id)) ALIVE(id) ? setMsg(idtruexADMINtrueteamSay) : setMsg(idtruexADMINfalseteamSay)
    else if(
VIP(id)) ALIVE(id) ? setMsg(idtruexVIPtrueteamSay) : setMsg(idtruexVIPfalseteamSay)
    else if(!
is_user_admin(id)) ALIVE(id) ? setMsg(idfalse""trueteamSay) : setMsg(idfalse""falseteamSay)
    return 
PLUGIN_HANDLED
}

stock setMsg(indexbool:is_admintype[], bool:is_alivebool:is_teamSay)
{
    new 
nMsg[192],szArg[192], szName[32], szTeam[32], players[32], num
    get_user_name
(indexszNamecharsmax(szName))
    
get_user_team(indexszTeamcharsmax(szTeam))

    
read_args(szArgcharsmax(szArg))
    
remove_quotes(szArg)

    if (!
szArg[0] || szArg[0] == '/') return PLUGIN_HANDLED_MAIN

    
if(is_alive)
    {
        if(
is_teamSay)
        {
            
is_admin formatex(nMsgcharsmax(nMsg), "^1(%s) %s ^3%s ^1: ^4%s"szTeamtypeszNameszArg) : formatex(nMsgcharsmax(nMsg), "^1(%s) ^3%s ^1: %s"szTeamszNameszArg)
            
get_players(playersnum"ae"szTeam)
            for(new 
i;numi++) client_print_color(players[i], 0nMsg)
        }
        else
        {
            (
is_admin) ? formatex(nMsgcharsmax(nMsg), "%s ^3%s ^1: ^4%s"typeszNameszArg) : formatex(nMsgcharsmax(nMsg), "^3%s ^1: %s"szNameszArg)
            
client_print_color(00nMsg)
        }
    } 
    else
    {
        if(
is_teamSay)
        {
            (
is_admin) ? formatex(nMsgcharsmax(nMsg), "^1*DEAD* (%s) %s ^3%s ^1: ^4%s"szTeamtypeszNameszArg) : formatex(nMsgcharsmax(nMsg), "^1*DEAD* (%s) ^3%s ^1: %s"szTeamszNameszArg)
            
get_players(playersnum"be"szTeam)
            for(new 
i;numi++) client_print_color(players[i], 0nMsg)
        }
        else 
        {
            (
is_admin) ? formatex(nMsgcharsmax(nMsg), "^1*DEAD* %s ^3%s ^1: ^4%s"typeszNameszArg) : formatex(nMsgcharsmax(nMsg), "^1*DEAD* ^3%s ^1: %s"szNameszArg)
            
get_players(playersnum"b")
            for(new 
i;numi++) client_print_color(players[i], 0nMsg)
        }
    } 
    return 
PLUGIN_HANDLED

I have returned the original say handler to my say func. and added cases in that ...
Now here is problem i m facing :

- Admin chat ( Acc to cases ) working perfect
- Normal player ( Non admin) chat not showing up :/

I have added case to handle normal chat but still not working ...
Most probably i think its the return stopping to use normal chat ..

Help Pro people ..

Last edited by instinctpt1; 05-07-2018 at 12:17. Reason: -
instinctpt1 is offline
CrAzY MaN
Senior Member
Join Date: Mar 2017
Location: India
Old 05-05-2018 , 07:25   Re: Normal Chat not working
Reply With Quote #2

Just use !(is_admin) and format for that!
__________________
CrAzY MaN is offline
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 05-05-2018 , 09:21   Re: Normal Chat not working
Reply With Quote #3

Quote:
Originally Posted by CrAzY MaN View Post
Just use !(is_admin) and format for that!
Its the same ...
instinctpt1 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-05-2018 , 10:54   Re: Normal Chat not working
Reply With Quote #4

Try using my tag user prefix you can set tags by flags
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 05-05-2018 at 10:55.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 05-05-2018 , 12:12   Re: Normal Chat not working
Reply With Quote #5

Natsheh i know there are many seriously better options
But i just want to know wht is wrong in my shit scripting to learn and have knwledge

As i wrote it under 10-15 mins and cant spot my mistakes for hours .. thats my talent
instinctpt1 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-05-2018 , 12:40   Re: Normal Chat not working
Reply With Quote #6

Quote:
Originally Posted by instinctpt1 View Post
Natsheh i know there are many seriously better options
But i just want to know wht is wrong in my shit scripting to learn and have knwledge

As i wrote it under 10-15 mins and cant spot my mistakes for hours .. thats my talent
Try to decrease calling the natives many times inside the function by saving the values inside variables, like is user alive get user flags...

Try to read my user tag prefix also its not perfectly optimized due careless.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-05-2018 , 13:45   Re: Normal Chat not working
Reply With Quote #7

You have a lot of redundant code and it is poorly organized. This makes it easier to make mistakes and harder to find and fix those mistakes.

Here is a much better way to organize the code:
PHP Code:
public checkMsg(idbool:teamSay)
{
    static 
tags[][] = {""xOWNERxHEADMINxADMINxVIP}
    new 
type
    
if( OWNER(id) )
        
type 1
    
else if( HEADMIN(id) )
        
type 2
    
else if( ADMIN(id) )
        
type 3
    
else if( VIP(id) )
        
type 4
    
else
        
type 0
    
    setMsg
(idis_user_admin(id), tags[type], is_user_alive(id), teamSay)
    
    return 
PLUGIN_HANDLED

Also note that returning PLUGIN_HANDLED or PLUGIN_HANDLED_MAIN in a subfunction doesn't actually do anything. Only the top-level function matters. I.e. returning different values in setMsg() doesn't do anything unless you actually use that return value (which you don't).

Also, if you are meaning to not do anything (and let the message continue like normal) when they are not one of the ones that needs a tag then you can simply return PLUGIN_CONTINUE if type == 0 instead of PLUGIN_HANDLED in checkMsg().
__________________

Last edited by fysiks; 05-05-2018 at 13:47.
fysiks is offline
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 05-05-2018 , 14:04   Re: Normal Chat not working
Reply With Quote #8

Thanks fysiks ☺️
instinctpt1 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-05-2018 , 14:25   Re: Normal Chat not working
Reply With Quote #9

Quote:
Originally Posted by instinctpt1 View Post
Thanks fysiks ☺️
Also hook saytext message and modifie the message instead of blocking the say/team clcmd other plugins chat commands will be blocked/ignored
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 05-06-2018 , 10:09   Re: Normal Chat not working
Reply With Quote #10

Quote:
Originally Posted by Natsheh View Post
Also hook saytext message and modifie the message instead of blocking the say/team clcmd other plugins chat commands will be blocked/ignored
But whats wrong in blocking Natsheh as i said i m going to return the chat again to normal if user is not admin
instinctpt1 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 08:15.


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