13.04.2012, 19:54
Yeah, that's what I wanna know; what shall I do if I wanna use the time like in GTA SA Singleplayer? That there'd be a textdraw and each second one minute would pass...just like in singleplayer. How to do that?
TogglePlayerClock(playerid,1);
#include <a_samp>
forward RealHourUpdate();
new T_MIN=0, T_HOUR=23, T_DAY=0;
new WorldTime;
new Text:DAN;
new Text:Clock;
public OnPlayerSpawn(playerid)
{
TextDrawShowForAll(DAN);
TextDrawShowForAll(Clock);
return 1;
}
public OnGameModeInit()
{
SetTimer("SetRandomWeather", 420000, true); //HERE!!!!!!!
SetTimer("RealHourUpdate", 1000, true);
DAN = TextDrawCreate(497.000000, 5.000000, "");
TextDrawFont(DAN, 3);
TextDrawLetterSize(DAN, 0.6, 1.5);
TextDrawSetOutline(DAN, 2);
TextDrawSetProportional(DAN, 1);
TextDrawSetShadow(DAN, 1);
Clock = TextDrawCreate(546.9, 21.0, "");
TextDrawSetShadow(Clock, 1);
TextDrawSetOutline(Clock, 2);
TextDrawLetterSize(Clock, 0.6, 2.4);
TextDrawFont(Clock, 3);
TextDrawSetProportional(Clock, 1);
return 1;
}
public RealHourUpdate()
{
new h, m, sc;
gettime(h, m, sc);
if(WorldTime != h)
{
WorldTime = h;
SetWorldTime(T_HOUR);
}
T_MIN++;
if(T_MIN == 60)
{
T_MIN=0;
T_HOUR++;
}
if(T_HOUR == 24)
{
T_HOUR=0;
T_DAY++;
}
new string[256];
if(T_MIN < 10)
{
if(T_HOUR < 10)
{
format(string,sizeof(string),"0%d:0%d",T_HOUR,T_MIN);
TextDrawSetString(Clock,string);
}
else
{
format(string,sizeof(string),"%d:0%d",T_HOUR,T_MIN);
TextDrawSetString(Clock,string);
}
}
else
{
if(T_HOUR < 10)
{
format(string,sizeof(string),"0%d:%d",T_HOUR,T_MIN);
TextDrawSetString(Clock,string);
}
else
{
format(string,sizeof(string),"%d:%d",T_HOUR,T_MIN);
TextDrawSetString(Clock,string);
}
}
/*new str[256];
format(str, 256, "worldtime %02d:%02d", T_HOUR, T_MIN);
SendRconCommand(str);*/
for(new g = 0; g < 200; g++)
{
}
}