Global time bug - 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: Global time bug (
/showthread.php?tid=556283)
Global time bug -
ATGOggy - 10.01.2015
This is my global time system:
PHP код:
public TimeU()
{
new string[7];
Tsec+=1;
if(Tsec==60)
{
Tsec=00;
THrs+=1;
}
if(THrs==24)
{
Tsec=00;
THrs=0;
}
if(Tsec<10)
{
format(string,sizeof(string),"%d:0%d",THrs,Tsec);
}
if(Tsec>10)
{
format(string,sizeof(string),"%d:%d",THrs,Tsec);
}
if(THrs<10)
{
format(string,sizeof(string),"0%d:%d",THrs,Tsec);
}
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SetPlayerTime(i,THrs,Tsec);
}
}
TextDrawSetString(Time,string);
}
But there is a problem
For example, when time is 2:2, it is is showing 02:2 instead of 02:02
How can I fix it?
Re: Global time bug -
]Rafaellos[ - 10.01.2015
Simple enough. No need to check for seconds, etc.
pawn Код:
format(string, sizeof(string), "%02d:%02d", THrs, Tsec);
Re: Global time bug -
ATGOggy - 10.01.2015
Found out the problem.
Why it always happens. Everytime, I tries to fix the problem my self and I won't find any solution. And then, Ill post here.
But, as soon as I post here, I'll find out the solution myself. -_-
EDIT:
Quote:
Originally Posted by ]Rafaellos[
Simple enough. No need to check for seconds, etc.
pawn Код:
format(string, sizeof(string), "%02d:%02d", THrs, Tsec);
|
Sorry, I didn't see your post. I fixed it myself. The problem was in the 5th 'if', that if changes everything in the string. Anyway, thanks for your help.