Bank-Time
#1

Hey there,

I've tried to make a simple Bank-System, so if the clock turns 6, every player inside the Bank-Area gets an amount of money, every day at 6 o' clock.

I tried the following code so far on myself, but unfortunatelly it isn't working like I want it to. You just get the money 1 time after server-start, but not the following days. I guess it has something to do with the Timer, but if I delete the "KillTimer" you get the money infinite times at 6 and it is not stopping lol.

Код:
  timer1 = SetTimer("isPlayerInArea",100, 1);
  timer2 = SetTimer("BankTime", 999, 1);

public isPlayerInArea()
{
  for(new i = 0; i < MAX_PLAYERS; i++)
  {
        if(IsPlayerInArea(i, 1711.4371, 1731.7839, -1670.3661, -1643.2722))
		{
			SendClientMessage(i, 0xFFFF00AA, "( ! ) Welcome to Bank!");
			KillTimer(timer1);
			return 1;
		}
  }
  return 1;
}

public BankTime()
{
  for(new i = 0; i < MAX_PLAYERS; i++)
  {
	if(IsPlayerInArea(i, 1711.4371, 1731.7839, -1670.3661, -1643.2722))
		{
		new hours;
		new minutes;
		GetPlayerTime(i, hours, minutes);
  	if(hours == 6.00 && minutes == 0.00)
 		  {
			PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
			GivePlayerMoney(i, 7500);
			SendClientMessage(i, 0x12900BBF, "||| 6:00 | BANK TIME: |||");
			SendClientMessage(i, 0xFFFF00AA, "YOU RECEIVE +7.500 $");
			KillTimer(timer2);
			return 1;
			}
		}
  }
  return 1;
}
I hope you can help me out to fix this, I'm a scripting-beginner
Reply
#2

You can't kill the timer, then it wont start again...

delete this line
pawn Код:
KillTimer(timer2);
EDIT: You should also check if the player ISN'T in the area (for isPlayerInArea timer) and if he isn't (after the timer has been killed) set the timer again...
Reply
#3

Thanks for the reply, but I tested that already. And if I delete the KillTimer, you get the money over and over again, non-stop. Maybe there's a mistake in the GetPlayerTime?
Reply
#4

Yeah maybe, never used it before so I really dno :P
Reply
#5

Well, no problem, would be nice though if there's anyone out there who can help me and knows a solution
Reply
#6

I thought about and well, it's obvious: If I check for hours == 6 && minutes == 00 you get the cash till it's 7 o' clock, because there exists no real 6:01,6:02 etc., only on my visual clock :P So how should I do it then, so that you only get money 1 time as soon as the clock turns from 5 to 6 and then the next day. I've seen it another server too, so I know it can work, but I can't seem to come up with a solution :S
Reply
#7

Well won't compile for me, got errors, and can I make GivePlayerMoney to not give money, I want give players server side money Rcash?
Reply
#8

Try this:

pawn Код:
timer2 = SetTimer("BankTime", 999, 1);

public BankTime()
{
    new hours; new minutes;
    GetPlayerTime(i, hours, minutes);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(hours == 6 && minutes == 0)
        {
            if(IsPlayerInArea(i, 1711.4371, 1731.7839, -1670.3661, -1643.2722) && GetPVarInt(i, "GotPayed") == 0)
            {
                GivePlayerMoney(i, 7500);
                SendClientMessage(i, 0x12900BBF, "||| 6:00 | BANK TIME: |||");
                SendClientMessage(i, 0xFFFF00AA, "YOU RECEIVE +7.500 $");
                PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
                SetPVarInt(i, "GotPayed", 1);
            }
        }
        else
        {
            SetPVarInt(i, "GotPayed", 0);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)