SA-MP Forums Archive
Clock and Time Change - 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: Clock and Time Change (/showthread.php?tid=482778)



Clock and Time Change - SplinteX - 22.12.2013

Hello

How can I toggle player clock and time changing (time changing:when time is 22:00 its night,when time is 13:00 its day) like this:




Re: Clock and Time Change - Lynn - 22.12.2013

If all you want is the clock to show it's:

pawn Код:
public OnPlayerConnect(playerid)
{
    TogglePlayerClock(playerid, 1);// 1 for show, 0 for disabled.
    return 1;
}



Re: Clock and Time Change - TheOriginal1337 - 22.12.2013

I think this is what you are looking for..
Make sure you have the include foreach!

Код HTML:
#include <foreach>

new Text:txtTimeDisp;

SetTimer("UpdateTime",1000,true); // ONGameModeInit

	txtTimeDisp = TextDrawCreate(605.0,15.0,"00:00");
	TextDrawUseBox(txtTimeDisp, 0);
	TextDrawFont(txtTimeDisp, 3);
	TextDrawSetShadow(txtTimeDisp,0); // no shadow
    TextDrawSetOutline(txtTimeDisp,2); // thickness 1
    TextDrawBackgroundColor(txtTimeDisp,0x000000FF);
    TextDrawColor(txtTimeDisp,0xFFFFFFFF);
    TextDrawAlignment(txtTimeDisp,3);
	TextDrawLetterSize(txtTimeDisp,0.5,1.5);

forward UpdateTime();
public UpdateTime()
{

	///////// TIME SHIT ////////
	gminute++;
	if( gminute == 60 ){ gminute = 0; ghour++; }
	if( gminute < 0 ) gminute = 0;
	if( ghour == 24 ) ghour = 0;
	if( ghour < 0 ) ghour = 0;
   	format(timestr,32,"%02d:%02d",ghour,gminute);
   	TextDrawSetString(txtTimeDisp,timestr);
   	SetWorldTime(ghour);

	foreach(Player,x)
	{
	    if(IsPlayerConnected(x) && GetPlayerState(x) != PLAYER_STATE_NONE)
		{
  			SetPlayerTime(x,ghour,gminute);
	 	}
	}
}

	TextDrawShowForPlayer(playerid,txtTimeDisp); // OnPlayerSpawn
	SetPlayerTime(playerid,ghour,gminute); //OnPlayerSpawn

       TextDrawHideForPlayer(playerid,txtTimeDisp); //OnPlayerDeath