16.01.2015, 08:29
Hello , i want to know how to set Day and night in the server or it depends on the place of hosting?
new Text:Time;
new Tsec;
new THrs;
Time = TextDrawCreate(578.000000, 14.000000, "00:00");
TextDrawAlignment(Time, 2);
TextDrawFont(Time, 3);
TextDrawLetterSize(Time, 0.609999, 3.299998);
TextDrawColor(Time, -1);
TextDrawSetOutline(Time, 1);
TextDrawSetProportional(Time, 0);
TextDrawSetSelectable(Time, 0);
Tsec= 0;
THrs= 0;
SetTimer("TimeU",60000,true);
forward TimeU();
public TimeU()
{
new string[7];
Tsec+=1;
if(Tsec==60)
{
Tsec=0;
THrs+=1;
}
if(THrs==24)
{
Tsec=0;
THrs=0;
}
if(THrs>10)
{
if(Tsec<10)
{
format(string,sizeof(string),"%d:0%d",THrs,Tsec);
}
if(Tsec>9)
{
format(string,sizeof(string),"%d:%d",THrs,Tsec);
}
}
if(THrs<10)
{
if(Tsec<10)
{
format(string,sizeof(string),"0%d:0%d",THrs,Tsec);
}
if(Tsec>9)
{
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);
}
new THrs;
new Tmin;
new Text:Time;
SetTimer("TimeU", 30000, true);
Time = TextDrawCreate(578.000000, 14.000000, "00:00");
TextDrawAlignment(Time, 2);
TextDrawFont(Time, 3);
TextDrawLetterSize(Time, 0.609999, 3.299998);
TextDrawColor(Time, -1);
TextDrawSetOutline(Time, 1);
TextDrawSetProportional(Time, 0);
TextDrawSetSelectable(Time, 0);
forward TimeU();
public TimeU()
{
new string[7], second;
gettime(THrs, Tmin, second);
if(THrs>10)
{
if(Tmin<10)
{
format(string,sizeof(string),"%d:0%d",THrs,Tmin;
}
if(Tmin>9)
{
format(string,sizeof(string),"%d:%d",THrs,Tmin);
}
}
if(THrs<10)
{
if(Tmin<10)
{
format(string,sizeof(string),"0%d:0%d",THrs,Tmin);
}
if(Tmin>9)
{
format(string,sizeof(string),"0%d:%d",THrs,Tmin);
}
}
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SetPlayerTime(i,THrs,Tmin);
}
}
TextDrawSetString(Time,string);
}
SetTimerEx("Clock", 1000, true, "i", playerid);
forward Clock(playerid);
public Clock(playerid)
{
new Hour, Minute, Second;
gettime(Hour, Minute, Second);
if(Hour == 12) return SetPlayerTime(playerid, 12, 0);
if(Hour == 13) return SetPlayerTime(playerid, 13, 0);
// (.....) you catch idea;
if(Hour == 20) return SetPlayerTime(playerid, 20, 0);
//(.....)
if(Hour == 1) return SetPlayerTime(playerid, 0, 0);
return 1;
}