Hi, I have read a lot about server and client communication but can`t get the tiniest code to run correctly. I guess I have an understanding problem, maybe someone can show me the way…
I try to constantly post the time with print, to test and learn server client communication. I wrote this:
server.lua:
local _,_,_,h,i,j = GetPosixTime()
-- debug command
RegisterCommand("time", function()
print (h,i,j)
end, false)
-- debug end
RegisterNetEvent('getTime')
AddEventHandler('getTime', function()
print(h,i,j)
end)
client.lua:
Citizen.CreateThread(function()
while true do
TriggerServerEvent("getTime")
Citizen.Wait(100)
end
end)
The command time is working and I would expect that the CreateThread function is triggering constantly the EventHandler within the RegisterNetEvent and should print the time but it doesn`t, the time is only displayed when I enter the command /time. What am I missing?