SA-MP Forums Archive
CMD:tod problem. - 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: CMD:tod problem. (/showthread.php?tid=528059)



CMD:tod problem. - 0B3Y - 26.07.2014

Hi guys, i have a tod command to set players command but the problem is when i do /tod [time] [minutes] the time has applied but within a few seconds the time is rolling back like before -_- Anyone know how to fix this? And here's the command

Код:
CMD:tod(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 1337)
	{
		new string[128], time;
		if(sscanf(params, "d", time)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /tod [time] (0-23)");

		SetWorldTime(time);
		gTime = time;
		format(string, sizeof(string), "Time set to %d:00.", time);
		BroadCast(COLOR_GRAD1, string);
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
	}
	return 1;
}
Thanks guys


Re: CMD:tod problem. - Blademaster680 - 26.07.2014

What do you mean rolling back like before?
If you are trying to set the world time then use
Код:
SetWorldTime(time);
https://sampwiki.blast.hk/wiki/SetWorldTime


Re: CMD:tod problem. - 0B3Y - 26.07.2014

Quote:
Originally Posted by Blademaster680
Посмотреть сообщение
What do you mean rolling back like before?
If you are trying to set the world time then use
Код:
SetWorldTime(time);
https://sampwiki.blast.hk/wiki/SetWorldTime
Basically, the time of my server is realtime... And when i do /tod, it's rolling back the time to the time before i do /tod. And you can see at the code that there is
Код:
SetWorldTime(time);
Anyway, thanks for the quick reply


Re: CMD:tod problem. - Blademaster680 - 26.07.2014

Is your server the time of your timezone in real life? and is the time displaying in a textdraw?


Re: CMD:tod problem. - 0B3Y - 26.07.2014

Yes.


Re: CMD:tod problem. - Blademaster680 - 26.07.2014

Somewere in your code there is something that is checking and changing the time. to keep it at realtime... Try find it and comment it out and see if your problem is fixed


Re: CMD:tod problem. - 0B3Y - 26.07.2014

Alright... i found this
Код:
new realtime = 1;
/////this
	if(!realtime)
	{
  		wtime = (MPHour + 3) % 24;
		SetWorldTime(wtime);
		gTime = wtime;
	}
/////////////this
	if (realtime)
	{
		new tmphour;
		new tmpminute;
		new tmpsecond;
		gettime(tmphour, tmpminute, tmpsecond);
		FixHour(tmphour);
		tmphour = shifthour;
		SetWorldTime(tmphour);
		gTime = tmphour;
	}
////////////////and this
public SyncTime()
{
	new string[128];
	new tmphour;
	new tmpminute;
	new tmpsecond;
	gettime(tmphour, tmpminute, tmpsecond);
	FixHour(tmphour);
	tmphour = shifthour;
	if ((tmphour > ghour) || (tmphour == 0 && ghour == 23))
	{
		WeatherCalling++;
		if(WeatherCalling > 3)
		{
		    WeatherCalling = 0;
		    new rand;
		    rand = random(20);
		    switch(rand)
		    {
          case 0:{ SetWeather(11); gWeather = 11; }
		        case 8:{ SetWeather(12); gWeather = 12; }
		        case 9:{ SetWeather(5); gWeather = 5; }
		        case 16:{ SetWeather(4); gWeather = 4; }
		        case 19:{ SetWeather(20); gWeather = 20; }
		        default:{ SetWeather(rand); gWeather = rand; }
		    }
		}
		format(string, sizeof(string), "Sekarang pukul %d:00.",tmphour);
		BroadCast(COLOR_WHITE,string);
		ghour = tmphour;
		TotalUptime += 1;
		PayDay();
		if (realtime)
		{
			SetWorldTime(tmphour);
			gTime = tmphour;
		}
//////////////
Thats what i found... With "realtime" search keywords


Re: CMD:tod problem. - Blademaster680 - 26.07.2014

Quote:

if(!realtime)
{
wtime = (MPHour + 3) % 24;
SetWorldTime(wtime);
gTime = wtime;
}

Try comment those lines out and see what happens?


Re: CMD:tod problem. - 0B3Y - 26.07.2014

Alright let me try...

Edit: It's not working By the way, i have this wristwatch command
Код:
CMD:wristwatch(playerid, params[])
{
	if(PlayerInfo[playerid][pWristwatch] > 0)
	{
		new string[128];
		if(GetPVarInt(playerid, "wristwatchonoff") == 0)
		{
			SetPVarInt(playerid, "wristwatchonoff", 1);
			new hour,minuite,second;
			gettime(hour,minuite,second);
			FixHour(hour);
			hour = shifthour;
			if(minuite < 10)
			{
				format(string, sizeof(string), "%d:0%d", hour, minuite);
			}
			else
			{
				format(string, sizeof(string), "%d:%d", hour, minuite);
			}
			TextDrawShowForPlayer(playerid, WristWatch);
			format(string, sizeof(string), "* %s turns on their wristwatch.", GetPlayerNameEx(playerid));
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		}
		else
		{
			KillTimer(GetPVarInt(playerid, "wristwatchtimer"));
			TextDrawHideForPlayer(playerid, WristWatch);
			DeletePVar(playerid, "wristwatchonoff");
			format(string, sizeof(string), "* %s turns off their wristwatch.", GetPlayerNameEx(playerid));
			ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		}
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "You don't have a wristwatch!");
	}
	return 1;
}



Re: CMD:tod problem. - Blademaster680 - 26.07.2014

Quote:

gettime(hour,minuite,second);

I think that is what is resetting the time...
I think that is what is getting the time from the real time, and is resetting your time back to realtime