SA-MP Forums Archive
ANTI SPAM For Commands - 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 For Commands (/showthread.php?tid=658355)



ANTI SPAM For Commands - Cezar98 - 02.09.2018

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.


Re: ANTI SPAM For Commands - iHollyZinhO - 02.09.2018

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
	}
}



Re: ANTI SPAM For Commands - Cezar98 - 02.09.2018

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''


Re: ANTI SPAM For Commands - ShihabSoft - 03.09.2018

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)