22.07.2015, 18:20
(
Last edited by Threshold; 22/07/2015 at 06:53 PM.
)
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;
}