SA-MP Forums Archive
[AJUDA] /Relatorio com Anti-Flood (Erros) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [AJUDA] /Relatorio com Anti-Flood (Erros) (/showthread.php?tid=270831)



[AJUDA] /Relatorio com Anti-Flood (Erros) - Kuddy - 21.07.2011

Bom, tentei criar um anti flood, porйm sou nгo consegui (este й o primeiro sistema 100% criado por mim, entгo queria saber onde estб o erro).


Topo GM:
pawn Код:
new PermTuto;
new PermTutopl;
forward PermTutopl(playerid); // linha 38
pawn Код:
if(strcmp(cmd, "/relatorio", true) == 0)
    {
        if(PermTuto[playerid] == 0)/*Linha do erro || 2990 */
        {
            if(IsPlayerConnected(playerid))
            {
                PermTuto[playerid] = 1;
                SetTimerEx("PermTutopl",10000,false,"i",playerid);
                new length = strlen(cmdtext);
                while ((idx < length) && (cmdtext[idx] <= ' '))
                {
                    idx++;
                }
                new offset = idx;
                new result[128];
                while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                {
                    result[idx - offset] = cmdtext[idx];
                    idx++;
                }
                result[idx - offset] = EOS;
                if(!strlen(result))
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "USE: /relatorio [texto]");
                    return 1;
                }
                if(PlayerInfo[playerid][pVIP] == 1)
                {
                    format(string, sizeof(string), "[RELATУRIO VIP Bronze] %s (%d): %s", sendername,playerid, (result));
                    SendAdminMessage(COLOR_GREEN,string);
                }
                else if(PlayerInfo[playerid][pVIP] == 2)
                {
                    format(string, sizeof(string), "[RELATУRIO VIP Silver] %s (%d): %s", sendername,playerid, (result));
                    SendAdminMessage(COLOR_PINK,string);
                }
                else if(PlayerInfo[playerid][pVIP] == 3)
                {
                    format(string, sizeof(string), "[RELATУRIO VIP Gold] %s (%d): %s", sendername,playerid, (result));
                    SendAdminMessage(COLOR_BLUE,string);
                }
                else
                {
                format(string, sizeof(string), "[RELATУRIO]: %s (%d): %s", sendername,playerid, (result));
                SendTesterAdminMessage(COLOR_RED,string);
                SendClientMessage(playerid, COLOR_GREEN, "Seu Relatуrio Foi Enviado Aos Admins e Testers Online.");
                new y, m, d;
                new h,mi,s;
                getdate(y,m,d);
                gettime(h,mi,s);
                format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /relatorio %s",d,m,y,h,mi,s,sendername, (result));
                CommandLog(string);
                ReportLog(string);
            }
           }
        }
        return 1;
    }
Publics:
pawn Код:
public PermTutopl(playerid)
{
    PermTuto[playerid] = 0;
}
Erros:
Quote:

Compilando Roleplay.pwn...

D:\SA-MP\Gunners\gamemodes\Roleplay.pwn(3 : error 021: symbol already defined: "PermTutopl"

D:\SA-MP\Gunners\gamemodes\Roleplay.pwn(16497) : warning 217: loose indentation // Mal identado :S

D:\SA-MP\Gunners\gamemodes\Roleplay.pwn(29990) : error 028: invalid subscript (not an array or too many subscripts): "PermTuto"
D:\SA-MP\Gunners\gamemodes\Roleplay.pwn(29990) : warning 215: expression has no effect
D:\SA-MP\Gunners\gamemodes\Roleplay.pwn(29990) : error 001: expected token: ";", but found "]"
D:\SA-MP\Gunners\gamemodes\Roleplay.pwn(29990) : error 029: invalid expression, assumed zero
D:\SA-MP\Gunners\gamemodes\Roleplay.pwn(29990) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


5 Errors.




Re: [AJUDA] /Relatorio com Anti-Flood (Erros) - RockFire - 21.07.2011

PHP код:
new Flood[MAX_PLAYERS];

public 
OnPlayerCommandText(playerid,cmdtext[])
{
    if(!
strcmp(cmdtext,"/relatorio",true))
    {
        if(
Flood[playerid] > gettime())
            return 
SendClientMessage(playerid,-1,"Sem flood");
    
        
Flood[playerid] = gettime()+5;
    
        
//Resto do comando
    
        
return 1;
    }
    return 
0;




Re: [AJUDA] /Relatorio com Anti-Flood (Erros) - Kuddy - 21.07.2011

Obrigado feliperch, porйm vocк nгo me disse o que havia de errado com o meu code, alguem pode me explicar?


Re: [AJUDA] /Relatorio com Anti-Flood (Erros) - Shadoww5 - 21.07.2011

PHP код:
new timer[MAX_PLAYERS];
public 
OnPlayerCommandText(playeridcmdtext[])
{
    if(
strcmp(cmd"/relatorio"true) == 0)
    {
        if(
timer[playerid] > gettime()) return SendClientMessage(playerid0xFFFF00FF"Aguarde 10 segundos para usar este comando de novo.");
        new 
length strlen(cmdtext);
        while ((
idx length) && (cmdtext[idx] <= ' '))
        {
            
idx++;
        }
        new 
offset idx;
        new 
result[128];
        while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
        {
            
result[idx offset] = cmdtext[idx];
            
idx++;
                }
        
result[idx offset] = EOS;
        if(!
strlen(result)) return SendClientMessage(playeridCOLOR_GRAD2"USE: /relatorio [texto]");
        if(
PlayerInfo[playerid][pVIP] == 1
        { 
            
format(stringsizeof(string), "[RELATУRIO VIP Bronze] %s (%d): %s"sendername,playerid, (result)); 
            
SendAdminMessage(COLOR_GREEN,string); 
        }
        else if(
PlayerInfo[playerid][pVIP] == 2
        { 
            
format(stringsizeof(string), "[RELATУRIO VIP Silver] %s (%d): %s"sendername,playerid, (result)); 
            
SendAdminMessage(COLOR_PINK,string); 
        }
        else if(
PlayerInfo[playerid][pVIP] == 3
        { 
            
format(stringsizeof(string), "[RELATУRIO VIP Gold] %s (%d): %s"sendername,playerid, (result)); 
            
SendAdminMessage(COLOR_BLUE,string); 
        }
        else
        {
            
format(stringsizeof(string), "[RELATУRIO]: %s (%d): %s"sendername,playerid, (result));
            
SendTesterAdminMessage(COLOR_RED,string);
        }
        
SendClientMessage(playeridCOLOR_GREEN"Seu Relatуrio Foi Enviado Aos Admins e Testers Online.");
        new 
ymd;
        new 
h,mi,s;
        
getdate(y,m,d);
        
gettime(h,mi,s);
        
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /relatorio %s",d,m,y,h,mi,s,sendername, (result));
        
CommandLog(string);
        
ReportLog(string);
        
timer[playerid] = gettime()+10;
        return 
1;
    }
    return 
0;

#EDIT

Seu erro й que vocк tinha criado uma variavel unica, ou seja, que nгo seria usada para cada jogador individualmente, confira a diferenзa:

PHP код:
new PermTuto
PHP код:
if(PermTuto[playerid] == 0