Anti spam for PM [help][reps]
#1

How to make Anti SPAM for PM ? thanks
Код:
CMD:pm(playerid,params[])
{
	if(PmDialog == 1)
	{
        new id;
        if(sscanf(params, "u", id)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick>");
		if(IsPlayerConnected(id))
		{
             pInfo[playerid][Clicked] = id;
		     format(Jstring,sizeof(Jstring),"PM To %s(ID: %d) Type you message:", GetName(id), id);
             return ShowPlayerDialog(playerid,DIALOG_PRIVATE_MESSAGE,DIALOG_STYLE_INPUT,"Private Message",Jstring,"Send","Cancel");
		}
		else return ShowMessage(playerid, red, 2);
	}
	else
	{
        new id,Message[128];
        if(sscanf(params, "us[128]",id, Message)) return SendClientMessage(playerid, lighterblue, "Usage: /pm <PlayerID/Part of Nick> <Message>");
		if(IsPlayerConnected(id))
		{
             return OnPrivateMessage(playerid, id, Message);
		}
		else return ShowMessage(playerid, red, 2);
	}
}
Reply
#2

This methods would work for all kinds of spam.

pawn Код:
if(GetPVarInt(playerid, "lastcommand") > GetTickCount())
{
    SendClientMessage(playerid, 0x00FFFFFF, "Slow it down on the commands!");
    SetPVarInt(playerid, "lastcommand", GetTickCount()+500);
    return 1;
}

SetPVarInt(playerid, "lastcommand", GetTickCount()+500);
Put that either in OnPlayerCommandText (for all the commands) or at the PM command.
Reply
#3

Quote:
Originally Posted by CuervO
Посмотреть сообщение
This methods would work for all kinds of spam.

pawn Код:
if(GetPVarInt(playerid, "lastcommand") > GetTickCount())
{
    SendClientMessage(playerid, 0x00FFFFFF, "Slow it down on the commands!");
    SetPVarInt(playerid, "lastcommand", GetTickCount()+500);
    return 1;
}

SetPVarInt(playerid, "lastcommand", GetTickCount()+500);
Put that either in OnPlayerCommandText (for all the commands) or at the PM command.
Код:
public OnPlayerCommandText(playerid, cmdtext[])

{
if(GetPVarInt(playerid, "lastcommand") > GetTickCount())
{
    SendClientMessage(playerid, 0x00FFFFFF, "Slow it down on the commands!");
    SetPVarInt(playerid, "lastcommand", GetTickCount()+500);
    return 1;
}

SetPVarInt(playerid, "lastcommand", GetTickCount()+500);
}
Like that? Thanks!
Reply
#4

Quote:
Originally Posted by MahdiGames
Посмотреть сообщение
Код:
public OnPlayerCommandText(playerid, cmdtext[])

{
if(GetPVarInt(playerid, "lastcommand") > GetTickCount())
{
    SendClientMessage(playerid, 0x00FFFFFF, "Slow it down on the commands!");
    SetPVarInt(playerid, "lastcommand", GetTickCount()+500);
    return 1;
}

SetPVarInt(playerid, "lastcommand", GetTickCount()+500);
}
Like that? Thanks!
If you put it at OnPlayerCommandText it must be on the top and the check must return 0;

What that code does is it stores in a variable when the player is able to send a command again (current time + 500 MS). If the player sends a command before that time, it will add another 500 MS to the time and will not allow him to send the command.
Reply
#5

Quote:
Originally Posted by CuervO
Посмотреть сообщение
If you put it at OnPlayerCommandText it must be on the top and the check must return 0;

What that code does is it stores in a variable when the player is able to send a command again (current time + 500 MS). If the player sends a command before that time, it will add another 500 MS to the time and will not allow him to send the command.
What is : SERVER: Unknown Command. , and i can spam 4 times how to down the value?
Reply
#6

Put instead 500 any time in MS you want before the player is able to send another command.

1000MS = 1 Second.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)