How to make a /robbank timer for all players?
#1

How to make a /robbank timer for all players?

How to make it so noone can rob for 10 minutes after a bank got robbed? I made it so one player can rob each 10 minutes, but I need it to work for all players on server.
Reply
#2

https://sampwiki.blast.hk/wiki/SetTimerEx

Make a custom function which takes the player's ID, and reset their value there. Have the timer call that function.
Reply
#3

I don't know how. If I knew I'd of done it already mate.
Reply
#4

Something like this?

Код:
if(robtime > 1)
              	{
                  	format(string, sizeof(string), "The Bank has recently been robbed please wait [%d]", robtime);
                  	SendClientMessage(playerid,COLOR_LIGHTRED,string);
                	return 1;
Reply
#5

Quote:
Originally Posted by 101
Посмотреть сообщение
I don't know how. If I knew I'd of done it already mate.
I know, which is why I've replied. I gave you the necessary information in order to do this yourself - re-read my post. If you have any questions from what I've said, then ask. I would hope no one would simply spoon-feed you the code to this, as you would learn nothing from it!

Read the documentation (link) of SetTimerEX I've provided above and go from there. It should be relatively easy considering you already know how to use SetTimer.
Reply
#6

I have this under my /robbank

Код:
SetTimerEx("bank1robbedoff",10000,0,"d",playerid);
I also have this check (does not work):
Код:
if(bank1alreadyrobbed[playerid] == 1)
     	{
        SendClientMessage(playerid, COLOR_WHITE, "The bank has already been robbed in the past 10 minutes! Try later!");
        return 1;
     	}
Finally the timer code is:

Код:
public bank1robbedoff(playerid)
{
    for(new player=0; player<MAX_PLAYERS; player++)
 	{
  	bank1alreadyrobbed[player] = 0;
  	SendClientMessageToAll(COLOR_WHITE, "You can now rob the bank again");
	}
    return 1;
}
It doesent work.
Reply
#7

I'm a bit confused here as to what you are trying to achieve after reading your post and now your responses. Do you want it so the bank can only be robbed every 10 minutes, or that only one player can rob it every 10 minutes?

If you were referring to the player being able to, then use the example I gave above. Otherwise, I can see why you were becoming confused. If that latter, you don't need to use SetTimerEx, simply SetTimer. You also wouldn't need the array to store whether or not the player robbed the bank, as it could be stored in a single variable representing the bank as a whole.
Reply
#8

I know how to make one for a player, and it works perfectly but I want to make it so the bank itself can only be robbed each 10 minutes.

Any chance you can give me a example?
Reply
#9

pawn Код:
// variable to store the bank status
new bool: bank_robbed = false;

// somewhere to again allow robbing, and set var to false
// so they cannot rob again yet
bank_robbed = true;
SetTimer("allowrob", <time>, false);

// the custom function passed to the timer
public allowrob()
    bank_robbed = false;
This also means that you no longer need an array to check whether or not the player has robbed the bank.
Reply
#10

Do I need to forward the timer as I do with settimerex?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)