Server Time = Real Time
#1

Hello!

First of all, I've been trying to set the server time go as real time. What I mean by this is 1 hour server time is equal to real 1 hour, 1 minute of server is equal to real 1 minute and 1 second of server is equal to real 1 second, but I couldn't get a hang of it..
I do not want the time to be set as the player country time. When a player joins, his time should remain as default server time.

Secondly, When a player dies, I want the time to stay the same, like for example, if a player dies at 14:30, I want that when he spawns back, his time is again 14:30.

A guideline to the right path would be highly appreciated.
Reply
#2

Use gettime function and SetPlayerTime.

E.G.

PHP код:
new hoursminutes;
gettime(hoursminutes);
SetPlayerTime(playeridhoursminutes); 
Place it on a timer or OnPlayerUpdate
Reply
#3

Quote:
Originally Posted by JaKe Elite
Посмотреть сообщение
Use gettime function and SetPlayerTime.

E.G.

PHP код:
new hoursminutes;
gettime(hoursminutes);
SetPlayerTime(playeridhoursminutes); 
Place it on a timer or OnPlayerUpdate
Though I asked for a guideline but can you please explain it a bit on how to? Because I tried the same thing using wiki.sa-mp.com but It wasn't setting the time back, it reset the time (just like normal).. :/
Reply
#4

What it basically do is get the real time (the server's host location) - it stores the returned hour & minute time of the server's host location real time into a variable. You use that variable to set a player's game time using the SetPlayerTime function.

Placing it on a timer or OnPlayerUpdate callback will cause you no hassle or troubles as no matter what you do, set the player time manually with a cmd etc. it will set back to the server's real time hence why I recommend you to put it on a timer or OnPlayerUpdate.
Reply
#5

Simply use gl_realtime filterscript or take a look at the .pwn file inside your filterscripts folder
Reply
#6

Quote:
Originally Posted by Lucases
Посмотреть сообщение
Simply use gl_realtime filterscript or take a look at the .pwn file inside your filterscripts folder
This will make it so a day cycle takes 24 hours, and is linked to the servers local time.

There are other ways to make the time synchronized between players, which is more likely what you actually want.


The ways use the same methods, just a different way of tracking the time itself.
Reply
#7

I guess I explained a bit wrong.
Well using
Код:
	new hours, minutes;
	gettime(hours, minutes);
	SetPlayerTime(playerid, minutes);
is fine to sync the player time with server time. Even gl_realtime would do the job, but I wanted that if player uses the command /time, it continues from there, and the above 2 methods wont let it be, they'll sync the time continuously.
Then I thought of using a timer on the above code and killing the timer when "/time" has been used but then that would again continue as 1 server minute = 1 real second which I don't really want.

Is there another way to do it?
If not, I guess we can just get the real minutes and set just the minutes. That would even continue if player uses /time.. But how can I set just the minutes?

I don't want the time to sync between the players. I just want that the day cycles in 24 hours.
Reply
#8

You are actually wanting to sync it, and it is in the same method as the gl_realtime... The only difference is that the checking of the servers time isn't needed, but what does need to be is a variable set which is hour/min/seconds, and simply count the time at a relative speed.

Here's something that may assist you, as I have also used it in the past.

https://sampforum.blast.hk/showthread.php?tid=257071
Reply
#9

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
You are actually wanting to sync it, and it is in the same method as the gl_realtime... The only difference is that the checking of the servers time isn't needed, but what does need to be is a variable set which is hour/min/seconds, and simply count the time at a relative speed.

Here's something that may assist you, as I have also used it in the past.

https://sampforum.blast.hk/showthread.php?tid=257071
But then the players will not be able to change their time with "/time"
Reply
#10

Quote:
Originally Posted by TahaMhr
Посмотреть сообщение
But then the players will not be able to change their time with "/time"
You can make that happen, but you'll be changing time for everyone, which is why that's usually an admin command.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)