diff --git a/ss_cli_time.lua b/ss_cli_time.lua index 344fa39..ee45173 100644 --- a/ss_cli_time.lua +++ b/ss_cli_time.lua @@ -47,3 +47,11 @@ Citizen.CreateThread( function() NetworkOverrideClockTime( math.floor( secondOfDay / 3600 ), math.floor( (secondOfDay - (h * 3600)) / 60 ), secondOfDay - (math.floor( secondOfDay / 3600 ) * 3600) - (math.floor( (secondOfDay - (h * 3600)) / 60 ) * 60) ) end end) + +RegisterNetEvent("addTimeChatSuggests") +AddEventHandler("addTimeChatSuggests", function() + TriggerEvent('chat:addSuggestion', '/time', 'Change the time.', { + { name="hour" , help="Hour of day in 24 hour format."}, + { name="minute", help="Minute of the hour."} + }) +end) \ No newline at end of file diff --git a/ss_srv_time.lua b/ss_srv_time.lua index b7851f5..be11060 100644 --- a/ss_srv_time.lua +++ b/ss_srv_time.lua @@ -18,6 +18,14 @@ Citizen.CreateThread(function() end end) +RegisterServerEvent( "addTimeChatSuggests" ) +AddEventHandler( "addTimeChatSuggests", function() + if IsPlayerAceAllowed(source, "changeTime") then + TriggerClientEvent ("addTimeChatSuggests",source) + end +end) + + Citizen.CreateThread( function() local timeBuffer = 0.0 local h = 0 @@ -61,15 +69,19 @@ RegisterCommand('time', function(source,args,rawCommand) end else if IsPlayerAceAllowed(source, "changeTime") then - ProcessTimeCommand(args[1],args[2]) - h = math.floor( secondOfDay / 3600 ) - m = math.floor( (secondOfDay - (h * 3600)) / 60 ) - TraceMsg(GetPlayerName(source).." has changed time to " ..string.format("%02d", h)..":"..string.format("%02d",m)) + if tonumber(args[1]) ~= nil and tonumber(args[2]) ~= nil then + ProcessTimeCommand(args[1],args[2]) + h = math.floor( secondOfDay / 3600 ) + m = math.floor( (secondOfDay - (h * 3600)) / 60 ) + TraceMsg(GetPlayerName(source).." has changed time to " ..string.format("%02d", h)..":"..string.format("%02d",m)) + else + TraceMsg("Invalid syntax, correct syntax is: time .",true) + end else TraceMsg('Access for command /time denied for player: '.. GetPlayerName(source),true) end end -end, false) +end, true) RegisterCommand('freezetime', function(source,args,rawCommand) h = math.floor( secondOfDay / 3600 ) @@ -86,7 +98,7 @@ RegisterCommand('freezetime', function(source,args,rawCommand) TraceMsg('Access for command /freezetime denied for player: '.. GetPlayerName(source),true) end end -end, false) +end, true) function ProcessTimeCommand(arg1,arg2) @@ -94,12 +106,12 @@ function ProcessTimeCommand(arg1,arg2) local m = 0 local argh = tonumber(arg1) local argm = tonumber(arg2) - if argh < 24 then + if argh < 24 and argh ~= nil then h = argh else h = 0 end - if argm < 60 then + if argm < 60 and arm ~= nil then m = argm else m = 0 diff --git a/ss_srv_weather.lua b/ss_srv_weather.lua index 1f64f78..1d7817c 100644 --- a/ss_srv_weather.lua +++ b/ss_srv_weather.lua @@ -135,4 +135,4 @@ RegisterCommand('weather', function(source, args) end end -end, false) \ No newline at end of file +end, true) \ No newline at end of file