SA-MP Forums Archive
Prevent /o spam? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Prevent /o spam? (/showthread.php?tid=156417)



Prevent /o spam? - Antonio [G-RP] - 22.06.2010

How do I prevent /o spam? Like put a 3 second timer between using /o


Re: Prevent /o spam? - Faith - 22.06.2010

new CanTalk[MAX_PLAYERS];


if(CanTalk[playerid]==0){
SendClientMessage(playerid, red, "You cannot speak in /o right now to prevent spam");
return 1;
}

under your command: CanTalk[playerid]=0;
SetTimerEx("CanTalkInO" blah blah

under public CanTalkInO
CanTalk[playerid]=1;

I hope it's clear enough.




Re: Prevent /o spam? - Antonio [G-RP] - 22.06.2010

Hah, I though it was gonna be something like tick count, its clear, so if nobody helps with GetTickCount, then ill use yours. Thanks


Re: Prevent /o spam? - Assyria - 22.06.2010

if(GetPVarInt(playerid,"miau")> GetTickCount()) return 0;
SetPVarInt(playerid,"miau", GetTickCount()+3000);


Re: Prevent /o spam? - Antonio [G-RP] - 22.06.2010

And how does that work?


Re: Prevent /o spam? - Finn - 22.06.2010

You don't need timer.

pawn Код:
new lasttimeooc[MAX_PLAYERS];
pawn Код:
// /o
if((gettime() - lasttimeooc[playerid]) > 3)
{
  lasttimeooc[playerid] = gettime();

  //Rest of the ooc cmd code here.
}
else
{
  return SendClientMessage(playerid, COLOR_HERE, "Wait 3 seconds before talking again, k?");
}
Edit: lol at below. You replaced 3 parts of my script with identical code and decided to post it cuz it's so much different from mine?

I c wat you did thar.


Re: Prevent /o spam? - mprofitt - 22.06.2010

pawn Код:
if(GetPVarInt(playerid,"OCCTick")< GetTickCount() + 3000)
{
    SetPVarInt(playerid,"OCCTick", GetTickCount());
    // Do your thing
}
else
{
    // Must wait 3 seconds
}



Re: Prevent /o spam? - Antonio [G-RP] - 22.06.2010

Fin, don't beak Mike. He has helped my script so much, and PVar is better than normal variables, so thanks for the help, but lets not be ass holes over forums.