AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved warning 219: local variable "menu" shadows a variable at a preceding level (https://forums.alliedmods.net/showthread.php?t=315876)

NC.svtrade 04-29-2019 14:56

warning 219: local variable "menu" shadows a variable at a preceding level
 
I'm so bad at solving minor problems...

Full Code

PHP Code:

#define PL_NAME "csgo pug"
#define PL_AUTHOR "lck"
#define PL_DESCRIPTION "csgo simple pug plugin"
#define PL_VERSION "alpha 1.0"
#define PL_URL "https://steamcommunity.com/profiles/76561198149066707"

public Plugin:myinfo = {
    
name PL_NAME,
    
description PL_AUTHOR,
    
description PL_DESCRIPTION,
    
description PL_VERSION,
    
description PL_URL
};

// Main Frame
#include <sourcemod>
#include <cstrike>

// DEBUG MODE
bool g_bDebug =                                 false;
Handle g_hDebugAlertHud =                         INVALID_HANDLE,
        
g_hDebugHud =                             INVALID_HANDLE;

// enum Game State Type
enum GameState {
    
GS_DUMMY =                                     -1,
    
GS_WARMUP =                                 0,
    
GS_CAP =                                     1,
    
GS_PRIORITY =                                 2,
    
GS_PICK =                                     3,
    
GS_MAP =                                     4,
    
GS_KNIFE =                                     5,
    
GS_ATDF =                                     6,
    
GS_READY =                                     7,
    
GS_INGAME =                                 8,
    
GS_BREAKINGAME =                             9,
    
GS_OVERTIME =                                 10,
    
GS_GAMEEND =                                 11
};

// enum Debug Output Type
enum DebugOutput {
    
DEBUG_CHAT 1,
    
DEBUG_ALLCHAT 2,
    
DEBUG_HUD 4,
    
DEBUG_HUDALL 8,
    
DEBUG_LOG 16
};

GameState g_cGSCurrentState =                     GS_WARMUP;

ConVar g_cVTagEnablity,
        
g_cVTagCap,
        
g_cVTagPlayer,
        
g_cVTagSpectator;

// Cap Section

ConVar g_cVCapRestrictTimerVal,
        
g_cVCapRestrictTimerEnablity,
        
g_cVCapUserMessageEnablity,
        
g_cVCapUserMessageTimerVal,
        
g_cVCapRandomIgnoreOringal,
        
g_cVCapElectMethod;

int g_AiCapList[2] =                             {00};

int g_iCapForceTemp =                             0;

float g_flCapRestrictTimer =                     0.0,
       
g_flCapUserMessageTimer =                 0.0;

public 
OnPluginStart() {
    
g_hDebugAlertHud CreateHudSynchronizer();
    
g_hDebugHud CreateHudSynchronizer();
    
    if(
GetEngineVersion() != Engine_CSGOSetFailState("THIS PLUGIN IS DESIGNED FOR CSGO.");
    
    
LoadTranslations("common.phrases");
    
    
RegAdminCmd("sm_c0"o_CBCapVolunteer0);
    
RegAdminCmd("sm_cf0"o_CBCapForceManageADMFLAG_ROOT);
    
RegAdminCmd("sm_debug"o_CBDebugModeADMFLAG_ROOT);
    
    
AddCommandListener(o_CBJoinTeam"jointeam");
    
    
ResetVariables(trueGS_DUMMY);
    
CreateConVars();
    
HookConVarChanges();
    
UpdateVariables();
}

public 
OnGameFrame() {
    
// Debugging
    
if(g_bDebugPrintDebugMsg();
    
    
// Game State
    
if(g_cGSCurrentState == GS_WARMUP) {
        if(
GetInGamePlayers() == 10ShiftGameStateForward();
    }
    
    if(
g_cGSCurrentState == GS_CAP) {
        if(
GetInGamePlayers() < 10) {
            
ShiftGameStateBackward();
            return;
        }
        if(
IsCapFull(CS_TEAM_CT) && IsCapFull(CS_TEAM_T)) {
            
ShiftGameStateForward();
            return;
        }
        if(
g_flCapRestrictTimer <= GetGameTime()) {
            
SelectRandomCap();
            return;
        }
        
        if(
g_flCapUserMessageTimer <= GetGameTime() && g_cVCapUserMessageEnablity.BoolValue) {
            
g_flCapUserMessageTimer GetGameTime() + g_cVCapUserMessageTimerVal.FloatValue;
            
            
// Messaging
            
if(g_cVCapElectMethod.IntValue == 0PrintToChatAll(" >> Call Admin for Election of Cap.");
            if(
g_cVCapElectMethod.IntValue == 1PrintToChatAll(" >> Players who want to be a caps, please Type !c0 for election of Cap.");
            
            return;
        }
    }
}

public 
OnClientSettingsChanged(client) {
    if(!
IsValidClient(client)) return;
    
    
UpdatePlayerSettings(client);
}

public 
OnConfigsExecuted() {
    
UpdateVariables();
}

public 
o_CBcVChange(ConVar cvar, const char[] oldValue, const char[] newValue) {
    
UpdateVariables();
}

public 
Action o_CBJoinTeam(client, const String:command[], argc) {
    if(!
IsValidClient(client) || argc 1
        return 
Plugin_Handled;
    
    new 
String:arg[10];
    
GetCmdArg(1argsizeof(arg));
    new 
TargetTeam StringToInt(arg);
    
    if(
g_cGSCurrentState == GS_CAP) {
        if(
TargetTeam != CS_TEAM_SPECTATOR) {
            
ReplyToCommand(client" >> Joining team during match is not allowed.\nJoin Spectator, Please.");
            return 
Plugin_Handled;
        }
    }
    
    
    
    
    if(
TargetTeam || TargetTeam CS_TEAM_CT) {
        
ReplyToCommand(client" >> Joining that team is not allowed.");
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;
}

public 
Action o_CBCapVolunteer(clientargs) {
    
// Ignore The Command
    
if(!IsValidClient(client)) return Plugin_Handled;
    if(
IsSpectator(client)) return Plugin_Handled;
    if(
g_cVCapElectMethod.IntValue != 1) return Plugin_Handled;
    
    
// Reply Denial The Commmand
    
if(IsCapFull(CS_TEAM_CT) && IsCapFull(CS_TEAM_T)) {
        
ReplyToCommand(client" >> Captain slots are all reserved.");
        return 
Plugin_Handled;
    }
    if(
IsPlayerCap(client)) {
        
ReplyToCommand(client" >> You are already a captain.");
        return 
Plugin_Handled;
    }
    
    new 
EmptyCapSlot GetEmptyCapSlot();
    
    
g_AiCapList[EmptyCapSlot] = client;
    
UpdatePlayerSettings(client);
    
    
PrintToChat(client" >> You are now a Captain.");
    
PrintToChatAll(" >> %N is now a Captain."client);
    
    return 
Plugin_Continue;
}

public 
Action o_CBCapForceManage(clientargs) {
    if(!
IsValidClient(client)) return Plugin_Handled;
    
    new 
Handle:menu CreateMenu(o_CBMenuPlayerList);
    
SetMenuTitle(menu"Please Select A Player for Cap.");
    
    new 
AvaliablePlayers 0;
    
    for(new 
i=1i<=MaxClientsi++) {
        if(
IsValidClient(i)) if(!IsSpectator(i)) if(!IsPlayerCap(i)) {
            new 
String:ii[3], String:name[MAX_NAME_LENGTH];
            
IntToString(iii3);
            
GetClientName(inamesizeof(name));
            
            
AddMenuItem(menuiiname);
            
            
AvaliablePlayers++
        }
    }
    
SetMenuExitButton(menutrue);
    if(
AvaliablePlayers 0DisplayMenu(menuclient0);
    else 
CloseHandle(menu);
    
    return 
Plugin_Continue;
}

public 
int o_CBMenuPlayerList(Handle menuMenuAction actionint clientint pos) {
    if(
action == MenuAction_Select) {
        
// Save the Value on Temporary Global Variable
        
new String:item[3];
        
GetMenuItem(menupositem3);
        
        
// @ GS_CAP
        
g_iCapForceTemp StringToInt(item);
        
        
// Create a Team Select Menu @ GS_CAP
        
new Handle:menu2 CreateMenu(o_CBMenuTeamList);
        
SetMenuTitle(menu2"Please Select A Team for Cap.");
        
AddMenuItem(menu2"0""T");
        
AddMenuItem(menu2"1""CT");
        
SetMenuExitButton(menu2true);
        
DisplayMenu(menu2client0);
        
        
// Debug
        
DebugForceCapMenu("o_CBMenuPlayerList CB"menuactionclientpos);
        
    } else if(
action == MenuAction_Cancel) {
        
// Debug
        
DebugForceCapMenu("o_CBMenuPlayerList CB"menuactionclientpos);
        
        
CloseHandle(menu);
        
g_iCapForceTemp 0;
    }
}

public 
int o_CBMenuTeamList(Handle menuMenuAction actionint clientint pos) {
    if(
action == MenuAction_Select) {
        
// Save the Value on Temporary Global Variable
        
new String:item[2];
        
GetMenuItem(menupositem2);
        
        
// @ GS_CAP
        
new team StringToInt(item);
        
g_AiCapList[team] = g_iCapForceTemp;
        
        
UpdatePlayerSettings(g_AiCapList[team]);
        
g_iCapForceTemp 0;
        
        
PrintToChatAll(" >> %N has been forced to be a Captain."g_iCapForceTemp);
        
        
// Debug
        
DebugForceCapMenu("o_CBMenuTeamList CB"menuactionclientpos);
        
    } else if(
action == MenuAction_Cancel) {
        
// Debug
        
DebugForceCapMenu("o_CBMenuTeamList CB"menuactionclientpos);
        
        
CloseHandle(menu);
        
g_iCapForceTemp 0;
    }
}

void DebugForceCapMenu(char[] m_sDebugNameHandle m_hmenuMenuAction m_cMAactionint m_iclientint m_ipos) {
    
char p_sDebugMsg[11][100];
    
Format(p_sDebugMsg[0], sizeof(p_sDebugMsg[0]), "< p_Variable Section >");
    
Format(p_sDebugMsg[1], sizeof(p_sDebugMsg[1]), "Handle:menu %x"m_hmenu);
    
Format(p_sDebugMsg[2], sizeof(p_sDebugMsg[2]), "MenuAction:action %d"view_as<int>(m_cMAaction));
    
    if(
IsValidClient(client)) Format(p_sDebugMsg[3], sizeof(p_sDebugMsg[3]), "client %d => %N"m_iclientm_iclient);
    else 
Format(p_sDebugMsg[3], sizeof(p_sDebugMsg[3]), "Client Invalid");
    
    
Format(p_sDebugMsg[4], sizeof(p_sDebugMsg[4]), "pos %d"m_ipos);
    
Format(p_sDebugMsg[5], sizeof(p_sDebugMsg[5]), "< g_Variable Section >");
    
Format(p_sDebugMsg[6], sizeof(p_sDebugMsg[6]), "g_cGSCurrentState %d"view_as<int>(g_cGSCurrentState));
    
Format(p_sDebugMsg[7], sizeof(p_sDebugMsg[7]), "g_AiCapList %d %d"g_AiCapList[0], g_AiCapList[1]);
    
Format(p_sDebugMsg[8], sizeof(p_sDebugMsg[8]), "g_iCapForceTemp %d"g_iCapForceTemp);
    
Format(p_sDebugMsg[9], sizeof(p_sDebugMsg[9]), "g_flCapRestrictTimer %2f"g_flCapRestrictTimer);
    
Format(p_sDebugMsg[10], sizeof(p_sDebugMsg[10]), "g_flCapUserMessageTimer %2f"g_flCapUserMessageTimer);
    
    
PrintDebugAlert(m_sDebugNamem_sDebugMsg11DEBUG_ALLCHAT);
}

public 
Action o_CBDebugMode(clientargs) {
    
g_bDebug = !g_bDebug;
    
    if(
g_bDebugPrintToChat(client" >> Debug Mode is now true.");
    else 
PrintToChat(client" >> Debug Mode is now false.");
    
    return 
Plugin_Continue;
}

void UpdateVariables() {
    if(
g_cVCapRestrictTimerVal.FloatValue 0.0g_cVCapRestrictTimerVal.FloatValue 0.0;
    if(
g_cVTagEnablity.IntValue 2g_cVCapRestrictTimerVal.IntValue 2;
    if(
g_cVTagEnablity.IntValue 0g_cVCapRestrictTimerVal.IntValue 0;
    if(
g_cVCapElectMethod.IntValue 2g_cVCapElectMethod.IntValue 2;
    if(
g_cVCapElectMethod.IntValue 0g_cVCapElectMethod.IntValue 0;
    if(
g_cVCapRestrictTimerEnablity.IntValue 1g_cVCapRestrictTimerEnablity.IntValue 1// bool
    
if(g_cVCapRestrictTimerEnablity.IntValue 0g_cVCapRestrictTimerEnablity.IntValue 0;
    if(
g_cVCapRandomIgnoreOringal.IntValue 1g_cVCapRandomIgnoreOringal.IntValue 1// bool
    
if(g_cVCapRandomIgnoreOringal.IntValue 0g_cVCapRandomIgnoreOringal.IntValue 0;
    if(
g_cVCapUserMessageEnablity.IntValue 1g_cVCapUserMessageEnablity.IntValue 1// bool
    
if(g_cVCapUserMessageEnablity.IntValue 0g_cVCapUserMessageEnablity.IntValue 0;
    if(
g_cVCapUserMessageTimerVal.FloatValue 0.0g_cVCapUserMessageTimerVal.FloatValue 0.0;
    
    for(
int i=1i<=MaxClientsi++) if(IsValidClient(i)) UpdatePlayerSettings(i);
    if(!
g_cVCapRestrictTimerEnablity.BoolValue) if(g_flCapRestrictTimer GetGameTime()) g_flCapRestrictTimer 0.0;
    if(!
g_cVCapUserMessageEnablity.BoolValue) if(g_flCapUserMessageTimer GetGameTime()) g_flCapUserMessageTimer 0.0;
}

void ResetVariables(bool m_bresetall falseGameState m_cGSstartstate == GS_DUMMY) {
    
bool p_bResetAllVar = (m_cGSstartstate == GS_DUMMY && m_bresetall);
    
    if(
m_cGSstartstate == GS_DUMMY || p_bResetAllVar) { 
        
g_bDebug false;
        
g_cGSCurrentState GS_WARMUP;
    }
    if(
m_cGSstartstate == GS_CAP || p_bResetAllVar) {
        if(
m_bresetall) {
            
g_AiCapList[0] = 0;
            
g_AiCapList[1] = 0;
        }
        
        
g_iCapForceTemp 0;
        
g_flCapRestrictTimer 0.0;
        
g_flCapUserMessageTimer 0.0;
    }
}

void UpdatePlayerSettings(m_iclient) {
    
char p_cCurrentClanTag[MAX_NAME_LENGTH];
    
CS_GetClientClanTag(m_iclientp_cCurrentClanTagsizeof(p_cCurrentClanTag));
    
    if(
IsGameStateInBound(GS_WARMUPGS_GAMEEND)) {
        
        
// Clan Tag Force Changer 
        // * If there is no clan tag, clan tag doesn't change.
        
char p_cTagRecieverSpec[MAX_NAME_LENGTH],
              
p_cTagRecieverPlayer[MAX_NAME_LENGTH],
              
p_cTagRecieverCap[MAX_NAME_LENGTH];
        
        
g_cVTagSpectator.GetString(p_cTagRecieverSpecsizeof(p_cTagRecieverSpec));
        
g_cVTagPlayer.GetString(p_cTagRecieverPlayersizeof(p_cTagRecieverPlayer));
        
g_cVTagCap.GetString(p_cTagRecieverCapsizeof(p_cTagRecieverCap));

        if(
IsSpectator(m_iclient)) 
            if((!
IsConVarTagForce() ? (!StrEqual(p_cTagRecieverSpec""true)) : true)) 
                if(
StrEqual(p_cCurrentClanTagp_cTagRecieverSpectrue)) 
                    
CS_SetClientClanTag(m_iclientp_cTagRecieverSpec);
        
        if(!
IsSpectator(m_iclient)) 
            if((!
IsConVarTagForce() ? (!StrEqual(p_cTagRecieverPlayer""true)) : true)) 
                if(
StrEqual(p_cCurrentClanTagp_cTagRecieverPlayertrue)) 
                    
CS_SetClientClanTag(m_iclientp_cTagRecieverPlayer);
        
        if(
IsPlayerCap(m_iclient)) 
            if((!
IsConVarTagForce() ? (!StrEqual(p_cTagRecieverCap""true)) : true)) 
                if(
StrEqual(p_cCurrentClanTagp_cTagRecieverCaptrue)) 
                    
CS_SetClientClanTag(m_iclientp_cTagRecieverCap);
        
        if(!
IsConVarTagForce()) 
            
CS_SetClientClanTag(m_iclientp_cCurrentClanTag);
        
        
char p_cDebugTag[50];
        
CS_GetClientClanTag(m_iclientp_cDebugTag50);
        
        if(
g_bDebug) {
            
char p_sDebugMsg[6][100];
            
            
Format(p_sDebugMsg[0], sizeof(p_sDebugMsg[0]), "< p_Variable Section >");
            
Format(p_sDebugMsg[1], sizeof(p_sDebugMsg[1]), "p_cTagRecieverSpec %s"p_cTagRecieverSpec);
            
Format(p_sDebugMsg[2], sizeof(p_sDebugMsg[2]), "p_cTagRecieverPlayer %s"p_cTagRecieverPlayer);
            
Format(p_sDebugMsg[3], sizeof(p_sDebugMsg[3]), "p_cTagRecieverCap %s"p_cTagRecieverCap);
            
Format(p_sDebugMsg[4], sizeof(p_sDebugMsg[4]), "< m_Variable Section >");
            
Format(p_sDebugMsg[5], sizeof(p_sDebugMsg[5]), "m_iclient %d"m_iclient);
            
            
PrintDebugAlert("UpdatePlayerSettings"m_sDebugMsg6DEBUG_ALLCHAT);
        }
    }
}

void CreateConVars() {
    
g_cVCapRestrictTimerVal =         CreateConVar("pug_cflrestricttimer""60.0""Value of Cap restrict timer.");
    
g_cVTagEnablity =                 CreateConVar("pug_tiagenable""2""Enability of Force Clan tag. Val Type : 0 = Doesn't Enable , 1 = Force Enable , 2 = Enable but no force on empty tags");
    
g_cVTagCap =                     CreateConVar("pug_tsagcap""[ CAP ]""Pug Tag for Cap");
    
g_cVTagPlayer =                 CreateConVar("pug_tsagplayer""""Pug Tag for Player");
    
g_cVTagSpectator =                 CreateConVar("pug_tsagspec""[ SPEC ]""Pug Tag for Spectator");
    
g_cVCapElectMethod =             CreateConVar("pug_cielectmethod""1""Method Selection for Cap Election. Val Type : 0 = Only Electing by Admin , 1 = Electing by player volunteers , 2 = Totally Random Election");
    
g_cVCapRestrictTimerEnablity =     CreateConVar("pug_cbrestricttimer""1""Enablity of Cap Restrict Timer for Random Cap.");
    
g_cVCapRandomIgnoreOringal =     CreateConVar("pug_cbignoreoriginal""1""Ignore the original caps when random cap election is processing.");
    
g_cVCapUserMessageEnablity =     CreateConVar("pug_cbusermsg""1""Enablity of User message timer which Message the cap elect method for players who don't know.");
    
g_cVCapUserMessageTimerVal =     CreateConVar("pug_cflusermsg""5.0""Value of User message timer.");
}

void HookConVarChanges() {
    
g_cVCapRestrictTimerVal.AddChangeHook(o_CBcVChange);
    
g_cVTagEnablity.AddChangeHook(o_CBcVChange);
    
g_cVTagCap.AddChangeHook(o_CBcVChange);
    
g_cVTagPlayer.AddChangeHook(o_CBcVChange);
    
g_cVTagSpectator.AddChangeHook(o_CBcVChange);
    
g_cVCapElectMethod.AddChangeHook(o_CBcVChange);
    
g_cVCapRestrictTimerEnablity.AddChangeHook(o_CBcVChange);
    
g_cVCapRandomIgnoreOringal.AddChangeHook(o_CBcVChange);
    
g_cVCapUserMessageEnablity.AddChangeHook(o_CBcVChange);
    
g_cVCapUserMessageTimerVal.AddChangeHook(o_CBcVChange);
}

void CallGameStateShifted(GameState m_cGSCurrentStatebool m_bIsForwardedGameState m_cGSPreState GS_DUMMY) {
    
ResetVariables(truem_cGSCurrentState);
    
ResetVariables(falsem_cGSPreState);
    
    if(
m_cGSCurrentState == GS_CAP) {
        if(
m_bIsForwarded) {
            if(
g_cVCapRestrictTimerEnablity.BoolValueg_flCapRestrictTimer GetGameTime() + g_cVCapRestrictTimerVal.FloatValue;
            if(
g_cVCapElectMethod.IntValue == 2SelectRandomCap();
            if(
g_cVCapUserMessageEnablity.BoolValueg_flCapUserMessageTimer GetGameTime() + g_cVCapUserMessageTimerVal.FloatValue;
        }
    }
}

void ShiftGameStateForward() {
    
GameState p_cGSPreState g_cGSCurrentState;
    
    if(
g_cGSCurrentState == GS_GAMEENDg_cGSCurrentState GS_WARMUP;
    else 
g_cGSCurrentState++
    
    
CallGameStateShifted(g_cGSCurrentStatetruep_cGSPreState);
    
    if(
g_bDebug) {
        
char p_sDebugMsg[5][100];
        
        
Format(p_sDebugMsg[0], sizeof(p_sDebugMsg[0]), "< p_Variable Section >");
        
Format(p_sDebugMsg[1], sizeof(p_sDebugMsg[1]), "Handle:menu %x"menu);
        
Format(p_sDebugMsg[2], sizeof(p_sDebugMsg[2]), "p_cGSPreState %d"view_as<int>(p_cGSPreState));
        
Format(p_sDebugMsg[3], sizeof(p_sDebugMsg[3]), "< g_Variable Section >");
        
Format(p_sDebugMsg[4], sizeof(p_sDebugMsg[4]), "g_cGSCurrentState %d"view_as<int>(g_cGSCurrentState));
        
        
PrintDebugAlert("ShiftGameStateForward"m_sDebugMsg5DEBUG_ALLCHAT);
    }
}

void ShiftGameStateBackward() {
    
GameState p_cGSPreState g_cGSCurrentState;
    
    if(
g_cGSCurrentState != GS_WARMUPg_cGSCurrentState--;
    else return;
    
    
CallGameStateShifted(g_cGSCurrentStatefalsep_cGSPreState);
    
    if(
g_bDebug) {
        
char p_sDebugMsg[5][100];
        
        
Format(p_sDebugMsg[0], sizeof(p_sDebugMsg[0]), "< p_Variable Section >");
        
Format(p_sDebugMsg[1], sizeof(p_sDebugMsg[1]), "Handle:menu %x"menu);
        
Format(p_sDebugMsg[2], sizeof(p_sDebugMsg[2]), "p_cGSPreState %d"view_as<int>(p_cGSPreState));
        
Format(p_sDebugMsg[3], sizeof(p_sDebugMsg[3]), "< g_Variable Section >");
        
Format(p_sDebugMsg[4], sizeof(p_sDebugMsg[4]), "g_cGSCurrentState %d"view_as<int>(g_cGSCurrentState));
        
        
PrintDebugAlert("ShiftGameStateBackward"m_sDebugMsg5DEBUG_ALLCHAT);
    }
}

bool IsGameStateInBound(GameState m_cGSminboundGameState m_cGSmaxbound) {
    if(
view_as<int>(m_cGSminbound) <= view_as<int>(g_cGSCurrentState) < view_as<int>(m_cGSmaxbound)) return true;
    else return 
false;
}

int GetInGamePlayers() {
    
int m_iReturnVal 0;
    
    for(
int i=1i<=MaxClientsi++) {
        if(
IsValidClient(i)) if((GetClientTeam(i) != CS_TEAM_SPECTATOR)) m_iReturnVal++
    }
    
    return 
m_iReturnVal;
}

void SelectRandomCap() {
    if(
GetEmptyCapSlot() == -1) return;
    if(
g_cGSCurrentState != GS_CAP) return;
    if(!
g_cVCapRestrictTimerEnablity.BoolValue && g_cVCapElectMethod.IntValue != 2) return;
    
    
int p_iMaxPlayers GetInGamePlayers();
    if(!
IsCapSlotFullyEmpty()) p_iMaxPlayers -= 1
    
    
bool p_bRandomIgnoreOriginalcVarVal g_cVCapRandomIgnoreOringal.BoolValue;
    
int p_iRandomSlot GetRandomInt(1p_iMaxPlayers);
    
int p_iCurrentSlot 0;
    
int p_iSlotTeam CS_TEAM_T;
    
    while(
p_bRandomIgnoreOriginalcVarVal p_iSlotTeam <= CS_TEAM_CT GetEmptyCapSlot() != -1) {
        
p_iRandomSlot GetRandomInt(1p_iMaxPlayers);
        
p_iCurrentSlot 0;
        
        for(
int i=1i<=MaxClientsi++) if(IsValidClient(i)) if(!IsSpectator(i)) if(!IsPlayerCap(i)) {
            
p_iCurrentSlot++
            if(
p_iCurrentSlot == p_iRandomSlot
                
g_AiCapList[p_iSlotTeam 2] = i;
        }
        
        
p_iMaxPlayers -= 1;
        
p_iSlotTeam++
    }
}

bool IsCapSlotFullyEmpty() {
    if(!
IsCapFull(CS_TEAM_T) && !IsCapFull(CS_TEAM_CT)) return true;
    else return 
false;
}

int GetEmptyCapSlot() {
    
int m_iReturnVal = -1;
    
    if(
IsCapFull(CS_TEAM_CT)) m_iReturnVal 0;
    if(
IsCapFull(CS_TEAM_T)) m_iReturnVal 1;
    if(
IsCapFull(CS_TEAM_T) && IsCapFull(CS_TEAM_CT)) m_iReturnVal = -1;
    else 
m_iReturnVal 0;
    
    return 
m_iReturnVal;
}

bool IsCapFull(int m_iteam) {
    if(
g_AiCapList[m_iteam 2] != 0) return true;
    else return 
false;
}

bool IsPlayerCap(int m_iclient) {
    if(
g_AiCapList[0] == m_iclient || g_AiCapList[1] == m_iclient) return true;
    else return 
false;
}

bool IsValidClient(int m_iclientbool m_bnobots true) {
    if(
g_bDebugm_bnobots false;
    if(
m_iclient <= || m_iclient MaxClients || !IsClientConnected(m_iclient) || (m_bnobots && IsFakeClient(m_iclient)))
        return 
false
    
    return 
IsClientInGame(m_iclient); 
}

bool IsSpectator(int m_iclientbool m_bnobots true) {
    if(
g_bDebugm_bnobots false;
    if(!
IsValidClient(m_iclient)) return false;
    if((
m_bnobots && IsFakeClient(m_iclient))) return false;
    
    if(
GetClientTeam(m_iclient) == CS_TEAM_SPECTATOR) return true;
    else return 
false;
}

bool IsConVarTagForce() {
    return (
g_cVTagEnablity.IntValue == true false);
}

void PrintDebugMsg() {
    if(!
g_bDebug) return;
    
    
char p_sDebugMsg[2096];
    
    
Format(p_sDebugMsgsizeof(p_sDebugMsg), " >> [ DEBUG ] Real-time Debugger\n");
    
    
// Format Info
    
if(g_cGSCurrentState == GS_CAP) {
        
Format(p_sDebugMsgsizeof(p_sDebugMsg), "%s >> GameState : %d\n"p_sDebugMsgview_as<int>(g_cGSCurrentState));
        
Format(p_sDebugMsgsizeof(p_sDebugMsg), "%s >> GameTime : %f\n"p_sDebugMsgGetGameTime());
        
Format(p_sDebugMsgsizeof(p_sDebugMsg), "%s >> g_AiCapList - T : %d\n"p_sDebugMsgg_AiCapList[0]);
        
Format(p_sDebugMsgsizeof(p_sDebugMsg), "%s >> g_AiCapList - CT : %d\n"p_sDebugMsgg_AiCapList[1]);
        
Format(p_sDebugMsgsizeof(p_sDebugMsg), "%s >> g_iCapForceTemp : %d\n"p_sDebugMsgg_iCapForceTemp);
        
Format(p_sDebugMsgsizeof(p_sDebugMsg), "%s >> g_flCapRestrictTimer : %f %f\n"p_sDebugMsgg_flCapRestrictTimerg_flCapRestrictTimer GetGameTime());
        
Format(p_sDebugMsgsizeof(p_sDebugMsg), "%s >> g_flCapUserMessageTimer : %f %f\n"p_sDebugMsgg_flCapUserMessageTimerg_flCapUserMessageTimer GetGameTime());
    }
    
    
// Print
    
SetHudTextParams(0.050.050.05255255255255);
    for(new 
i=1i<=MaxClientsi++) if(IsValidClient(i)) {
        
ClearSyncHud(ig_hDebugHud);
        
ShowSyncHudText(ig_hDebugHudp_sDebugMsg);
        
SetEntProp(iProp_Send"m_iHideHUD"GetEntProp(iProp_Send"m_iHideHUD") | << 12);
    }
}

void PrintDebugAlert(char[] m_sDebugNamechar[][] m_sDebugMsgint m_iFDSizeDebugOutput m_cDOOutputtype DEBUG_LOGm_iTarget 0) {
    if(!
g_bDebug) return;
    
    
char p_sFinalPrint[5096];
    if((
m_cDOOutputtype DEBUG_ALLCHAT) || (m_cDOOutputtype DEBUG_CHAT)) Format(p_sFinalPrintsizeof(p_sFinalPrint), " \x0A>> \x02[ DEBUG ] \x04Debugging \x07%s \x01...\n\n"m_cDebugName);
    else 
Format(p_sFinalPrintsizeof(p_sFinalPrint), " >> [ DEBUG ] Debugging %s ...\n\n"m_sDebugName);
    
    for(
int i=0i<=m_iFDSize 1i++) {
        if((
m_cDOOutputtype DEBUG_ALLCHAT) || (m_cDOOutputtype DEBUG_CHAT)) Format(p_sFinalPrintsizeof(p_sFinalPrint), "%s \x0A>> \x02%d \x01| \x04%s\x01\n"p_sFinalPrint1m_sDebugMsg[i]);
        else 
Format(p_sFinalPrintsizeof(p_sFinalPrint), "%s >> %d | %s\n"p_sFinalPrint1m_sDebugMsg[i]);
    }
    
    if((
m_cDOOutputtype DEBUG_ALLCHAT) || (m_cDOOutputtype DEBUG_CHAT)) Format(p_sFinalPrintsizeof(p_sFinalPrint), "\n%s \x0A>> \x02Debug Report \x01is \x04Ended.\x01"p_sFinalPrint);
    else 
Format(p_sFinalPrintsizeof(p_sFinalPrint), "\n%s >> Debug Report is Ended."p_sFinalPrint);
    
    if(
m_cDOOutputtype DEBUG_ALLCHATPrintToChatAll(p_sFinalPrint);
    if(
m_cDOOutputtype DEBUG_CHAT) if(IsValidClient(m_iTarget)) PrintToChat(m_iTargetp_sFinalPrint);
    if(
m_cDOOutputtype DEBUG_HUD) if(IsValidClient(m_iTarget)) {
        
ClearSyncHud(m_iTargetg_hDebugAlertHud);
        
SetHudTextParams(0.850.055.0255255255255);
        
ShowSyncHudText(m_iTargetg_hDebugAlertHudp_sFinalPrint);
    }
    if(
m_cDOOutputtype DEBUG_HUDALL) {
        
SetHudTextParams(0.850.055.0255255255255);
        for(
int i=1i<=MaxClientsi++) {
            if(
IsValidClient(i)) {
                
ClearSyncHud(ig_hDebugAlertHud);
                
ShowSyncHudText(ig_hDebugAlertHudp_sFinalPrint);
            }
        }
    }
    if(
m_cDOOutputtype DEBUG_LOGLogMessage(p_sFinalPrint);
}


/* 


Error is @

PHP Code:

public Action o_CBCapForceManage(clientargs) {
    if(!
IsValidClient(client)) return Plugin_Handled;
    
    new 
Handle:menu CreateMenu(o_CBMenuPlayerList); // <- Error & Line 332
    
SetMenuTitle(menu"Please Select A Player for Cap.");
    
    new 
AvaliablePlayers 0;
    
    for(new 
i=1i<=MaxClientsi++) {
        if(
IsValidClient(i)) if(!IsSpectator(i)) if(!IsPlayerCap(i)) {
            new 
String:ii[3], String:name[MAX_NAME_LENGTH];
            
IntToString(iii3);
            
GetClientName(inamesizeof(name));
            
            
AddMenuItem(menuiiname);
            
            
AvaliablePlayers++
        }
    }
    
SetMenuExitButton(menutrue);
    if(
AvaliablePlayers 0DisplayMenu(menuclient0);
    else 
CloseHandle(menu);
    
    return 
Plugin_Continue;





https://imgur.com/a/fN6YkJj

I searched error for 2 hours and still can't find it...

Help !

scorpius2k1 04-29-2019 15:16

Re: warning 219: local variable "menu" shadows a variable at a preceding level
 
You cannot call the Handle 'menu' since you are calling it in your 'public int o_CBMenuPlayerList'. Either rename it in one or the other. This should fix that part, I just renamed the Handle and all references in 'public Action o_CBCapForceManage' to 'menuPlayerList':

PHP Code:

public Action o_CBCapForceManage(clientargs) {
    if(!
IsValidClient(client)) return Plugin_Handled;
    
    new 
Handle:menuPlayerList CreateMenu(o_CBMenuPlayerList);
    
SetMenuTitle(menuPlayerList"Please Select A Player for Cap.");
    
    new 
AvaliablePlayers 0;
    
    for(new 
i=1i<=MaxClientsi++) {
        if(
IsValidClient(i)) if(!IsSpectator(i)) if(!IsPlayerCap(i)) {
            new 
String:ii[3], String:name[MAX_NAME_LENGTH];
            
IntToString(iii3);
            
GetClientName(inamesizeof(name));
            
            
AddMenuItem(menuPlayerListiiname);
            
            
AvaliablePlayers++
        }
    }
    
SetMenuExitButton(menuPlayerListtrue);
    if(
AvaliablePlayers 0DisplayMenu(menuPlayerListclient0);
    else 
CloseHandle(menuPlayerList);
    
    return 
Plugin_Continue;


This is the public int you are calling it from and getting the warning from (you named it 'Handle menu' here too)

PHP Code:

public int o_CBMenuPlayerList(Handle menuMenuAction actionint clientint pos) { 


Hope this helps!

NC.svtrade 04-29-2019 15:22

Re: warning 219: local variable "menu" shadows a variable at a preceding level
 
It fixed ! Thank you for the help ! :D


All times are GMT -4. The time now is 13:31.

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