SA-MP Forums Archive
Need Help: On the 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: Need Help: On the Clock system. (/showthread.php?tid=402766)



Need Help: On the Clock system. - Peet - 27.12.2012

I been researching on how to script a clock system that supports the real life time and also include the Daytime and Night time system. Here is an screenshot that can use as an example.

:

I attempts to put the Setplayertime or Setworldtime, Noting can match the image.

"I doubt that there might be the similar topic that is related to mines but I seriously can't find a way out."

Hopefully you scripters out there can help me reslove this.


Re: Need Help: On the Clock system. - Dragonborn - 28.12.2012

Hm, i think that the reason (If i understand what you want) is... You're using the var of the hour to set the Player/World Time ? If you don't understand, see the example :
pawn Код:
new hour, minute, second;
    gettime(hour, minute, second);
    SetWorldTime(hour);
Study the FS about time, created by SAMP Team, "gl_realtime"
here : http://pastebin.com/yjgtCJP0

Hope that helped you !


Re: Need Help: On the Clock system. - David (Sabljak) - 28.12.2012

Try this

OnGameModInit

Код:
SetTimer("settime",1000,true);
	Date = TextDrawCreate(4.000000, 297.000000,"--");
	TextDrawFont(Date,3);
	TextDrawLetterSize(Date,0.399999,1.600000);
	TextDrawColor(Date,10944511);
	TextDrawSetOutline(Date, 1);
	SetTimer("settime",1000,true);
	Time = TextDrawCreate(21.000000, 310.000000,"--");
	TextDrawFont(Time,3);
	TextDrawLetterSize(Time,0.399999,1.600000);
	TextDrawColor(Time,10944511);
	TextDrawSetOutline(Time, 1)
on top

Код:
new Text:Time, Text:Date;
OnPlayerSpawn or OnPlayerConnect

Код:
TextDrawShowForPlayer(playerid, Time);
	TextDrawShowForPlayer(playerid, Date);
on bottom

Код:
public settime(playerid)
{
new string[256],year,month,day,hours,minutes,seconds;
getdate(year, month, day), gettime(hours, minutes, seconds);
format(string, sizeof string, "%d/%s%d/%s%d", day, ((month < 10) ? ("0") : ("")), month, (year < 10) ? ("0") : (""), year);
TextDrawSetString(Date, string);
format(string, sizeof string, "%s%d:%s%d:%s%d", (hours < 10) ? ("0") : (""), hours, (minutes < 10) ? ("0") : (""), minutes, (seconds < 10) ? ("0") : (""), seconds);
TextDrawSetString(Time, string);
}



Re: Need Help: On the Clock system. - Peet - 28.12.2012

Thanks for the guide/help. Problem solved.