Clock and Time Change
#1

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:

Reply
#2

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;
}
Reply
#3

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)