anticommandspam - OCMD
#1

Is there a possibility to anticommandspam while using ocmd without checking commandspam before

every single command?
Reply
#2

I don't know how ocmd works but in my gamemode, in OnPlayerCommandRecieved, i have this:

pawn Код:
if(Player[playerid][IsLoggedIn] == false) return ShowPlayerFooter(playerid, "You need to be ~r~logged ~w~to use commands.", 5000);
To prevent non logged players the usage of commands.

You can easily replace it with your anti cmd spam code.
Reply
#3

Use a mixture of this tutorial by [HLF]Southclaw & OnPlayerCommandRecieved
Reply
#4

Quote:
Originally Posted by XxBaDxBoYxX
Посмотреть сообщение
Use a mixture of this tutorial by [HLF]Southclaw & OnPlayerCommandRecieved
Why use something like that if it's just done with a single line?
Reply
#5

...Or if you wish to block just some commands:

Put:

pawn Код:
SetPVarInt(playerid,"CmdTime",GetTickCount()+10000);//10000 stands for 10 seconds
In the command you wish to block.

And:

pawn Код:
if(GetPVarInt(playerid,"CmdTime")>GetTickCount()) return SendClientMessage(playerid,-1,"* Please wait before using this command again.");
In OnPlayerCommandRecieved.

Obviosuly pvars are just an idea. You can use tick count instead if you wish.
Reply
#6

Quote:
Originally Posted by Undef1ned
Посмотреть сообщение
Why use something like that if it's just done with a single line?
The result would be also a single if condition (or switch, according to the scripter's will)
Simply, Learning and applying it yourself is by far better practice than waiting for someone else to "feed" it for you.
Reply
#7

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
...Or if you wish to block just some commands:

Put:

pawn Код:
SetPVarInt(playerid,"CmdTime",GetTickCount()+10000);//10000 stands for 10 seconds
In the command you wish to block.

And:

pawn Код:
if(GetPVarInt(playerid,"CmdTime")>GetTickCount()) return SendClientMessage(playerid,-1,"* Please wait before using this command again.");
In OnPlayerCommandRecieved.

Obviosuly pvars are just an idea. You can use tick count instead if you wish.
PVar is the last option to get performance.
Reply
#8

I know, it was just to give him an idea.
Reply
#9

I tried it with GetTickCount and GetTime both won't work > OnPlayerCommandPerformed works

I can just type a Command every single sec like before
public OnPlayerCommandPerformed(playerid, cmdtext[], success)
{

if(success)
{
if(lastcommand[playerid]>gettime()) return SendClientMessage(playerid,-1,"* Please wait before using this command again.");

lastcommand[playerid] = gettime()+10000;
return 1;
}
return 1;
}
Reply
#10

You have to put:

pawn Код:
lastcommand[playerid] = gettime()+10000;
In every command you wish to block.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)