Help with a timer
#1

i have this code
Код:
	if(strcmp(cmdtext, "/robbank", true) == 0)
	{
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pRank] < 5)
			{
			    SendClientMessage(playerid, COLOR_GREY, "   Morate da ste  Rank 5 za da ja ograbite bankata !");
			    return 1;
			}
            if(RobStart2[playerid] == 1)
            {
            	if (!PlayerToPoint(30, playerid, -482.10000610,-183.69999695,972.29998779))
            	{
                	SendClientMessage(playerid, COLOR_GREY, "Ne ste vo blizina na banka!");
                	return 1;
            	}
            	GetPlayerName(playerid, sendername, sizeof(sendername));
            	SendClientMessage(playerid,COLOR_WHITE,"||| VESTI NA DENOT |||");
        	    format(string, sizeof(string), "BANK ALARM: %s go zapocna grabezot BANK ALARM !!!.", sendername);
			    SendTeamMessage(1, COLOR_YELLOW, string);
				SendTeamMessage(2, COLOR_YELLOW, string);
				SendTeamMessage(3, COLOR_YELLOW, string);
                SendTeamMessage(1, COLOR_YELLOW, string);
				SendTeamMessage(2, COLOR_YELLOW, string);
				SendTeamMessage(3, COLOR_YELLOW, string);
				SendTeamMessage(1, COLOR_YELLOW, string);
				SendTeamMessage(2, COLOR_YELLOW, string);
				SendTeamMessage(3, COLOR_YELLOW, string);
        		SendClientMessage(playerid,COLOR_WHITE,"** Ve molimo pocekajte 3 minuti dodeka parite se prefrluvaat vo kombeto");
        	    SetTimerEx("RobDone",60000, false, "i", playerid);
        	}
	    	else
	    	{
				SendClientMessage(playerid, COLOR_RED, "* Ne,Nemoze taka ! ");
			}
    	}
	}
and i want to add a timer so once they rob the bank it can't be robed again for an hour i tryed many thing i didnt suceed can anyone help me?
Reply
#2

At top of your FS/GM:

pawn Код:
new BankRobbedLast;
To your command, as soon as the robbing was successful:
pawn Код:
BankRobbedLast = gettime();
To your command, where they try to rob again:
pawn Код:
if(BankRobbedLast+60000 > gettime()) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: The bank has already been robbed in the last 60 minites. Try again later.");

It is much better to use the gettime() function to block an event for a specific amount of time, instead of using timers.
Reply
#3

I was about to make you a timer, but Jeffry gave you the best solution for this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)