Raised This Month: $ Target: $400
 0% 

Solved Normal Chat not working


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 04:42.


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