Payday
#1

Hello guys,

I have a question on how to make payday per hour.

I use this script:

pawn Код:
// ------ Forwards
forward Realtime();

// ------ OnGameModeInit();
SetTimer("Realtime", 1000, 1);

// ------ Public RealTime
public Realtime()
{
    new hour, minute, second;
    gettime(hour, minute, second);
    SetWorldTime(hour);
    return 1;
}
Dunno if this helps you guys.

Now my question is to have a payday every time the time is XX:00 (11:00, 12:00 etc.)

Thanks in advance!

Hipflop
Reply
#2

If you want it every hour then you could just set the timer to an hour, being 600000 (I think /me fails at maths)
Reply
#3

I dunno if it would work but you can try doing like this:
pawn Код:
// ------ Forwards
forward Realtime();

// ------ OnGameModeInit();
SetTimer("Realtime", 1000, 1);

// ------ Public RealTime
public Realtime()
{
    new hour, minute, second;
    gettime(hour, minute, second);
    SetWorldTime(hour);
    if(minute == 00 && second == 00)
    {
        BLA BLA BLA
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Dirkon
Посмотреть сообщение
I dunno if it would work but you can try doing like this:
pawn Код:
// ------ Forwards
forward Realtime();

// ------ OnGameModeInit();
SetTimer("Realtime", 1000, 1);

// ------ Public RealTime
public Realtime()
{
    new hour, minute, second;
    gettime(hour, minute, second);
    SetWorldTime(hour);
    if(minute == 00)
    {
        BLA BLA BLA
    }
    return 1;
}
Never thought of that! I'll try and use it!
Answer in an hour, since its xx:07 now...
Reply
#5

Just change time on your PC and you can test it in a minute.
P.S look again at my post I fixed that it wouldn't give payday every second till first minue passes.
Reply
#6

Quote:
Originally Posted by Dirkon
Посмотреть сообщение
Just change time on your PC and you can test it in a minute.
P.S look again at my post I fixed that it wouldn't give payday every second till first minue passes.
Already noticed that. But thx anyways!
Reply
#7

it worked?
Reply
#8

Nope...

pawn Код:
public Realtime(playerid)
{
    new hour, minute, second;
    gettime(hour, minute, second);
    SetWorldTime(hour);
    if(minute == 00 && second == 00)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            SendClientMessage(i, COLOR_WHITE, "------ PAYDAY");
            if(gPlayerInfo[playerid][pLevel] == 1)
            {
                SendClientMessage(playerid, COLOR_WHITE, "You received $1000");
                GivePlayerMoney(playerid, 1000);
            }
            else if(gPlayerInfo[playerid][pLevel] == 2)
            {
                SendClientMessage(playerid, COLOR_WHITE, "You received $2000");
                GivePlayerMoney(playerid, 2000);
            }
        }
    }
    return 1;
}
Any suggestions?
Reply
#9

Код:
public SyncTime()
{
	new string[64];
	new tmphour;
	new tmpminute;
	new tmpsecond;
	gettime(tmphour, tmpminute, tmpsecond);
	FixHour(tmphour);
	tmphour = shifthour;
	if ((tmphour > ghour) || (tmphour == 0 && ghour == 23))
	{
		format(string, sizeof(string), "* The time is now %d:00 hours",tmphour);
		BroadCast(COLOR_WHITE,string);
		ghour = tmphour;
		//here you put your payday or  declare a public PayDay(and here put PayDay(); )
		if (realtime)
		{
			SetWorldTime(tmphour);
		}
	}
}
Reply
#10

I got the solution.

I forgot the check if the player is connected

Here is good solution:

pawn Код:
public Realtime(playerid)
{
    new hour, minute, second;
    gettime(hour, minute, second);
    SetWorldTime(hour);
    if(minute == 00 && second == 00)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                SendClientMessage(i, COLOR_WHITE, "------ PAYDAY");
                if(gPlayerInfo[playerid][pLevel] == 1)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "You received $1000");
                    GivePlayerMoney(playerid, 1000);
                }
                else if(gPlayerInfo[playerid][pLevel] == 2)
                {
                    SendClientMessage(playerid, COLOR_WHITE, "You received $2000");
                    GivePlayerMoney(playerid, 2000);
                }
            }
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)