Time problem.. -
dundolina - 16.03.2015
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.
Re: Time problem.. -
DeitY - 16.03.2015
PHP timezone on your dedicated server?
Re: Time problem.. -
dundolina - 17.03.2015
I think no. And i start server on localhost, it is the problem?
Respuesta: Time problem.. -
alexus - 17.03.2015
Have you tried the gl_realtime filterscript included in sa-mp ?
Re: Time problem.. -
dundolina - 17.03.2015
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.
Re: Time problem.. -
CalvinC - 17.03.2015
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.
Respuesta: Time problem.. -
alexus - 17.03.2015
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
Re: Time problem.. -
dundolina - 18.03.2015
I have some shit that block the code. I mean it changes for 1 second and the old sunny weather it's back..
Respuesta: Time problem.. -
alexus - 18.03.2015
Find where you have SetWorldTime or SetPlayerTime. Perhaps you have several timers...
Re: Time problem.. -
dundolina - 18.03.2015
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?