SA-MP Forums Archive
Help With Clock System.. - 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: Help With Clock System.. (/showthread.php?tid=395594)



Help With Clock System.. - ArmandoRamiraz - 26.11.2012

I am trying to edit this clock system since all the ones I have tried failed. When i put the clock into the script and go IG, the time shows up (example) as 16:15:4 (hours: minutes: seconds) I was wondering if anyone could possibly tell me how i can make it into a 12 hour clock system?

Код:
forward Clock();
public Clock()
{
    new string[128];
	gettime(thour, tmin, tsec);
	new Day, Month, Year;
	getdate(Year, Month, Day);
	format(string, sizeof(string), "%d:%d:%d", thour, tmin, tsec);
	TextDrawSetString(TimeTD, string);
	foreach(Player, i)
	{
	    if(IsPlayerLoggedIn(i))
	    {
	        if(!IsAFK[i] && !BusTime[i])
	        {
				Seconds[i] ++;
				if(Seconds[i] == 60)
				{
				    Seconds[i] = 0;
				    PlayerInfo[i][pMinutes] ++;
				    if(PlayerInfo[i][pVIPTemp])
				    {
				    	PlayerInfo[i][pVIPTemp] --;
				    	if(PlayerInfo[i][pVIPTemp] <= 0)
				    	{
				    	    PlayerInfo[i][pVIP] = 0;
				    	    PlayerInfo[i][pVIPDay] = 0;
				    	    PlayerInfo[i][pVIPMonth] = 0;
				    	    PlayerInfo[i][pVIPHour] = 0;
				    	    PlayerInfo[i][pVIPTemp] = 0;
					    format(string, sizeof(string), "SERVER: %s's temporary Bronze VIP has expired.", RPN(i));
					    SendAdminMessage(COLOR_DARKRED, 1, string);
					    Log("logs/makevip.log", string);
					    SendClientMessage(i, COLOR_LIGHTBLUE, " Your temporary Bronze VIP has expired.");
				    	}
				    }
				}
				if(PlayerInfo[i][pVIP])
			    {
			        if(Day >= PlayerInfo[i][pVIPDay] && Month >= PlayerInfo[i][pVIPMonth] && !PlayerInfo[i][pVIPTemp])
			        {
				    format(string, sizeof(string), "SERVER: %s's %s VIP has expired.", RPN(i), RPVIPN(i));
				    SendAdminMessage(COLOR_DARKRED, 1, string);
				    Log("logs/makevip.log", string);
				    format(string, sizeof(string), " Your %s VIP has expired.", RPVIPN(i));
				    SendClientMessage(i, COLOR_LIGHTBLUE, string);
				    PlayerInfo[i][pVIP] = 0;
			    	    PlayerInfo[i][pVIPDay] = 0;
			    	    PlayerInfo[i][pVIPMonth] = 0;
			    	    PlayerInfo[i][pVIPHour] = 0;
			    	    PlayerInfo[i][pVIPTemp] = 0;
			        }
			    }
			}
	    }
	}



Re: Help With Clock System.. - NumbSkull - 26.11.2012

do an if thour>12 show thour-12


Re: Help With Clock System.. - ArmandoRamiraz - 27.11.2012

Could you give an example or something?


Re: Help With Clock System.. - NumbSkull - 27.11.2012

pawn Код:
if(hour<= 12)
    {
        format(string, sizeof(string), "%d:0%d", hour, minuite);
    }
    else
    {
        format(string, sizeof(string), "%d:0%d", hour-12, minuite);
    }
and show that in your textdraw or where ever


Re: Help With Clock System.. - ViniBorn - 27.11.2012

pawn Код:
format(string, sizeof(string), "%02d:%02d:%02d", thour, tmin, tsec);



Re: Help With Clock System.. - ArmandoRamiraz - 27.11.2012

Thanks guys I have it working but now all my textdraws are combining together?? Any help?


Re: Help With Clock System.. - maramizo - 27.11.2012

That's before or after the clock creation?


Re: Help With Clock System.. - ArmandoRamiraz - 27.11.2012

nevermind I found out the problem. I had a TD commented out. Thanks though.


Re: Help With Clock System.. - maramizo - 27.11.2012

Wait, what? You're saying all TD's combined together because only ONE was commented out?


Re: Help With Clock System.. - ArmandoRamiraz - 27.11.2012

Yeah? They all showed up at once on the screen. I dont guess that would be the right explanation for it though.