Payday system help
#1

Hello everyone. I'm trying to make a payday that will be called every hour. I checked many filterscripts on forums but all of them start a one hour timer under OnGameModeInit.But I want the payday to be called at the end of each hour like 1:00:00, 5:00:00 etc...If I use the methods I found it would be random as hell as it would depend on when I started the server. I hope you guys can help.
Reply
#2

pawn Код:
forward Payday(playerid);

public OnFilterScriptInit()
{
    SetTimer("Payday",TIME,true);
    return 1;
}

public Payday(playerid)
{
    GivePlayerMoney(playerid, $$$$);
    return 1;
}
Reply
#3

I think you didn't read what I wrote...Any idiot can do that. But I need it to give payday at the end of an hour not an hour after starting the server.
Reply
#4

Well it depends. How are you using the time for an hour?
If you're using a one second timer for your time in hours/minutes, just check when minutes == 0, then issue the payday.
Reply
#5

Well, I am doing the same thing but with seconds, as the minute will be 0 for 60 seconds which means they gonna have 60 paydays. But sometimes it gives you your paycheck and sometimes it doesn't
Reply
#6

If you have a 1 second time, every 60 seconds you can use a function like this to see if it is different (every second is unnecessary) or you can use 60 second timer, but here is an example:
pawn Код:
//somewhere at the top of your script create g_iHour, like so:
new g_iHour = 0;

forward SyncTime();

public OnGameModeInit()
{
    //other code here
    new        
        iTmpHour,
        iTmpMin,
        iTmpSec;
    gettime(iTmpHour, iTmpMin, iTmpSec);
    g_iHour = iTmpHour; //current hour is set when gamemode starts
    //other code here
}

public SyncTime()
{
    new
        iTmpHour,
        iTmpMin,
        iTmpSec;
    gettime(iTmpHour, iTmpMin, iTmpSec);
    if((iTmpHour > g_iHour) || (g_iHour == 23 && iTmpHour == 0))
    {
        //It is a new hour
        //your code here
    }
}
If you call SyncTime(); in a timer it will check the time, if the hour is different to what it last was then it will execute the code you enter.
Reply
#7

Oh now I see how that works. I saw that same code on an NGG edit when I tries to look at their payday system but I didn't understand how it worked so I didn't use it.
Reply
#8

Quote:
Originally Posted by mirou123
Посмотреть сообщение
Oh now I see how that works. I saw that same code on an NGG edit when I tries to look at their payday system but I didn't understand how it worked so I didn't use it.
Funnily enough, I actually wrote that from scratch and then realised it was pretty much the exact same as NGG ^_^
Reply
#9

Quote:
Originally Posted by BlackSirrah239
Посмотреть сообщение
Funnily enough, I actually wrote that from scratch and then realised it was pretty much the exact same as NGG ^_^
Thanks champ!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)