Spam question?!
#1

I have 2 commands

Код:
  if(strcmp("/moli", cmdtext, true) == 0)
	{
		if(PlayerToPoint(5.0,playerid,2490.2896,918.3433,11.0234))
	    {
	    SendClientMessage(playerid, 0xFF0005FF,"Pricekaj 30 sekundi da se pomolis....");
	    TogglePlayerControllable(playerid,0);
      SetTimerEx("Molitva", 30000, false, "d",playerid);
}
    return 1;
}
  if(strcmp("/molitva", cmdtext, true) == 0)
	{
		if(PlayerToPoint(5.0,playerid,1454.1189,751.7510,11.0234))
	    {
	    SendClientMessage(playerid, 0xFF0005FF,"Pricekaj 30 sekundi da se pomolis....");
	    TogglePlayerControllable(playerid,0);
      SetTimerEx("Molitva2", 30000, false, "d",playerid);
}
    return 1;
}
And i wanna make spam blocker, when player use command /moli and /molitva to cant use that command next 5 min. Can anyone help me?! Its really need me
Reply
#2

bump
Reply
#3

I guess you can make a timer
Reply
#4

pawn Код:
new spamblocker[MAX_PLAYERS];
new spamblocker2[MAX_PLAYERS];
OnPlayerconnect
pawn Код:
spamblocker = 0;
spamblocker2 = 0;
pawn Код:
if(strcmp("/moli", cmdtext, true) == 0)
    {
         if(spamblocker[playerid] == 1 ) return SendClientMessage(playerid , color, "You have to wait 30 seconds to use this command.");
         else
        if(PlayerToPoint(5.0,playerid,2490.2896,918.3433,11.0234))
        {
        SendClientMessage(playerid, 0xFF0005FF,"Pricekaj 30 sekundi da se pomolis....");
        TogglePlayerControllable(playerid,0);
      SetTimerEx("Molitva", 30000, false, "d",playerid);
      spamblocker[playerid] = 1;
}
    return 1;
}
  if(strcmp("/molitva", cmdtext, true) == 0)
    {

         if(spamblocker2[playerid] == 1 ) return SendClientMessage(playerid , color, "You have to wait 30 seconds to use this command.");
         else
        if(PlayerToPoint(5.0,playerid,1454.1189,751.7510,11.0234))
        {
        SendClientMessage(playerid, 0xFF0005FF,"Pricekaj 30 sekundi da se pomolis....");
        TogglePlayerControllable(playerid,0);
      SetTimerEx("Molitva2", 30000, false, "d",playerid);
spamblocker2[playerid] = 1;
}
    return 1;
}
pawn Код:
foward Molitva2(playerid);
public Molitva2(playerid)
{
spamblocker2[playerid] = 0;
}
foward Molitva(playerid);
public Molitva(playerid)
{
spamblocker[playerid] = 0;
}
Untested ! but it should work
Reply
#5

C:\Users\NASTIE\Desktop\ExtremePower\gamemodes\Ext remePower.pwn(870) : error 033: array must be indexed (variable "spamblocker")
C:\Users\NASTIE\Desktop\ExtremePower\gamemodes\Ext remePower.pwn(871) : error 033: array must be indexed (variable "spamblocker2")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

Код:
public OnPlayerConnect(playerid)
{
  spamblocker = 0; // LINE 870
  spamblocker2 = 0;// LINE 871
Reply
#6

Quote:
Originally Posted by DarkPower
C:\Users\NASTIE\Desktop\ExtremePower\gamemodes\Ext remePower.pwn(870) : error 033: array must be indexed (variable "spamblocker")
C:\Users\NASTIE\Desktop\ExtremePower\gamemodes\Ext remePower.pwn(871) : error 033: array must be indexed (variable "spamblocker2")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

Код:
public OnPlayerConnect(playerid)
{
  spamblocker = 0; // LINE 870
  spamblocker2 = 0;// LINE 871
spamblocker[playerid] = 0;
spamblocker2[playerid] = 0;
Reply
#7

Quote:
Originally Posted by _Saif_
Quote:
Originally Posted by DarkPower
C:\Users\NASTIE\Desktop\ExtremePower\gamemodes\Ext remePower.pwn(870) : error 033: array must be indexed (variable "spamblocker")
C:\Users\NASTIE\Desktop\ExtremePower\gamemodes\Ext remePower.pwn(871) : error 033: array must be indexed (variable "spamblocker2")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.

Код:
public OnPlayerConnect(playerid)
{
  spamblocker = 0; // LINE 870
  spamblocker2 = 0;// LINE 871
spamblocker[playerid] = 0;
spamblocker2[playerid] = 0;
tny
Reply
#8

I wouldn't recommend using a timer for this. Try GetTickCount()

Код:
static n_PlayerLastUsedCommand[MAX_PLAYERS];

public OnPlayerDisconnect(playerid)
{
  n_PlayerLastUsedCommand[playerid] = 0;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(!strcmp(cmdtext, "/somecmd"))
  {
    if(n_PlayerLastUsedCommand[playerid] != 0 && GetTickCount() - n_PlayerLastUsedCommand[playerid] < 5*60*1000)
    {
       SendClientMessage(playerid, COLOR_RED, "You can only use this once every 5 minutes."); 
       return 1;
    } 
   
    n_PlayerLastUsedCommand[playerid] = GetTickCount();
 
   // rest of the cmd
    
  }
}
Reply
#9

Quote:
Originally Posted by _Jay_
I wouldn't recommend using a timer for this. Try GetTickCount()

Код:
static n_PlayerLastUsedCommand[MAX_PLAYERS];

public OnPlayerDisconnect(playerid)
{
  n_PlayerLastUsedCommand[playerid] = 0;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(!strcmp(cmdtext, "/somecmd"))
  {
    if(n_PlayerLastUsedCommand[playerid] != 0 && GetTickCount() - n_PlayerLastUsedCommand[playerid] < 5*60*1000)
    {
      SendClientMessage(playerid, COLOR_RED, "You can only use this once every 5 minutes."); 
      return 1;
    } 
  
    n_PlayerLastUsedCommand[playerid] = GetTickCount();
 
   // rest of the cmd
    
  }
}
he was saying about both .If any one use GetTickCount in command the other commands will also stop working ,In which you use GetTickCount .That`s why i didnt post here about GetTickCount or its easy for me to explain rather then variables!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)