Skip to content

Commit

Permalink
VinaFramework update
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Dec 6, 2020
1 parent 522de76 commit ba88b21
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 31 deletions.
35 changes: 6 additions & 29 deletions FiveM_TimeSyncServer/Modules/TimeSyncModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,12 @@ public TimeSyncModule(Server server) : base(server)
script.SetExport("GetTimeIsPaused", new Func<bool>(ExportGetTimeIsPaused));
script.SetExport("SetTimeIsPaused", new Action<bool>(ExportSetTimeIsPaused));

script.SetExport("GetCurrentDateTicks", new Func<long>(ExportCurrentDateTicks));
script.SetExport("GetCurrentDateTicks", new Func<long>(ExportGetCurrentDateTicks));
script.SetExport("SetCurrentDateTicks", new Action<long>(ExportSetCurrentDateTicks));
}

#region ACCESSORS

public DateTime RealDate
{
get
{
return DateTime.Now;
}
}

public TimeSpan RealTime
{
get
{
return RealDate.TimeOfDay;
}
}

public DateTime CurrentDate
{
get
Expand All @@ -53,14 +37,6 @@ public DateTime CurrentDate
}
}

public TimeSpan CurrentTime
{
get
{
return CurrentDate.TimeOfDay;
}
}

public bool Paused
{
get
Expand Down Expand Up @@ -183,7 +159,7 @@ private async Task PeriodicConsolePrint()

if (!printEnabled) return;

script.Log($@"SERVER CURRENT TIME: {CurrentDate.ToString(printFormat)}");
script.Log($@"SERVER CURRENT TIME: {((Paused) ? "[PAUSED]" : "")}{CurrentDate.ToString(printFormat)}");
}

#endregion
Expand Down Expand Up @@ -256,18 +232,19 @@ private bool ExportGetTimeIsPaused()
private void ExportSetTimeIsPaused(bool isPaused)
{
SetTimePaused(isPaused);
script.Log($"Server time has been {((isPaused) ? "Paused" : "Unpaused")} from an Export call.");
script.Log($"Server time has been {((isPaused) ? "Paused" : "Unpaused")} at {CurrentDate.ToString(printFormat)} from an Export call.");
}

private long ExportCurrentDateTicks()
private long ExportGetCurrentDateTicks()
{
return CurrentDate.Ticks;
}

private void ExportSetCurrentDateTicks(long ticks)
{
lastServerTime = new DateTime(ticks);
script.Log("Server time has been set from an Export call.");
UpdatePlayerDateTime();
script.Log($"Server time has been set to {CurrentDate.ToString(printFormat)} from an Export call.");
}

#endregion
Expand Down
8 changes: 6 additions & 2 deletions __resource.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
game 'gta5'
client_script 'VinaFrameworkClient.dll'
client_script 'FiveM_TimeSync.net.dll'
server_script 'FiveM_TimeSyncServer.net.dll'
server_script 'FiveM_TimeSyncServer.net.dll'

files {
"Newtonsoft.Json.dll",
"VinaFrameworkClient.dll",
}

0 comments on commit ba88b21

Please sign in to comment.