Tracking paydays
#1

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
Reply
#2

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

What are cron jobs?
Reply
#4

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)
Reply
#5

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

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

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?
Reply
#8

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;
}
Reply
#9

@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
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)