SA-MP Forums Archive
Tracking paydays - 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: Tracking paydays (/showthread.php?tid=423301)



Tracking paydays - dusk - 17.03.2013

Hello, for multiple reason I want to keep track of payday. For example that every 2 paydays something would happen. Or that After exactly 1payday(1h) something would happen. The reason is i need this is to avoid using many timers


Re: Tracking paydays - Misiur - 17.03.2013

You could use cron jobs - of course if you have access to them


Re: Tracking paydays - dusk - 17.03.2013

What are cron jobs?


Re: Tracking paydays - Misiur - 17.03.2013

It's automated script called by server with some frequency. Anyway, I've got better idea - why don't you just use data storage system of your choice (ini files, sql database) to store current payday? (you can even track more info about specific payday, like how much money in total was spent)


Re: Tracking paydays - dusk - 17.03.2013

You mean like on every payday it would add +1 to my storage system?


Re: Tracking paydays - Misiur - 17.03.2013

For sql you have at least 2 options:
1. single field
Quote:

UPDATE `yourtable` SET paydays = paydays + 1

2. New table, with additional fields like date
Quote:

INSERT INTO `newtable` SET id = null, paydate = NOW()

(something like this)

For filesystem simply create single file called paydays or something, and add a new line every payday.


Re: Tracking paydays - dusk - 17.03.2013

Ok. I want stuff to happen every 2 paydays. I think i should try dividing by 2,if it does nicely,stuff happens. How do i do that? Or is you have some other way in mind?


Re: Tracking paydays - master2466 - 17.03.2013

Can I have two OnPlayerCommandText somehow? or how do I make so I have two..


Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new string[128];
	SpamStrings[playerid] +=2;
    if(SpamStrings[playerid] >= MAX_SPAM)
	{
	    format(string,sizeof(string),"Please do not spam in %s. Please wait before typing again.",sabbv);
	    SendClientMessage(playerid, COLOR_ERROR, string);
	    return 1;
    }
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(siren,5,cmdtext);
return 1;
}



Re: Tracking paydays - Misiur - 17.03.2013

@master: create now topic

@OP:
Well, let's start with basic method
pawn Код:
public OnGameModeInit() {
    SetTimeout("Payday", XXX, true);
    return 1;
}

forward Payday();
public Payday() {
    static paydays = 0;
    if(1 == paydays % 2) {
        //This is called every 2 paydays
    }
    //Normal payday thingies
    ++paydays;
    return 1;
}
Then you can store current paydays somewhere


Re: Tracking paydays - dusk - 17.03.2013

A couple of questions:
Why static? not new?
if(1 == paydays % 2) What is this?