Clock issue -
HighFlyer - 29.09.2012
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...
Код:
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;
}
OnGameModeInit:
Код:
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);
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?
Re: Clock issue -
Socan - 29.09.2012
Hmm seems very weird this one. Is there any error codes on these certain lines?
Re: Clock issue -
HighFlyer - 29.09.2012
Nope. I did that as well, and still the same result...
Код:
public ClockUpdate()
{
new string[12];
Second += 1;
format(string, sizeof(string), "%i:%i:%i", Hour, Minute, Second);
for(new x = 0; x < MAX_PLAYERS; x++)
{
if(Logged[x] == 1)
{
if(Second == 59)
{
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)
{
if(Second == 59)
{
Hour = 0;
Minute = 0;
Second = 0;
}
}
if(Minute == 59)
{
if(Second == 59)
{
Hour ++;
Minute = 0;
Second = 0;
}
/*if(Hour == 23)
{
Hour = 0;
Minute = 0;
Second = 0;
}
else
{
Hour ++;
Minute = 0;
Second = 0;
}*/
}
Re: Clock issue -
Joshman543 - 29.09.2012
Are there any compiling errors that have to do with the Text Draw?
Re: Clock issue -
Socan - 29.09.2012
Have you tried setting Minute and Second to 60 not 59? Just a suggestion..
Код:
public ClockUpdate()
{
new string[12];
Second += 1;
format(string, sizeof(string), "%i:%i:%i", Hour, Minute, Second);
for(new x = 0; x < MAX_PLAYERS; x++)
{
if(Logged[x] == 1)
{
if(Second == 60)
{
if(Minute == 60)
{
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)
{
if(Second == 59)
{
Hour = 0;
Minute = 0;
Second = 0;
}
}
if(Minute == 59)
{
if(Second == 59)
{
Hour ++;
Minute = 0;
Second = 0;
}
/*if(Hour == 23)
{
Hour = 0;
Minute = 0;
Second = 0;
}
else
{
Hour ++;
Minute = 0;
Second = 0;
}*/
}
Oh and with the ending, is that it or did you just crop off some bits? I would have thought you would have had to keep doing '}' till you got to the end or something/
Re: Clock issue -
HighFlyer - 29.09.2012
If I change it to sixty, it's adding minutes and not changing seconds from :00 at all
Re: Clock issue -
Socan - 29.09.2012
Oh yeah that's true :/ How about Seconds:59, Minutes:60. Im jsut guessing :/
Re: Clock issue -
iTorran - 29.09.2012
pawn Код:
public ClockUpdate()
{
new string[12];
Second ++;
if(Second == 60)
{
if(Minute == 59)
{
if(Hour == 23) Hour = 0;
else Hour ++;
Minute = 0;
}
else Minute ++;
Second = 0;
}
for(new x = 0; x < MAX_PLAYERS; x++)
{
if(Logged[x] == 1)
{
if(Minute == 0 && Second == 0)
{
if(Player[x][PaydayTime] >= 30)
{
SendClientMessage(x, ORANGE, ">> Your pay cheque is ready to be picked up. Please head to the city hall to claim it.");
CheckReady[x] = 1;
}
else SendClientMessage(x, LIBLUE, ">> You haven't been playing long enough to get a pay cheque.");
}
}
}
format(string, sizeof(string), "%02i:%02i:%02i", Hour, Minute, Second);
TextDrawSetString(Clock, string);
SetWorldTime(Hour);
return 1;
}