SA-MP Forums Archive
Payday - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Payday (/showthread.php?tid=267200)



Payday - Hipflop - 07.07.2011

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


Re: Payday - Vero - 07.07.2011

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


Re: Payday - Dirkon - 07.07.2011

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;
}



Re: Payday - Hipflop - 07.07.2011

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...


Re: Payday - Dirkon - 07.07.2011

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.


Re: Payday - Hipflop - 07.07.2011

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!


Re: Payday - Dirkon - 07.07.2011

it worked?


Re: Payday - Hipflop - 07.07.2011

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?


Re: Payday - dariusmare - 07.07.2011

Код:
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);
		}
	}
}



Re: Payday - Hipflop - 07.07.2011

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;
}