ANTI SPAM For Commands
#1

Hi! How can i create an anti spam system for commands like this:

https://imgur.com/a/F0u1UHS

And if anti spam 0 player will be able to use commands again.
Reply
#2

If you're using zcmd, it is the code:

Код:
public OnPlayerCommandReceived(playerid, cmdtext[]){

	if(GetPVarInt(playerid, "AntiSpam") > gettime())//checking if 3 seconds is elapsed 
	{
		new string[128];
		format(string, 128, "Wait %d seconds to use a command again!", GetPVarInt(playerid, "AntSpam")-gettime());
		SendClientMessage(playerid, -1, string);
		return 0;
	}
	return 1;
}

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
	if(success)
	{
		//When the command is valid, anti spam is enable
		SetPVarInt(playerid, "AntiSpam", gettime()+3);//It gets the current time and add 3 seconds
	}
}
Reply
#3

Quote:
Originally Posted by iHollyZinhO
Посмотреть сообщение
If you're using zcmd, it is the code:

Код:
public OnPlayerCommandReceived(playerid, cmdtext[]){

	if(GetPVarInt(playerid, "AntiSpam") > gettime())//checking if 3 seconds is elapsed 
	{
		new string[128];
		format(string, 128, "Wait %d seconds to use a command again!", GetPVarInt(playerid, "AntSpam")-gettime());
		SendClientMessage(playerid, -1, string);
		return 0;
	}
	return 1;
}

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
	if(success)
	{
		//When the command is valid, anti spam is enable
		SetPVarInt(playerid, "AntiSpam", gettime()+3);//It gets the current time and add 3 seconds
	}
}
Does not work it says ''Wait 0 seconds to use a command again''
Reply
#4

Quote:
Originally Posted by iHollyZinhO
Посмотреть сообщение
If you're using zcmd, it is the code:

Код:
public OnPlayerCommandReceived(playerid, cmdtext[]){

	if(GetPVarInt(playerid, "AntiSpam") > gettime())//checking if 3 seconds is elapsed 
	{
		new string[128];
		format(string, 128, "Wait %d seconds to use a command again!", GetPVarInt(playerid, "AntSpam")-gettime());
		SendClientMessage(playerid, -1, string);
		return 0;
	}
	return 1;
}

public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{
	if(success)
	{
		//When the command is valid, anti spam is enable
		SetPVarInt(playerid, "AntiSpam", gettime()+3);//It gets the current time and add 3 seconds
	}
}
Modify these

SetPVarInt(playerid, "AntiSpam", gettime()+3);

to

SetPVarInt(playerid, "AntiSpam", (gettime()+3));


if(GetPVarInt(playerid, "AntiSpam") > gettime())

to

if((gettime() - GetPVarInt(playerid, "AntiSpam")) > 3)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)