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

Solved Normal Chat not working


Post New Thread Reply   
 
Thread Tools Display Modes
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-07-2018 , 11:15   Re: Normal Chat not working
Reply With Quote #11

What he means is that you're using PLUGIN_HANDLED for ALL messages, no matter what.
Even though you have incorporated checks for commands (checking if it starts with /) it doesn't matter since in the end you only have one return value.

It all depends on where your plugin is placed in the plugins.ini. If it's at the top, no other plugins will never recieve any chat commands.

If you took what fysiks posted and edited it a little your other return values would actually matter.
Code:
public checkMsg(id, bool:teamSay) {     static tags[][] = {"", xOWNER, xHEADMIN, xADMIN, xVIP}     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(id, is_user_admin(id), tags[type], is_user_alive(id), teamSay)
   
    return PLUGIN_HANDLED
}
->
Code:
public checkMsg(id, bool:teamSay) {     static tags[][] = {"", xOWNER, xHEADMIN, xADMIN, xVIP}     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    
    return setMsg(id, is_user_admin(id), tags[type], is_user_alive(id), teamSay)
}

Now, handle(Team)Say() would return whatever checkMsg() returns, which is whatever setMsg() returns.

On the other hand, is it relevant? If you use PLUGIN_HANDLED_MAIN it's basically what you need. It will block it but it will let all other plugins recieve it first, therefor not blocking commands only the chat output.
__________________
Black Rose is offline
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 05-07-2018 , 11:47   Re: Normal Chat not working
Reply With Quote #12

Black this one is latest. Is there any need to edit it ?
https://github.com/xpt1x/ExtraAmxxPl...ChatPrefix.sma
instinctpt1 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-07-2018 , 11:59   Re: Normal Chat not working
Reply With Quote #13

I would change this:
Code:
public checkMsg(id, bool:teamSay) {     new type     static tags[][] = { "", "^1[^4OWNER^1]", "^1[^4ADMIN^1]", "^1[^4VIP^1]" } /* Prefix are here */     if(OWNER(id)) type = 1     else if(ADMIN(id)) type = 2     else if(VIP(id)) type = 3
    else type = 0
   
    if(type == 0) return PLUGIN_CONTINUE
    setMsg(id, tags[type], bool:is_user_alive(id), teamSay)
    return PLUGIN_HANDLED
}
->
Code:
public checkMsg(id, bool:teamSay) {     new type     static tags[][] = { "", "^1[^4OWNER^1]", "^1[^4ADMIN^1]", "^1[^4VIP^1]" } /* Prefix are here */     if(OWNER(id)) type = 1     else if(ADMIN(id)) type = 2     else if(VIP(id)) type = 3
    else return PLUGIN_CONTINUE
    setMsg(id, tags[type], bool:is_user_alive(id), teamSay)
    return PLUGIN_HANDLED_MAIN
}

and
Code:
stock setMsg(index, type[], bool:is_alive, bool:is_teamSay) {     new nMsg[192],szArg[192], szName[32], szTeam[32], players[32], num     get_user_name(index, szName, charsmax(szName))     get_user_team(index, szTeam, charsmax(szTeam))     read_args(szArg, charsmax(szArg))     remove_quotes(szArg)     #if defined HIDE_SLASH
    if (!szArg[0] || szArg[0] == '/') return PLUGIN_HANDLED
    #endif     if(is_alive)     {         if(is_teamSay) {             formatex(nMsg, charsmax(nMsg), "^1(%s) %s ^3%s ^1: ^4%s", szTeam, type, szName, szArg)             get_players(players, num, "ae", szTeam)             for(new i;i < num; i++) client_print_color(players[i], 0, nMsg)         }         else {             formatex(nMsg, charsmax(nMsg), "%s ^3%s ^1: ^4%s", type, szName, szArg)             client_print_color(0, 0, nMsg)         }     }     else     {         if(is_teamSay) {             formatex(nMsg, charsmax(nMsg), "^1*DEAD* (%s) %s ^3%s ^1: ^4%s", szTeam, type, szName, szArg)             get_players(players, num, "be", szTeam)             for(new i;i < num; i++) client_print_color(players[i], 0, nMsg)         }         else {             formatex(nMsg, charsmax(nMsg), "^1*DEAD* %s ^3%s ^1: ^4%s", type, szName, szArg)             get_players(players, num, "b")             for(new i;i < num; i++) client_print_color(players[i], 0, nMsg)         }     }
    return PLUGIN_HANDLED
}
->
Code:
stock setMsg(index, type[], bool:is_alive, bool:is_teamSay) {     new nMsg[192],szArg[192], szName[32], szTeam[32], players[32], num     get_user_name(index, szName, charsmax(szName))     get_user_team(index, szTeam, charsmax(szTeam))     read_args(szArg, charsmax(szArg))     remove_quotes(szArg)     #if defined HIDE_SLASH
    if (!szArg[0] || szArg[0] == '/') return
    #endif     if(is_alive)     {         if(is_teamSay) {             formatex(nMsg, charsmax(nMsg), "^1(%s) %s ^3%s ^1: ^4%s", szTeam, type, szName, szArg)             get_players(players, num, "ae", szTeam)             for(new i;i < num; i++) client_print_color(players[i], 0, nMsg)         }         else {             formatex(nMsg, charsmax(nMsg), "%s ^3%s ^1: ^4%s", type, szName, szArg)             client_print_color(0, 0, nMsg)         }     }     else     {         if(is_teamSay) {             formatex(nMsg, charsmax(nMsg), "^1*DEAD* (%s) %s ^3%s ^1: ^4%s", szTeam, type, szName, szArg)             get_players(players, num, "be", szTeam)             for(new i;i < num; i++) client_print_color(players[i], 0, nMsg)         }         else {             formatex(nMsg, charsmax(nMsg), "^1*DEAD* %s ^3%s ^1: ^4%s", type, szName, szArg)             get_players(players, num, "b")             for(new i;i < num; i++) client_print_color(players[i], 0, nMsg)         }     }
   
}

The spacing on the highlighted lines is weird for some reason, you get the point.
I honestly didn't read through anything except the highlighted lines. Sure there are other things I would've written differently, but if it works there's really no reason.
__________________

Last edited by Black Rose; 05-07-2018 at 12:10.
Black Rose is offline
instinctpt1
Senior Member
Join Date: Dec 2016
Location: Chandigarh, India
Old 05-07-2018 , 12:16   Re: Normal Chat not working
Reply With Quote #14

Yeah now i got it Now
Myself i was abt to change
PHP Code:
else type 0
    
    
if(type == 0)return PLUGIN_CONTINUE 
to the one you have edited and highlighted but was getting plugin bugged now i know why it was getting bugged
- Yeah except this plugin works fine ( I too was not sure of this returning things but was determined not to register a message separately and use return on say handlers instead of that xD )

Thanks BlackRose, Fysiks, Natsheh for all help
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 10:37.


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