I'm in your plugin added a couple of lines:
Code:Time = "Текущее время: {time}",And it works. Can add to the casual players check time? Add another minute need.Code:function PLUGIN:cmdTime(player, cmd, args) self:SendMessage(player, self:Parse(self.Config.Messages["Time"], { time = math.floor(Sky.Hour) })) end
Day & Night System [Unmaintained]
Discussion in 'Plugin Support' started by Mughisi, Oct 22, 2014.
-
please Update for new Version ....
-
-
I know that this is a hard work, thank you ....
-
Is there any chance to get this Plugin work ?
#edit#
Sorry for double posting, next Time i use "EDIT"Last edited by a moderator: Nov 26, 2014 -
-
Fixed your plugin <3
Code:-- -------------------------------------------------------------------------------------- -- m-Time.lua -- -------------------------------------------------------------------------------------- -- This plugin allows an admin modify the ingame time or freeze the time entirely. -- --------------------------------------------------------------------------------------PLUGIN.Title = "Time Changer" PLUGIN.Description = "Change the ingame time." PLUGIN.Version = V(0, 2, 0) PLUGIN.HasConfig = true PLUGIN.Author = "Mughisi"local Sky = nil local Time = nilfunction PLUGIN:Init() command.AddChatCommand("settime", self.Object, "cmdSetTime") command.AddChatCommand("freezetime", self.Object, "cmdFreezeTime") command.AddChatCommand("unfreezetime", self.Object, "cmdUnfreezeTime") command.AddConsoleCommand("env.time", self.Object, "ccmdEnvTime") command.AddConsoleCommand("env.freeze", self.Object, "ccmdEnvTime") command.AddConsoleCommand("env.unfreeze", self.Object, "ccmdEnvTime") self:LoadSavedData() timer.Once(0.1, function() Sky = global.TOD_Sky.get_Instance().Cycle Time = global.TOD_Sky.get_Instance():GetComponent("TOD_Components"):GetComponent("TOD_Time") if TimeData.Hour and TimeData.Frozen then local CurrentTime = Sky.Hour if(TimeData.Hour > CurrentTime) then CurrentTime = CurrentTime + 24 end Time:AddTime( CurrentTime-TimeData.Hour, true ) Time.ProgressTime = not TimeData.Frozen end end) endfunction PLUGIN:LoadSavedData() TimeData = datafile.GetDataTable("m-Time") TimeData = TimeData or { } endfunction PLUGIN:SaveData() datafile.SaveDataTable("m-Time") end function PLUGIN:LoadDefaultConfig() -- General Settings: self.Config.Settings = { ChatName = "Time", } -- Plugin Messages: self.Config.Messages = { SetTime = "Current time is {time}, use /settime <time> to change the time.", SetTimeC = "Current time is {time}, use env.time <time> to change the time.", SetTimeFrozen = "Time is currently frozen!", SetTimeSucces = "You have modified the time to {time}, time will change soon!", SetTimeSyntax = "The time needs to be a number between 0 and 24!", FreezeTimeFrozen = "Time is already frozen!", FreezeTimeSucces = "Time is now frozen!", UnfreezeTime = "Time is already running!", UnfreezeTimeSucces = "Time is now running again!" } endfunction PLUGIN:cmdSetTime(player, cmd, args) if args.Length == 0 then self:SendMessage(player, self:Parse(self.Config.Messages["SetTime"], { time = math.floor(Sky.Hour) })) if not Time.ProgressTime then self:SendMessage(player, self.Config.Messages["SetTimeFrozen"]) end elseif args.Length == 1 then local targetTime = tonumber(args[0]) if not targetTime then self:SendMessage(player, self.Config.Messages["SetTimeSyntax"]) return end if targetTime >= 0 and targetTime <= 24 then self:SetTime(targetTime) self:SendMessage(player, self:Parse(self.Config.Messages["SetTimeSucces"], { time = targetTime })) else self:SendMessage(player, self.Config.Messages["SetTimeSyntax"]) end else self:SendMessage(player, self.Config.Messages["SetTimeSyntax"]) endendfunction PLUGIN:cmdFreezeTime(player, cmd, args) if Time.ProgressTime then self:FreezeTime(true) self:SendMessage(player, self.Config.Messages["FreezeTimeSucces"]) else self:SendMessage(player, self.Config.Messages["FreezeTimeFrozen"]) end endfunction PLUGIN:cmdUnfreezeTime(player, cmd, args) if not Time.ProgressTime then self:FreezeTime(false) self:SendMessage(player, self.Config.Messages["UnfreezeTimeSucces"]) else self:SendMessage(player, self.Config.Messages["UnfreezeTime"]) endendfunction PLUGIN:ccmdEnvTime(arg) local player = nil local command = arg.cmd.namefull if arg.connection then player = arg.connection.player end if command == "env.time" then if not arg.Args or arg.Args.Length == 0 then arg:ReplyWith(self:Parse(self.Config.Messages["SetTimeC"], { time = math.floor(Sky.Hour) })) elseif arg.Args[0] then local targetTime = tonumber(arg.Args[0]) if not targetTime then arg:ReplyWith(self.Config.Messages["SetTimeSyntax"]) return end if targetTime >= 0 and targetTime <= 24 then self:SetTime(targetTime) arg:ReplyWith(self:Parse(self.Config.Messages["SetTimeSucces"], { time = targetTime })) else arg:ReplyWith(self.Config.Messages["SetTimeSyntax"]) end end elseif command == "env.freeze" then if Time.ProgressTime then self:FreezeTime(true) arg:ReplyWith(self.Config.Messages["FreezeTimeSucces"]) else arg:ReplyWith(self.Config.Messages["FreezeTimeFrozen"]) end elseif command == "env.unfreeze" then if not Time.ProgressTime then self:FreezeTime(false) arg:ReplyWith(self.Config.Messages["UnfreezeTimeSucces"]) else arg:ReplyWith(self.Config.Messages["UnfreezeTime"]) end end return endfunction PLUGIN:SetTime(time) TimeData.Hour = time if(Sky.Hour > time) then time = time + 24 end Time:AddTime((time-Sky.Hour),true) self:SaveData() endfunction PLUGIN:FreezeTime(bool) Time.ProgressTime = not bool TimeData.Frozen = bool self:SaveData() endfunction PLUGIN:SendMessage(target, message) message = UnityEngine.StringExtensions.QuoteSafe(message) target:SendConsoleCommand("chat.add \"" .. self.Config.Settings.ChatName .. "\"" .. message); endfunction PLUGIN:Parse(message, values) for k, v in pairs(values) do message = string.gsub(message, "{" .. k .. "}", v) end return message end
Last edited by a moderator: Nov 27, 2014 -
Code:
11:31 AM [Error] Failed to load plugin m-Time (LuaScriptException: [string "m-Time.lua"]:185: <name> expected near '/') 11:31 AM [Debug] at NLua.Lua.ThrowExceptionFromError (Int32 oldTop) [0x00000] in <filename unknown>:0 at NLua.Lua.LoadString (System.String chunk, System.String name) [0x00000] in <filename unknown>:0 at Oxide.Lua.Plugins.LuaPlugin.Load () [0x00000] in <filename unknown>:0 at Oxide.Lua.Plugins.LuaPluginLoader.Load (System.String directory, System.String name) [0x00000] in <filename unknown>:0 at Oxide.Core.OxideMod.LoadAllPlugins () [0x00000] in <filename unknown>:0
-
there is no line 185 on my version ... so check you file.
-
ok sorry i made a mistake by inserting the Code in a LUA File.
mea culpa
Ok , know it works but if i say /settime 10 the answer ist time changed to 11 ??? /settime 22 answer is time changed to 19 ???
/freezetime says time is frozen but the time is going on !Last edited by a moderator: Nov 27, 2014 -
edited the file, it showed the current time and not the new time. it set the time right but it just didn't show you the time you set. doesn't matter
as for the time frozen, hmm
try env.freeze
that's what i tested and it works for me. -
This is Strange ?
/settime answer it is 3
/settime 10 answer you set the Time to 8
/freezetime no function
(F1Console) env.freeze no function
*Edit*
I made a Beginner Mistake.
as I have deleted the config and data files the times are ok.
but freeze is without function anywayLast edited by a moderator: Nov 27, 2014 -
well freeze should work cause it works for me :x
haven't really looked in the plugin, i just wanted to show mughisi how to fix the settime XD -
Anyway, I am grateful because I've missed this plugin.
Big THX for your work .... -
This doesn't work again since the 12/2 update
-
does it give an error?
-
Nope it even says in chat that it's going to change time like it always did, just never happens
-
and did you use the one i posted?
-
Please update for the latest version. At the command plugin does not respond.
-
[DOUBLEPOST=1417672180,1417649786][/DOUBLEPOST]