View Single Post
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-30-2018 , 16:05   Re: Top Flags [27/09/2018]
Reply With Quote #29

You need to review the function in entirety when making a change. You should not be exiting the function within the loop based on a condition that affects 1 player, replace the return X with continue.

Code:
    for(new i; i < iNum; i++)     {         id = iPlayers[i]         if(get_user_flags(id) & iFlagsRestrictToCheck)
        return PLUGIN_HANDLED  <- replace with continue, and indent.
        //If you want to require the player to have ALL of the flags in the cvar, replace with the below.         //Your code will skip them if they have one or more of the flags and not require all. If this is how you want it then disregard.         if ( ( get_user_flags(id) & iFlagsRestrictToCheck ) == iFlagsRestrictToCheck )                 continue;         iRank = get_user_stats(id, stats, bodyhits)                 get_user_name(id, szName, charsmax(szName))                 if(iRank <= get_pcvar_num(VarRank))         {             if(!isTop[id])             {                 client_print_color(id, print_team_red, "^x04[TopFlags]^x03: You are on^x04 TOP%d^x03 and have won the^x04 VIP flags.", get_pcvar_num(VarRank))                 client_print_color(0, print_team_red,"^x04[TopFlags]^x03: %s is in^x04 TOP%d^x03 and won the^x04 VIP flags.", szName, get_pcvar_num(VarRank))                    remove_user_flags(id, ADMIN_USER)                 set_user_flags(id, flags)                 isTop[id] = true             }             //Remove this
            return PLUGIN_HANDLED
        }         else         {             if(isTop[id])             {                 client_print_color(id, print_team_red,"^x04[TopFlags]^x03: You left the^x04 TOP%d^x03 and lost the^x04 VIP flags.", get_pcvar_num(VarRank))                 client_print_color(0, print_team_red,"^x04[TopFlags]^x03: %s left the^x04 TOP%d^x03 and lost the^x04 VIP flags.", szName, get_pcvar_num(VarRank))                 remove_user_flags(id, flags)                 set_user_flags(id, ADMIN_USER)                 isTop[id] = false             }         }     }
__________________

Last edited by Bugsy; 09-30-2018 at 16:10.
Bugsy is offline