Portal SAMP
[Ajuda] shadows a variable at a preceding level - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] shadows a variable at a preceding level (/showthread.php?tid=4220)



shadows a variable at a preceding level - L10motos - 17/11/2023

warning 219: local variable "slot_weapon" shadows a variable at a preceding level

Código PHP:
forward SetPlayerWeapons(playerid);
public 
SetPlayerWeapons(playerid)
{
    if(
IsPlayerConnected(playerid))
    {
        ResetPlayerWeapons(playerid);

    
    if(PlayerInfo[playerid][pLevel] > 1)
        {
            if(PlayerInfo[playerid][pJailed] > 0) return 0;
    
        if(Gangs(playerid)) GivePlayerWeaponEx(playerid51gTeam[playerid]);
            if(
gTeam[playerid] == O_REPORTERGivePlayerWeaponEx(playerid43100gTeam[playerid]);

            for(new 
slot_weapon 0slot_weapon SLOTS_WEAPONslot_weapon++) GivePlayerWeaponEx(playeridPlayerInfo[playerid][pWeapon][slot_weapon], PlayerInfo[playerid][pAmmo][slot_weapon], PlayerInfo[playerid][pWeaponcode][PlayerInfo[playerid][pWeapon][slot_weapon]]); //erro aqui
        
}
    }
    return 
1;




RE: shadows a variable at a preceding level - xbruno1000x - 18/11/2023

Código:
for(new slot_weapon = 0;

Você criou uma variável que já existe.