I am now attempting to create a script which would check what time it is (in game) and @ 7am i want to script to trigger a event.
So far i have added only 1 .lua in the client folder which contains the following script:
RegisterNetEvent(âMSQPlaySoundâ)
local MSQPlaySound = true
AddEventHandler(âMSQPlaySoundâ, function(time)
Citizen.CreateThread(function()
while true do
Citizen.Wait(1)
if ASData.time.h = 7 then
TriggerEvent(âexampleâ)
end
end)
end)
**If anyone has the time, can you please review the above and let me know what im missing?
Remove that function entirely. Go to the clientâs additional-sync.lua, find the thread function -- In-game Clock Manipulation Loop. Youâll want it to look something like the following:
-- In-game Clock Manipulation Loop
Citizen.CreateThread( function()
while not hasBeenInitialised do
Wait( 500 )
end
local timeBuffer = 0.0
local triggered7amToday = false
local triggered8amToday = false
while true do
Wait( 33 ) -- (int)(GetMillisecondsPerGameMinute() / 60)
if not ASData.time.frozen then
local gameSecond = 33.333 / ASData.time.rates.night
if secondOfDay >= 19800 and secondOfDay <= 75600 then
gameSecond = 33.333 / ASData.time.rates.day
end
timeBuffer = timeBuffer + round( 33.0 / gameSecond, 0 )
if timeBuffer >= 1.0 then
local skipSeconds = math.floor( timeBuffer )
timeBuffer = timeBuffer - skipSeconds
secondOfDay = secondOfDay + skipSeconds
if secondOfDay >= 86400 then
secondOfDay = secondOfDay % 86400
end
end
end
-- Apply time
ASData.time.h = math.floor( secondOfDay / 3600 )
ASData.time.m = math.floor( (secondOfDay - (ASData.time.h * 3600)) / 60 )
ASData.time.s = secondOfDay - (ASData.time.h * 3600) - (ASData.time.m * 60)
NetworkOverrideClockTime( ASData.time.h, ASData.time.m, ASData.time.s )
-- Trigger time based events
if ASData.time.h == 7 and ASData.time.m == 0 and triggered7amToday == false then
triggered7amToday = true;
TriggerEvent( "My7amEvent" );
elseif ASData.time.h == 7 and ASData.time.m > 0 then
triggered7amToday = false;
end
if ASData.time.h == 8 and ASData.time.m == 0 and triggered8amToday == false then
triggered8amToday = true;
TriggerEvent( "My8amEvent" );
elseif ASData.time.h == 8 and ASData.time.m > 0 then
triggered8amToday = false;
end
end
end)
Itâs coded like this because you probably want the event to fire only once, and with the time rate in mind, itâs possible to skip seconds, thatâs why you reset the variable when itâs safe to do so (when the minute has passed) so it wonât get called twice that day. Youâll still have to make your âMy7amEventâ etc. yourselfâŠ
With es_roleplay, i have a weird and unconfortable bug. The game âblinkâ and âflashâ sometimes ( like all the 20 sec), when i disable ACL, itâs gone.
Someone can help me with that ? I really need this script for whitelisting with SteamID
Update ! I tried to record the bug, and i think with what i found can help me to resolve the problem. The time set to to night like 0.3ms, and i donât know why. I remove all the sync related in es_roleplay, but still happenning. I REALLY need youâre help guys !
@Ryload I donât know anything about es_roleplay but if itâs doing its own synchronization you really do need to disable that entirely (video is unavailable for me).
@J_Sickness Players should be syncing. The leading variable on the server is secondsOfDay. You are correct that MSQASInit initializes the client on spawn.
Oh yeah sorry about the video, private Youtube shit⊠Well i tried to disable everything about sync in es_roleplay but even with that it didnât work
Otherwise, i would assume that you would need to find the hash for each type of police and then force disable them on the server - similar to what is scripted for the no peds in this script.
iâve the same issue, if i put day, all people already here will have day, but newly arrived peoples will have night. thatâs why i would like remove time sync but keep others functionalities of this mod.
Edit: work now perfectly with the v1.0.6 and admins IP replaced! Also you have to be admin to use any commands otherwise it donât work.
I installed the additional server sync in my server resources, added it to citmp-server, but ingame, when I use chat (T) and
write for example /playerstatus or /time NIGHT nothing happens and in the RCom panel this appears:
error during NUI callback chatResult: citizen:/scripting/lua/scheduler.lua243: bad argument #1 to âunpackâ (table expected got nil)
Hello guys, thx for this awesome release MsQerade.
I have a litte problem and I donât know where to check.
Every new player can join when I add the steam ID they have.
Everything work, every player, except one, I tried to put him at the top, at the middle of the list, I have a â,â at every line except the last.
All player can connect except him, he has steam opening and when he try to connect he has the message âthis is a private server, âŠâ but in the console its the same ID steam in the file.
here is my ACL config and the console when he connect.
Its Meteorys in the file and Materiax in the console.