Pay Day Timer....
#1

Hey guys, how do i create a timer for payday system?

I am really not good with timers.... If someone can tell me i will be Thanks!
Just need the script to do something every hours
Reply
#2

Put this somewhere
pawn Код:
forward Payday(playerid);
public Payday(playerid)
{
     //what do you want the timer to do?
     return 1;
}
pawn Код:
public OnGameModeInit(...)
{
     for(new i = 0; i<MAX_PLAYERS; i++)
     {
          SetTimerEx("PayDay", seconds x 1000, 1, "i",i);
     }
     return 1;
}
Reply
#3

Well, it depends. What kind of PayDay timer you want?

You want a 'global' one, which pays everyone at :00 minutes of every hour?

You want a 'global' with a minimum playing minutes to get it?

You want a player based one? When player reaches 60 minutes online, he gets a Payday?

LE: Just read your last sentece ...

Well, you can do like this:
pawn Код:
public OnGameModeInit()
{
     SetTimer( "Payday", 60000, true );
}
This will set a timer, called "Payday" ( a public function more exactly), which occurs every 1 minute. Don`t worry, you won`t get payday every minute. You`ll understand later.

Now, we`ll make the Payday function:
pawn Код:
forward Payday();
public Payday()
{
    new hh, mm, ss;
    gettime( hh, mm, ss );
    new String[ 75 ];
    new prandom = random(5000); // THis is used for random paycheck, you can change it :)
   
    if( mm == 0 ) // This checks if the minutes is :00
    {
        foreach (Player,i) // We loop through all online players, to give them $$ (Credits to ****** for this)
        {
             GivePlayerMoney(i, prandom);
             format(String, sizeof String, "Paycheck! Recieved %d $.", prandom);
             SendClientMessage(i, -1, String);
        }
     }
}
Well, that`s all ... it`s a simple payday, which gives every online player a random( 0 - 5000$).
Reply
#4

this is my code for Payday

Код:
public PayDay()
{
	SendClientMessageToAll(COLOR_LIGHTBLUE,"PAYDAY: All business earnings have been updated and all players have recieved a rebate of $50000");
	for (new i = 0; i < MAX_PLAYERS; i++) {
		GivePlayerMoney(i,500);
		if(PlayerInfo[i][bowner] == 1) {
			new cbmon = BizInfo[PlayerInfo[i][bowned]][cashbox], pmon = BizInfo[PlayerInfo[i][bowned]][profit];
			BizInfo[PlayerInfo[i][bowned]][cashbox] = cbmon+pmon;
			SendClientMessage(i,COLOR_LIGHTBLUE,"To collect you business' earnings return to your business and type '/cashbox'");
		}
	}
Reply
#5

Quote:
Originally Posted by austin070
Посмотреть сообщение
Put this somewhere
pawn Код:
forward Payday(playerid);
public Payday(playerid)
{
     //what do you want the timer to do?
     return 1;
}
pawn Код:
public OnGameModeInit(...)
{
     for(new i = 0; i<MAX_PLAYERS; i++)
     {
          SetTimerEx("PayDay", seconds x 1000, 1, "i",i);
     }
     return 1;
}
Wrong

OnGameModeInit is called when a gamemode starts.

-

Correction, for a global payday.

pawn Код:
public OnGameModeInit(...)
{
     SetTimer("PayDay",Time,true);
     return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)