SA-MP Forums Archive
Anti spam! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Anti spam! (/showthread.php?tid=361309)



Anti spam! - bakarihl - 20.07.2012

Hello guys, again me, now i have problem with chat spammers/command spammers, i have some chat spammers and some command spammers at server and i want to stop it, how can i do it? Exist any fs or?


Re: Anti spam! - Kindred - 20.07.2012

You could always do something like this:

pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if((commandTime[playerid] - gettime()) > 0)
    {
        SendClientMessageEx(playerid, COLOR_WHITE, "You are muted from submitting commands right now.");
        return 0;
    }
    else if(commandAttempts[playerid] >= 5)
    {
        commandTime[playerid] = gettime() + 10;
        SendClientMessageEx(playerid, COLOR_YELLOW, "You have been muted automatically for spamming. Please wait 10 seconds and try again.");
        return 0;
    }
    commandAttempts[playerid]++;
    return 1;
}
If not incorrect, this requires ZCMD, and the use of making the variables yourself.


Re: Anti spam! - Benjo - 20.07.2012

Hi,

I would suggest the first lines of code within the OnPlayerText and OnPlayerCommandText callbacks should be a timer that raises a flag.

Next, you want an If statement that checks if the flag has been raised. If it has, return 0;

Finally, you will need to create a function that the timer calls, which will reset the flag to false.

Good luck!


Re: Anti spam! - bakarihl - 20.07.2012

Quote:
Originally Posted by Kindred
Посмотреть сообщение
You could always do something like this:

pawn Код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
    if((commandTime[playerid] - gettime()) > 0)
    {
        SendClientMessageEx(playerid, COLOR_WHITE, "You are muted from submitting commands right now.");
        return 0;
    }
    else if(commandAttempts[playerid] >= 5)
    {
        commandTime[playerid] = gettime() + 10;
        SendClientMessageEx(playerid, COLOR_YELLOW, "You have been muted automatically for spamming. Please wait 10 seconds and try again.");
        return 0;
    }
    commandAttempts[playerid]++;
    return 1;
}
If not incorrect, this requires ZCMD, and the use of making the variables yourself.
i tryed to add it but it doesn't work, like5 errors :o


Re: Anti spam! - Kindred - 20.07.2012

Obviously, you will need to create the variables yourself.

pawn Код:
new commanTime[MAX_PLAYERS], commandAttempts[MAX_PLAYERS];
//etcetra



Re: Anti spam! - SuperViper - 20.07.2012

https://sampforum.blast.hk/showthread.php?tid=338516

It can detect spamming and much, much more.


Re: Anti spam! - bakarihl - 20.07.2012

I think i need only anti spam this command
pawn Код:
// This command allows the player to call for assistance
COMMAND:assist(playerid, params[])
{
    // Setup local variables
    new bool:AssistOnline = false, Msg[128], Name[24];

    // Send the command to all admins so they can see it
    SendAdminText(playerid, "/assist", params);

    // Check if the player has logged in
    if (APlayerData[playerid][LoggedIn] == true)
    {
        // Get the player's name
        GetPlayerName(playerid, Name, sizeof(Name));
        // Preset the message that needs to be sent to assistance players
        format(Msg, 128, "{00FF00}Player {FFFF00}%s{00FF00} needs assistance, go help him", Name);

        // Check if there is at least one assistance player online
        for (new i; i < MAX_PLAYERS; i++)
        {
            // Check if this player is connected
            if (IsPlayerConnected(i))
            {
                // Check if this player is assistance class
                if (APlayerData[i][PlayerClass] == ClassAssistance)
                {
                    // Set the flag to indicate that at least one assistance player is online
                    AssistOnline = true;
                    // Send the assistance player a message to inform him who needs assistance
                    SendClientMessage(i, 0xFFFFFFFF, Msg);
                }
            }
        }

        // Check if there is at least one assistance player online
        if (AssistOnline == true)
        {
            // Set yourself as "AssistanceNeeded"
            APlayerData[playerid][AssistanceNeeded] = true;
            // Let the player know he called for assistance
            SendClientMessage(playerid, 0xFFFFFFFF, "{00FF00}You've called for assistance");
        }
        else // No assistance is online
        {
            // Check if the player is the driver of a vehicle
            if (GetPlayerVehicleSeat(playerid) == 0)
            {
                // Fully repair the vehicle (damage value and bodywork)
                RepairVehicle(GetPlayerVehicleID(playerid));
                // Also re-fuel the vehicle
                AVehicleData[GetPlayerVehicleID(playerid)][Fuel] = MaxFuel;
                // Let the player pay for the repairs and refuel (default $2000)
                RewardPlayer(playerid, -2000, 0);
                // Let the player know he spent $2000 for auto-repair because there were no assistance players online
                SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Your vehicle has been auto-repaired and refuelled for $2000");
                SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}because there is no assistance player online");
            }
        }
    }
    else
        return 0;

    // Let the server know that this was a valid command
    return 1;
}