Time problem..
#1

Hello i have time problem and i cant solve it. I want to make the weather in server to be are what in my country. For example - in 19:00 it comes night and in the server comes night. For me night comes at 23;30. I add many "time systems" but dont work for me.
Reply
#2

PHP timezone on your dedicated server?
Reply
#3

I think no. And i start server on localhost, it is the problem?
Reply
#4

Have you tried the gl_realtime filterscript included in sa-mp ?
Reply
#5

Yes but dont work i think. I think i need some timer to set time on right hour and i'll update it when it comes summer and etc.
Reply
#6

Use gettime.
pawn Код:
new Hour;
gettime(Hour);
SetWorldTime(Hour);
You can use a repeating timer to apply the time.
Or loop through all players and use SetPlayerTime, which gives you the ability to set the minutes as well as hours.
Reply
#7

I will give you all the necessary:

Код:
#define DIF_HOUR 4 // the difference between "gettime" hour and yours

new hour, minute, Text:txtTime, timestr[32];

forward UpdateTime()

public UpdateTime()
{
	gettime(hour, minute);
	format(timestr,32,"%02d:%02d",hour,minute);
	TextDrawSetString(txtTime,timestr);
	new x=0;
	while(x!=MAX_PLAYERS)
	{
		if(IsPlayerConnected(x) && GetPlayerState(x) != PLAYER_STATE_NONE) SetPlayerTime(x,hour,minute);
		x++;
	}
	hour += DIF_HOUR;
	if (hour>23) hour -= 24;
	SetWorldTime(hour);  // here you add de difference in hours
}
OnGameModeInit
Код:
	txtTime = TextDrawCreate(605.0,25.0,"00:00");
	TextDrawUseBox(txtTime, 0);
	TextDrawFont(txtTime, 3);
	TextDrawSetShadow(txtTime,0);
	TextDrawSetOutline(txtTime,2);
	TextDrawBackgroundColor(txtTime,0x000000FF);
	TextDrawColor(txtTime,0xFFFFFFFF);
	TextDrawAlignment(txtTime,3);
	TextDrawLetterSize(txtTime,0.5,1.5);
	UpdateTime();
	SetTimer("UpdateTime",1000 * 60,1);
OnPlayerConnect
Код:
	TogglePlayerClock (playerid, 0);
	gettime (hour, minute);
	SetPlayerTime (playerid,hour,minute);
OnPlayerSpawn
Код:
	TextDrawShowForPlayer(playerid,txtTime);
	gettime(hour, minute);
	SetPlayerTime(playerid,hour,minute);
OnPlayerDeath
Код:
TextDrawHideForPlayer(playerid,txtTime);
It will work with integer DIF_HOUR only
Reply
#8

I have some shit that block the code. I mean it changes for 1 second and the old sunny weather it's back..
Reply
#9

Find where you have SetWorldTime or SetPlayerTime. Perhaps you have several timers...
Reply
#10

I have "SetPlayerTime" on many places. I have it for temp ban and if i delete it the command still works? And i have this function on one timer. It will bug or no?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)