Sync World Time
#1

Hi! Sorry if this topic already exist but I want to know how to Synchronize the World time to the other players (using TogglePlayerClock if possible)

Or can you send me a code for a custom clock (1 in-game hour = 1 real life minute)
Reply
#2

Quote:
Originally Posted by Andre9977
There are a few clock FS'es in Script Showroom
Like:
1) Real life clock by tafi
2) Clock by KAPIL
this is not what i'm looking for, I don't want "real life" clock... I want clock like TogglePlayerClock's clock.... and sync it with other player (exactly as Littlewhitey's mode)
Reply
#3

use timers and toggleplayerclock and setplayertime and getplayer time
Reply
#4

Quote:
Originally Posted by Khaled
use timers and toggleplayerclock and setplayertime and getplayer time
mmmmm ok for me, it will be hard! lol but I'll try
Reply
#5

pawn Код:
#include <time>

forward TimeUpdate();
new worldTime;

public TimeUpdate() {
    worldTime++;
    worldTime%=24;
    SetWorldTime(worldTime);
}

//under gamemode init
    SetTimer("TimeUpdate",65009, 1);
cheerz
Reply
#6

Quote:
Originally Posted by cmg4life
pawn Код:
#include <time>

forward TimeUpdate();
new worldTime;

public TimeUpdate() {
    worldTime++;
    worldTime%=24;
    SetWorldTime(worldTime);
}

//under gamemode init
    SetTimer("TimeUpdate",65009, 1);
cheerz
Thanks! it's not perfectly synchronised, but it works! thanks!
Reply
#7

Sounds sorta like you want a time system like my own... I'll explain what my script does & you let me know if that's what you're looking for

Every REAL second that passes, 12 GAME seconds pass, so every 5 REAL seconds mean 1 GAME minute has passed. Every 1 REAL minute mean 12 GAME minutes goes by & every 5 REAL minutes means 1 GAME hour has passed. Every 1 REAL hour means 12 GAME hours, so every 2 REAL hour would mean a full 24 GAME hour cycle... Confused yet? Heh, this was confusing me just typing it :P

Every 24 GAME hours would then turn the day (Sun-Sat) & also the date(1st-31st) of the month. Once you reach the end of the month, the month turns (Jan-Dec) & finally the year turns at 12 months etc. I use formats to be able to display ALL this information correctly... Use my time command on server would result this similar message:

The day is Tuesday, March 12th of 2004
The time is 5:07am

The light turns with every passing GAME hour as well as weather change, but nothing silly like clear day jumps to storm or anything etc. (Noticed a red sky once or twice though *Shrugs*) I only use 5 possible weather changes though and it doesn't jump, it checks the last weather & then decides what weather may come next... The 5: Clear skies, Cloudy, Real Cloudy, Storm & Fog (Also: Use the correct day/night weathers according to hour etc.)

Now if that's not what you're looking for, are you talking about the in game timer showing players time? I don't use that, sorry. However, I do have plans of supporting the calendar/clock by using Game Text...
Reply
#8

Ok, but thats Game time. he wants Game time = Real Time. I have it done to mine but i dont know what all is needed. The code posted above was perfect from what i saw. Even mines not perfectly synced.
Reply
#9

Quote:
Originally Posted by warlost
(1 in-game hour = 1 real life minute)
That there is why I thought "Gametime", but if it's real time you're after, I can't really help much, sorry
Reply
#10

well xGhostz ur Time is like crap doesnt matches a thing in game a minute = 1 real sec , urs... doesnt
Reply
#11

Quote:
Originally Posted by cmg4life
well xGhostz ur Time is like crap doesnt matches a thing in game a minute = 1 real sec , urs... doesnt
I think my script codes are pretty advanced, but don't call it crap just because it isn't exactly what you're looking for... I mis-understood what this topic was looking for EXACTLY, but I think I understand it NOW. My time system wasn't designed to know the REAL time, yet anyways. But it does support a full working GAME time system which works flawlessly. So what would I use it for? Well, I'm a RPG programer, most stores on server (Clothes, Gym, Cluckin Bells, Etc.) are NOT open 24 hours... Mondays through Fridays opens from 8:00am to 10:00pm, but remains closed for the weekends (In-Game Time)

Nope, can't imagine my time system could really be used for anything
Guess I'll just trash the code then... And then remove it from the Recycle Bin too :P
Reply
#12

Quote:
Originally Posted by Pghpunkid
Ok, but thats Game time. he wants Game time = Real Time. I have it done to mine but i dont know what all is needed. The code posted above was perfect from what i saw. Even mines not perfectly synced.
no, I want 1 real life second = 1 Game time minute, like in single player, but syncronised
Reply
#13

This is an easy synced clock script.

It is not a pro script but hope you like it.

Untested !

pawn Код:
// top
new Timme;
new Minut;

// on filterscript/gamemode init
SetTimer("ClockSync", 1000, 1);

// onplayerspawn
TogglePlayerClock(playerid, 1);

// function

public ClockSync(playerid)
{
  new string[128];
  Minut = Minut + 1;
  if (Minut == 60)
  {
    Timme = Timme + 1;
    Minut = 0;
  }
  for(new i; i<MAX_PLAYERS; i++)
  SetPlayerTime(i, Timme, Minut);
  format(string, sizeof(string), "The time [%d] [%d]", Timme, Minut);
  print(string); // testing only.
  return 1;
}
I hope it works
Don't read this lol
Reply
#14

Thnx sooow much bonas!! i was looking for this also and it works perfectly, all players have the same time now, perfect sync , just everything!

U may be a little clucker but u're damn great!!

thnx again

PS: seen this was posted a long time ago but doesn't meen i shouldn't say thnx
Reply
#15

Quote:
Originally Posted by bonas
This is an easy synced clock script.

It is not a pro script but hope you like it.

Untested !

pawn Код:
// top
new Timme;
new Minut;

// on filterscript/gamemode init
SetTimer("ClockSync", 1000, 1);

// onplayerspawn
TogglePlayerClock(playerid, 1);

// function

public ClockSync(playerid)
{
  new string[128];
  Minut = Minut + 1;
  if (Minut == 60)
  {
    Timme = Timme + 1;
    Minut = 0;
  }
  for(new i; i<MAX_PLAYERS; i++)
  SetPlayerTime(i, Timme, Minut);
  format(string, sizeof(string), "The time [%d] [%d]", Timme, Minut);
  print(string); // testing only.
  return 1;
}
I hope it works
Don't read this lol
I have 1 Warning with this Sync Script

warning 235: public function lacks forward declaration (symbol "ClockSync")

how can i fix this problem? pelase help me

thanx
Reply
#16

full xD

Код:
// top
new Minute=8;
new Second;

// on filterscript/gamemode init
SetTimer("ClockSync", 1000, 1);

// OnPlayerConnect
TogglePlayerClock(playerid, 1);

// function

forward ClockSync();
public ClockSync()
{
  Second++;
  if(Second == 60)
  {
    Minute++;
    Second = 0;
  }
  if(Minute >= 24) Minute = 0;
  for(new i; i<GetMaxPlayers(); i++) SetPlayerTime(i, Minute, Second);
  new string[64];
  format(string, sizeof(string), "The time [%d] [%d]", Minute, Second);
  print(string); // testing only.
  return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)