Remaining Time Help - 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: Remaining Time Help (
/showthread.php?tid=576907)
Remaining Time Help -
Armageddonz - 07.06.2015
How Can I Make A remaining time system with this code..actually i want to make an anti spam system which will mute the player if the player get spam warning..
part of the code
Код:
new string[256], name[24], mutee[256];
GetPlayerName(playerid,name,24);//Save the spammers name into the string variable "name".
if((gettime()-ChatSpamTime[playerid][2])<4)//We get sure again if it took the player less than 4 secs.
{
format(string,sizeof(string),"--------------------------------------------------\n{FFFFFF}[Anti-Spam]{FFFF66}Player %s Has Been Muted , {FF0000}Reason: Spam\n--------------------------------------------------",name);
SendClientMessageToAll(0xFFFFFF,string);
SendClientMessage(playerid, 0xFFFFFF,"{FFFFFF}[Anti-Spam]You Have Received A Warning (3/3), {FF0000}Reason: Spam");
muted[playerid]=1;//we mute him
SetTimerEx("AutoUnMute",AutoUnmuteTime*60000,false,"i",playerid);
format( mutee, sizeof(mutee), "You Have Been Muted\nRemaining Time : ~r~%i Seconds", AutoUnmuteTime*60);
GameTextForPlayer(playerid, mutee, 900000, 3);
i want to make a remaining time system when the game text show to player
this code
Код:
format( mute, sizeof(mute), "You Have Been Muted\nRemaining Time : ~r~%i Seconds", AutoUnmuteTime*60);
GameTextForPlayer(playerid, mute, 900000, 3);
whole code
Код:
stock AntiSpam(playerid)//stock function
{
SpamCount[playerid]++;//Everytime a player types smth. in the chat this variable gets increased by one.
switch (SpamCount[playerid])//switch between the SpamCount variable.
{
case 1://If a player types smth. into the chat for the first time...
{
ChatSpamTime[playerid][0]=gettime();//Get the unix timestamp and save it into a variable.
//ChatSpamTime[playerid][0] this variable is our first variable. The array is "0" for the first one not "1"!
}
case 2://If the player types smth. into the chat the second time...
{
if((gettime()-ChatSpamTime[playerid][0])<4)//We check if the Time between the players first and
{
//second chat is more or less than 4 seconds. In case the player chatted faster than 4 seconds
//We will give him his first warning ...
SendClientMessage(playerid,0xFFFFFF,"{FFFFFF}[Anti-Spam]You Have Received A Warning (1/3), {FF0000}Reason: Spam");
ChatSpamTime[playerid][1]=gettime();//and we save his chat time again to another variable.
//Lets take a closer look at this: gettime()-ChatSpamTime[playerid][0].
//We use gettime() to get the current unix timestamp and we simply subtract the time we
//saved before (as the player chatted the first time). Always make sure to subtract the older
//timestamp from the newer one as the newer timestamp is always bigger!
}
else SpamCount[playerid]=0;//If the player needed longer than 4 seconds to send another
//chat message we reset his SpamCount variable bac to 0. (as he is obviously not spamming or a very slow spammer ;) )
}
case 3://If the player types smth. into the chat the third time...
{
if((gettime()-ChatSpamTime[playerid][1])<4)//We check how long it took the player to send another message after the 2nd one.
{
//If the player send another message faster than 4 seconds he is obviously spamming and we give
//him a 2nd warning as we dont want to be that cruel to spammers right? ;)
SendClientMessage(playerid,0xFFFFFF,"{FFFFFF}[Anti-Spam]You Have Received A Warning (2/3), {FF0000}Reason: Spam");
ChatSpamTime[playerid][2]=gettime();//Again save his chat time for this message to another variable.
}
else SpamCount[playerid]=0;//In case the player calmed down, reset his SpamCount variable.
}
case 4..50://In case the certain player gets the idea to spam again...
{
new string[256], name[24], mutee[256];
GetPlayerName(playerid,name,24);//Save the spammers name into the string variable "name".
if((gettime()-ChatSpamTime[playerid][2])<4)//We get sure again if it took the player less than 4 secs.
{
format(string,sizeof(string),"--------------------------------------------------\n{FFFFFF}[Anti-Spam]{FFFF66}Player %s Has Been Muted , {FF0000}Reason: Spam\n--------------------------------------------------",name);
SendClientMessageToAll(0xFFFFFF,string);
SendClientMessage(playerid, 0xFFFFFF,"{FFFFFF}[Anti-Spam]You Have Received A Warning (3/3), {FF0000}Reason: Spam");
muted[playerid]=1;//we mute him
SetTimerEx("AutoUnMute",AutoUnmuteTime*60000,false,"i",playerid);
format( mutee, sizeof(mutee), "You Have Been Muted\nRemaining Time : ~r~%i Seconds", AutoUnmuteTime*60);
GameTextForPlayer(playerid, mutee, 900000, 3);
}
}
}
return 1;
Re: Remaining Time Help -
Abagail - 07.06.2015
Do you call the function?