29.09.2012, 11:19
Hi there,
Timers always give me grief when I do them, and it's not different this time. For some odd reason, the clock flows at full hour from :59, misses out :00 and flows to :61, any offers? This is my ClockUpdate function...
OnGameModeInit:
Also, the clock speeds up and everytime someone logs in, a second is added onto the timer, so the intervals increase i.e from :40 to :44 and so on. I suppose this is because of the Second +=1 thing, but where do I put it, if not there?
Timers always give me grief when I do them, and it's not different this time. For some odd reason, the clock flows at full hour from :59, misses out :00 and flows to :61, any offers? This is my ClockUpdate function...
Код:
public ClockUpdate()
{
for(new x = 0; x < MAX_PLAYERS; x++)
{
if(Logged[x] == 1)
{
new string[12];
Second += 1;
format(string, sizeof(string), "%i:%i:%i", Hour, Minute, Second);
if(Second == 60)
{
if(Minute == 59)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(Player[i][PaydayTime] >= 30)
{
SendClientMessage(i, ORANGE, ">> Your pay cheque is ready to be picked up. Please head to the city hall to claim it.");
CheckReady[i] = 1;
}
else return SendClientMessage(i, LIBLUE, ">> You haven't been playing long enough to get a pay cheque.");
}
}
if(Hour == 23)
{
Hour = 0;
Minute = 0;
Second = 0;
}
else
{
Hour ++;
Minute = 0;
Second = 0;
}
}
else
{
Minute ++;
Second = 0;
}
}
if(Minute == JACKPOT_CALL_MINUTE && Second == 0)
{
SendClientMessageToAll(JACKPOT_COLOR, "Dear Transporters! The lottery is here!");
SendClientMessageToAll(JACKPOT_COLOR, "Type /buyticket and choose a number to buy your lottery ticket. The ticket will cost $5.");
format(gString, sizeof gString, "This hour's jackpot is ($%d). Good luck!", gJackpot);
SendClientMessageToAll(JACKPOT_COLOR, gString);
}
if(Minute == JACKPOT_CALL_MINUTE + JACKPOT_LAST_CALL && Second == 0)
{
SendClientMessageToAll(JACKPOT_COLOR, "Dear Transporters! Only two minutes left until the lottery draw. Last chance to buy your ticket with /buyticket!");
}
if(Minute == JACKPOT_CALL_MINUTE + JACKPOT_LAST_CALL + JACKPOT_CALL && Second == 0)
{
TicketDraw();
}
format(string,sizeof (string),"%02i:%02i:%02i", Hour, Minute, Second);
TextDrawSetString(Clock, string);
SetWorldTime(Hour);
}
}
return 1;
}
Код:
Clock = TextDrawCreate(547.000000, 24.500000, "--:--:--");
TextDrawBackgroundColor(Clock, 255);
TextDrawFont(Clock, 3);
TextDrawLetterSize(Clock, 0.420000, 1.300000);
TextDrawColor(Clock, -1);
TextDrawSetOutline(Clock, 0);
TextDrawSetProportional(Clock, 1);
TextDrawSetShadow(Clock, 1);
Hour = 12;
Minute = 30;
Second = 1;
ClockTimer = SetTimer("ClockUpdate", 999, 1);

