GTA Közösség - A magyar GTA fórum

San Andreas Multiplayer (SA-MP) => SA-MP: Szerverfejlesztés => Segítségkérés => A témát indította: Nátha - 2012. június 06. - 13:47:50

Cím: Anti Flood
Írta: Nátha - 2012. június 06. - 13:47:50
Kellene egy olyan script hogyha ír valaki a chat re akkor 3 másodperc után írhassa a következõt. Ha meg nem várja meg a 3 másodpercet és írna akkor meg írja ki neki pirossal hogy Kérlek írj lassabban !
Cím: Anti Flood
Írta: Gabor.. - 2012. június 06. - 14:01:50

#include   <     a_samp    >
public OnFilterScriptInit( )
{
    SetTimer( \"Update\", 3000, true );
}
public OnPlayerConnect( playerid )
{
    SetPVarInt( playerid, \"Flood\", 0 );
    return 1;
}
public OnPlayerText( playerid, text[] )
{
    SetPVarInt( playerid, \"Flood\", GetPVarInt( playerid, \"Flood\" ) + 1 );
    if( GetPVarInt( playerid, \"Flood\" ) > 1 )
    {
        SendClientMessage( playerid, 0xFF0000AA, \"HIBA: 3 Másodpercenként küldhetsz üzenetet, Írj lassabban!\" );
    }
    return 0;
}
forward Update( playerid );
public Update( playerid )
{
    foreach(Player, i)
    {
        if( GetPVarInt( i, \"Flood\" ) > 0  )
        {
           SetPVarInt( i, \"Flood\", 0 );
        }
    }
}

Most gyors írtam egyet, nem biztos, hogy jó, nem teszteltem.
Cím: Anti Flood
Írta: Nátha - 2012. június 06. - 14:08:27
Nekem úgy kellene hogyha 3 másodpercen belül akar írni valamit az ne jelenjen meg a chat en és akkor írja ki neki hogy Kérlek írj lassabban !
Cím: Anti Flood
Írta: Norby - 2012. június 06. - 15:55:18
#include   <     a_samp    >
public OnFilterScriptInit( )
{
    SetTimer( \"Update\", 3000, true );
}
public OnPlayerConnect( playerid )
{
    SetPVarInt( playerid, \"Flood\", 0 );
    return 1;
}
public OnPlayerText( playerid, text[] )
{
    SetPVarInt( playerid, \"Flood\", GetPVarInt( playerid, \"Flood\" ) + 1 );
    if( GetPVarInt( playerid, \"Flood\" ) > 1 )
    {
        SendClientMessage( playerid, 0xFF0000AA, \"HIBA: 3 Másodpercenként küldhetsz üzenetet, Írj lassabban!\" );
    }
    return 0;
}
forward Update( playerid );
public Update( playerid )
{
    foreach(Player, i)
    {
        if( GetPVarInt( i, \"Flood\" ) > 0  )
        {
           SetPVarInt( i, \"Flood\", 0 );
        }
    }
}

 
Így... Az OnPlayerText-nél return 0; ne térjen vissza!
Cím: Anti Flood
Írta: Nátha - 2012. június 06. - 18:34:41
De most meg error os:
 
C:\\Documents and Settings\\Robi\\Asztal\\Új mappa (4)\\new.pwn(28) : error 017: undefined symbol \"foreach\"
C:\\Documents and Settings\\Robi\\Asztal\\Új mappa (4)\\new.pwn(30) : error 017: undefined symbol \"i\"
C:\\Documents and Settings\\Robi\\Asztal\\Új mappa (4)\\new.pwn(32) : error 017: undefined symbol \"i\"
Pawn compiler 3.2.3664           Copyright (c) 1997-2006, ITB CompuPhase
 
3 Errors.
Cím: Anti Flood
Írta: Gabor.. - 2012. június 06. - 18:37:51
#include   <     a_samp    >
#include   <     foreach   >
public OnFilterScriptInit( )
{
    SetTimer( \"Update\", 3000, true );
}
public OnPlayerConnect( playerid )
{
    SetPVarInt( playerid, \"Flood\", 0 );
    return 1;
}
public OnPlayerText( playerid, text[] )
{
    SetPVarInt( playerid, \"Flood\", GetPVarInt( playerid, \"Flood\" ) + 1 );
    if( GetPVarInt( playerid, \"Flood\" ) > 1 )
    {
        SendClientMessage( playerid, 0xFF0000AA, \"HIBA: 3 Másodpercenként küldhetsz üzenetet, Írj lassabban!\" );
    }
    return 0;
}
forward Update( playerid );
public Update( playerid )
{
    foreach(Player, i)
    {
        if( GetPVarInt( i, \"Flood\" ) > 0  )
        {
           SetPVarInt( i, \"Flood\", 0 );
        }
    }
}

Szükséges hozzá foreach.inc!
Cím: Anti Flood
Írta: Zsolesszka - 2012. június 06. - 18:48:53
baseaf.inc
 
#include <a_samp>
static iPlayerChatTime[MAX_PLAYERS];
stock
IsPlayerFlooding(playerid)
{
if(GetTickCount() - iPlayerChatTime[playerid] < 2000)
    return 1;
return 0;
}
public
OnPlayerText(playerid, text[])
{
// Is the player flooding?
if(IsPlayerFlooding(playerid) && !IsPlayerAdmin(playerid))
{
    SendClientMessage(playerid, 0xFF0000FF, \"* You can only send a message once every two seconds.\");
    return 0;
}
iPlayerChatTime[playerid] = GetTickCount();
// bla bla..
 
    return 1;
}
public
OnPlayerDisconnect(playerid, reason)
{
iPlayerChatTime[playerid] = 0;
return 1;
}
public
OnPlayerCommandText(playerid, cmdtext[])
{
if(IsPlayerFlooding(playerid) && !IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, 0xFF0000FF, \"* You can only use commands once every two seconds.\");
    return 1;
}
iPlayerChatTime[playerid] = GetTickCount();
// command .....
 
return 0;
}

 
Legelsõ filterszkript-be -ként kell beleírni\\betenni.
server.cfg
filterscripts baseaf (többi szkript neve)
Cím: Anti Flood
Írta: Nátha - 2012. június 06. - 19:14:35
baseaf.inc
    #include <a_samp>
     
    static iPlayerChatTime[MAX_PLAYERS];
     
    stock
            IsPlayerFlooding(playerid)
    {
            if(GetTickCount() - iPlayerChatTime[playerid] < 2000)
                return 1;
     
            return 0;
    }
     
    public
            OnPlayerText(playerid, text[])
    {
            // Is the player flooding?
            if(IsPlayerFlooding(playerid) && !IsPlayerAdmin(playerid))
            {
                SendClientMessage(playerid, 0xFF0000FF, \"* You can only send a message once every two seconds.\");
                return 0;
            }
            iPlayerChatTime[playerid] = GetTickCount();
    // bla bla..
     
     
        return 1;
    }
     
    public
            OnPlayerDisconnect(playerid, reason)
    {
            iPlayerChatTime[playerid] = 0;
            return 1;
    }
     
    public
            OnPlayerCommandText(playerid, cmdtext[])
    {
            if(IsPlayerFlooding(playerid) && !IsPlayerAdmin(playerid))
            {
                    SendClientMessage(playerid, 0xFF0000FF, \"* You can only use commands once every two seconds.\");
                return 1;
            }
            iPlayerChatTime[playerid] = GetTickCount();
    // command .....
     
     
            return 0;
    }

 
Legelsõ filterszkript-be -ként kell beleírni\\betenni.
server.cfg
filterscripts baseaf (többi szkript neve)
[/quote]
Kösz, mûködik ! ;D