anti cmd flood
#2

pawn Code:
#include <a_samp>

new LastChat[MAX_PLAYERS], ChatWarns[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    LastChat[playerid] = 0; // Not really necessary, but you can add it if you want.
    ChatWarns[playerid] = 0; // Reset the chat warnings for new players
    return 1;
}

public OnPlayerText(playerid, text[])
{
    new time = gettime(); // Gets the current time as a unix timestamp (seconds)
    if((time - LastChat[playerid]) <= 3) // If the time between their last message and now is less than 3 seconds
    {
        SendClientMessage(playerid, -1, "[ Don`t Spam ! You can use the chat every 3 seconds ]");
        if(++ChatWarns[playerid] >= 3) Kick(playerid); // Kick player if they have spammed at least 3 times
        return 0; // Stops the message being sent to main chat
    }
    LastChat[playerid] = time; // Saving the time of their new message
    ChatWarns[playerid] = 0; // Reset the chat warnings

    // Rest of your OnPlayerText
   
    return 1;
}
Reply


Messages In This Thread
anti cmd flood - by PepsiCola23 - 22.07.2015, 18:15
Re: anti cmd flood - by Threshold - 22.07.2015, 18:20
Re: anti cmd flood - by dominik523 - 22.07.2015, 18:23
Re: anti cmd flood - by PepsiCola23 - 22.07.2015, 18:30
Re: anti cmd flood - by Threshold - 22.07.2015, 18:55
Re: anti cmd flood - by PepsiCola23 - 22.07.2015, 20:05

Forum Jump:


Users browsing this thread: 1 Guest(s)