[Ajuda] Flood no comando [Promover]
#1

Olб, boa noite!

O comando /promover estб com um BUG.
Quando promovemos a [444 ou 555], ele funciona normalmente.
Agora quando promover a um cargo de 1 а 5 ele flood a tela inteira. Porque isso estб acontecendo ?!


pawn Код:
//>-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    if(strcmp(cmd, "/promover", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "Use:  /Promover [id] [Cargos 1 a 5] OBS:[Cargos 444 e 555 sгo Sub-Lideres]");
                return true;
            }
            new para1;
            new level;
            para1 = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            level = strval(tmp);
            if(level != 1 && level != 2 && level != 3 && level != 4 && level != 5 && level != 444 && level != 555)
            {
                SendClientMessage(playerid, COLOR_GREY, "   [Cargos 1 a 5] OBS:Cargos 444 e 555 sгo Sub-Lideres");
                return true;
            }
            if (PlayerInfo[playerid][pLider] > 0)
            {
                if(IsPlayerConnected(para1))
                {
                    for(new i = 0; i < MAX_PLAYERS; i++)
                    {
                        if(PlayerInfo[para1][pMembro] == PlayerInfo[playerid][pLider])
                        {
                            if(para1 != INVALID_PLAYER_ID)
                            {
                                GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                                GetPlayerName(playerid, sendername, sizeof(sendername));
                                PlayerInfo[para1][pCargo] = level;
                                format(string, sizeof(string), "   Vocк foi promovido pelo lнder %s", PlayerName(playerid));
                                SendClientMessage(para1, COLOR_LIGHTBLUE, string);
                                format(string, sizeof(string), "   Vocк promoveu %s a cargo %d.", giveplayer,level);
                                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                                new org = PlayerInfo[playerid][pLider];
                                if(level == 555)
                                {
                                    if(strcmp(InfoOrg[org][Sub555],"Ninguem",true)==0)
                                    {
                                        DemitirInfoOrg(giveplayer);
                                        ConviteInfoOrg(giveplayer, org, 555);

                                    }
                                    else
                                    {
                                        strmid(string, InfoOrg[org][Sub555], 0, strlen(InfoOrg[org][Sub555]), 255);
                                        DemitirInfoOrg(giveplayer);
                                        DemitirInfoOrg(InfoOrg[org][Sub555]);
                                        ConviteInfoOrg(string, org, 4);
                                        ConviteInfoOrg(giveplayer, org, 555);
                                    }
                                    return true;
                                }
                                else if(level == 444)
                                {
                                    if(strcmp(InfoOrg[org][Sub444],"Ninguem",true)==0)
                                    {
                                        DemitirInfoOrg(giveplayer);
                                        DemitirInfoOrg(giveplayer);
                                        ConviteInfoOrg(giveplayer, org, 444);

                                    }
                                    else
                                    {
                                        strmid(string, InfoOrg[org][Sub444], 0, strlen(InfoOrg[org][Sub444]), 255);
                                        DemitirInfoOrg(giveplayer);
                                        DemitirInfoOrg(InfoOrg[org][Sub444]);
                                        ConviteInfoOrg(string, org, 4);
                                        ConviteInfoOrg(giveplayer, org, 444);
                                    }
                                    return true;
                                }
                                if(strcmp(InfoOrg[org][Sub555],giveplayer,true)==0)
                                {
                                    if(level < 444)
                                    {
                                        DemitirInfoOrg(giveplayer);
                                        ConviteInfoOrg(giveplayer, org, level);
                                    }
                                    return true;
                                }
                            }
                            if(PlayerInfo[para1][pMembro] != PlayerInfo[playerid][pLider])
                            {
                                SendClientMessage(playerid, COLOR_GREY, "Nгo pode promover quem nгo й da sua org.");
                                return true;
                            }
                        }
                    }
                }//not connected
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "Vocк nгo й um lнder !");
            }
        }
        return true;
    }
Vlw!
Reply
#2

Tira isso. O loop:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
Nгo vi vocк usando a variбvel i, mas vocк me pergunta: Por que com 444 e 555 dava certo? Porque vocк criou uma condicional para se o cargo for 444 ou 555, no final, ele retorna true. E com o resto dos valores nгo aconteceria isso, pois vocк nгo colocou um retorno, e as mensagens se repetiriam 500, ou 1000 vezes, nгo sei a quantidade mбxima de players que pode agora. kkk
Reply
#3

Olб, boa noite!

Rodney Francalim, oloko. 1000 vezes ?! kkkkkkk
Vou testar e jб edito.

Vlw!
Reply
#4

Se quiser saber quantas vezes se repete, basta fazer isso:
pawn Код:
GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                                GetPlayerName(playerid, sendername, sizeof(sendername));
                                PlayerInfo[para1][pCargo] = level;
                                format(string, sizeof(string), "   Vocк foi promovido pelo lнder %s", PlayerName(playerid));
                                SendClientMessage(para1, COLOR_LIGHTBLUE, string);
                                format(string, sizeof(string), "   Vocк promoveu %s a cargo %d.", giveplayer,level);
                                SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                                new org = PlayerInfo[playerid][pLider];
                                printf( "MSG %d", i ); // ADICIONE ISSO
Olha no MS-DOS do samp-server.exe.
Reply
#5

Olб, boa noite!

Rodney Francalim, pegou normal. Vlw!
Reputado!

Obrigado!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)