payday code didn't work ?!
#1

this is it

Код:
public Payday(playerid)
{
    new hour, minute, second;
    gettime(hour, minute, second);
    if(minute == 00)
    {
    	for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
        {
			if(PlayerInfo[i][ExpS] == 0)
			{
			    PlayerInfo[i][Exp]++;
			}
			else
			{
			    PlayerInfo[i][Exp] += PlayerInfo[i][ExpS];
			}
			if(PlayerInfo[i][Level] < 30)
			{
				GivePlayerMoney(i, PlayerInfo[i][Level]*1000);
			}
			else
			{
			    GivePlayerMoney(i, 30000);
			}
		}
	}
    return 1;
}
Reply
#2

What do you mean "it didn't work". What are you trying to do?
Reply
#3

Try like this
Код:
public Payday(playerid)
{
    new hour, minute, second;
    gettime(hour, minute, second);
    if(minute == 00)
    {
    	for(new i = 0; i < MAX_PLAYERS; i++) 
        {
               if(IsPlayerConnected(i)) {
			if(PlayerInfo[i][ExpS] == 0)
			{
			    PlayerInfo[i][Exp]++;
			}
			else
			{
			    PlayerInfo[i][Exp] += PlayerInfo[i][ExpS];
			}
			if(PlayerInfo[i][Level] < 30)
			{
				GivePlayerMoney(i, PlayerInfo[i][Level]*1000);
			}
			else
			{
			    GivePlayerMoney(i, 30000);
			}
                   }
	  }
	}
    return 1;
}
Reply
#4

Instead of using a timer (assuming ~ 1ms) and check the minute everytime whether it's 0 (when it takes 60 minutes to be 0 again), why don't you make a timer every 1 hour?
Reply
#5

So..I add a timer that check what's the time every 1 second and it's work now.Tnx all :>
Reply
#6

Код:
public Payday(playerid) //You assign this to a playerid
{
    new hour, minute, second;
    gettime(hour, minute, second);
    if(minute == 00)
    {
    	for(new i = 0; i < MAX_PLAYERS; i++)  //Then you loop it for everyone
        {
               if(IsPlayerConnected(i)) {
			if(PlayerInfo[i][ExpS] == 0)
			{
			    PlayerInfo[i][Exp]++;
			}
			else
			{
			    PlayerInfo[i][Exp] += PlayerInfo[i][ExpS];
			}
			if(PlayerInfo[i][Level] < 30)
			{
				GivePlayerMoney(i, PlayerInfo[i][Level]*1000);
			}
			else
			{
			    GivePlayerMoney(i, 30000);
			}
                   }
	  }
    }
    return 1;
}
Do like this instead

Код:
forward Payday();
public Payday()
{
    new hour, minute, second;
    gettime(hour, minute, second);
    if(minute == 00)
    {
    	for(new i = 0; i < MAX_PLAYERS; i++)
        {
               if(IsPlayerConnected(i)) {
			if(PlayerInfo[i][ExpS] == 0)
			{
			    PlayerInfo[i][Exp]++;
			}
			else
			{
			    PlayerInfo[i][Exp] += PlayerInfo[i][ExpS];
			}
			if(PlayerInfo[i][Level] < 30)
			{
				GivePlayerMoney(i, PlayerInfo[i][Level]*1000);
			}
			else
			{
			    GivePlayerMoney(i, 30000);
			}
                   }
	  }
    }
    return 1;
}
You'll need a timer or something to check it aswell.

SetTimer("Payday", 1000, true);

But yeah, making a timer checking every hour would be better.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)