SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/01/2020, 09:24 PM   #11
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 363
Reputation: 17
Default Re: Make the world time the same for everyone

Quote:
Originally Posted by PPC23 View Post
Minutes doesn't change the sky, they change only the clock. If the time is 10:00 or 10:59 - it will be the same. The sky will change at 11, etc..

You can use this to set the hour and minutes for all the players to match the clock:
pawn Code:
#undef SetWorldTime
#define SetWorldTime(%1, %2) for(new i = 0,j = GetPlayerPoolSize();i <= j;i++) if(IsPlayerConnected(i)) SetPlayerTime(i, %1, %2);
Minutes doesn't matter to the sky neither in SetWorldTime or SetPlayerTime.
I'm not sure if I'm misunderstanding.
Quote:
This function is only relevant for players that do not use a passing clock - see TogglePlayerClock.
^ On SetWorldTime

I'm using TogglePlayerClock, and I'm pretty sure it changes the time as time goes by, I could be wrong?
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is offline   Reply With Quote
Old 17/01/2020, 09:32 PM   #12
PPC23
Little Clucker
 
Join Date: Feb 2013
Posts: 26
Reputation: 8
Default Re: Make the world time the same for everyone

About this SetWorldTime:
pawn Code:
#undef SetWorldTime
#define SetWorldTime(%1, %2) for(new i = 0,j = GetPlayerPoolSize();i <= j;i++) if(IsPlayerConnected(i)) SetPlayerTime(i, %1, %2);
It actually undefines the original function and creates a new one that uses the SetPlayerTime function to make the time the same for all players.
You can change it so the original SetWorldTime is availible again:
pawn Code:
#define SetTimeForAll(%1, %2) for(new i = 0,j = GetPlayerPoolSize();i <= j;i++) if(IsPlayerConnected(i)) SetPlayerTime(i, %1, %2);

You can use it as SetTimeForAll(hour, minutes);


EDIT:
This is all wrong. When you use SetPlayerTime to set the player's time, when the player pauses the game so the clock, so this is how the clock get's desynced for some players.
SetWorldTime doesn't have this problem, because the time is the same for all.
Disadvantage is that you can't set the minute here.
I'll try to work on this. ALTERNATIVE

Sorry for the confusion.
PPC23 is offline   Reply With Quote
Old 17/01/2020, 11:15 PM   #13
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 363
Reputation: 17
Default Re: Make the world time the same for everyone

Quote:
Originally Posted by PPC23 View Post
About this SetWorldTime:
pawn Code:
#undef SetWorldTime
#define SetWorldTime(%1, %2) for(new i = 0,j = GetPlayerPoolSize();i <= j;i++) if(IsPlayerConnected(i)) SetPlayerTime(i, %1, %2);
It actually undefines the original function and creates a new one that uses the SetPlayerTime function to make the time the same for all players.
You can change it so the original SetWorldTime is availible again:
pawn Code:
#define SetTimeForAll(%1, %2) for(new i = 0,j = GetPlayerPoolSize();i <= j;i++) if(IsPlayerConnected(i)) SetPlayerTime(i, %1, %2);

You can use it as SetTimeForAll(hour, minutes);


EDIT:
This is all wrong. When you use SetPlayerTime to set the player's time, when the player pauses the game so the clock, so this is how the clock get's desynced for some players.
SetWorldTime doesn't have this problem, because the time is the same for all.
Disadvantage is that you can't set the minute here.
I'll try to work on this. ALTERNATIVE

Sorry for the confusion.
That solution works well. Thanks!
__________________
Developer @ Trucknation
Administrator & Developer @ Lost Legacy
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
Proxus is offline   Reply With Quote
Old 18/01/2020, 05:24 PM   #14
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: 🇩🇪
Posts: 1,652
Reputation: 559
Default Re: Make the world time the same for everyone

Quote:
Originally Posted by PPC23 View Post
About this SetWorldTime:
pawn Code:
#undef SetWorldTime
#define SetWorldTime(%1, %2) for(new i = 0,j = GetPlayerPoolSize();i <= j;i++) if(IsPlayerConnected(i)) SetPlayerTime(i, %1, %2);
It actually undefines the original function and creates a new one that uses the SetPlayerTime function to make the time the same for all players.
You can change it so the original SetWorldTime is availible again:
pawn Code:
#define SetTimeForAll(%1, %2) for(new i = 0,j = GetPlayerPoolSize();i <= j;i++) if(IsPlayerConnected(i)) SetPlayerTime(i, %1, %2);

You can use it as SetTimeForAll(hour, minutes);


EDIT:
This is all wrong. When you use SetPlayerTime to set the player's time, when the player pauses the game so the clock, so this is how the clock get's desynced for some players.
SetWorldTime doesn't have this problem, because the time is the same for all.
Disadvantage is that you can't set the minute here.
I'll try to work on this. ALTERNATIVE

Sorry for the confusion.
You can use SendRconCommand("worldtime 6:08"); to set the global time including minutes.
NaS is offline   Reply With Quote
Old 20/01/2020, 11:40 PM   #15
TAKTAK26
Little Clucker
 
Join Date: Nov 2018
Posts: 33
Reputation: 0
Default Re: Make the world time the same for everyone

Fix++
TAKTAK26 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
World Time AnonScripter Scripting Help 3 03/10/2013 10:01 PM
how to set player's time same as world time memeli11 Scripting Help 0 02/05/2013 08:35 PM
Get World Time VirSpectorX Help Archive 13 22/06/2010 02:36 PM
[HELP] World time. screw Help Archive 3 02/01/2010 07:46 PM
[HELP]How To set world time. arachimi Help Archive 1 22/12/2009 11:10 PM


All times are GMT. The time now is 03:55 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.