Okay so i want to make a plugin which will executes(every 2 mins) the command that is in the config file...
It will be my first plugin so i need so much help
With what should i start .. Timer ?
I want to make a plugin HELP
Discussion in 'Rust Development' started by PaiN, Apr 6, 2015.
-
Wulf Community Admin
-
-
Wulf Community Admin
-
I have only this
Code:Timers = {} self.Config.Interval = self.Config.Interval or 600 self:SaveConfig() end
-
Wulf Community Admin
Just experiment. You can easily add timers without them being in the config, and then go from there as you learn. -
)
-
Wulf Community Admin
-
For now i've got this
Code:PLUGIN.Title = "AutoExec" PLUGIN.Version = V(0, 0, 1) PLUGIN.Description = "Executes a command every (x) minutes." PLUGIN.Author = "Merka" PLUGIN.HasConfig = truefunction PLUGIN:Init() self:LoadDefaultConfig() command.AddChatCommand(self.Config.Settings.ChatCommand, self.Plugin, "cmdAutoCommand") command.AddConsoleCommand(self.Config.Settings.ConsoleCommand, self.Plugin, "ccmdAutoCommand") endtimer.Repeat(10, 0, function() rust.RunServerCommand(airdrop.massdrop 2) end, self.Plugin)
-
Wulf Community Admin
I'd do something more like this (without config if you don't need it yet). Keep in mind that the airdrop command has to exist too.
Code:PLUGIN.Title = "AutoExec" PLUGIN.Version = V(0, 0, 1) PLUGIN.Description = "Executes a command every (x) minutes." PLUGIN.Author = "Merka"function PLUGIN:OnServerInitialized() self:TimedCommands() endfunction PLUGIN:TimedCommands() timer.Repeat(10, 0, function() rust.RunServerCommand("airdrop.massdrop 2") end, self.Plugin) end
-
I want the config to have "Timer":"x" and "TimedCommands":"...."
here is my plugin
Code:PLUGIN.Title = "AutoExec" PLUGIN.Version = V(0, 0, 1) PLUGIN.Description = "Executes a command every (x) minutes." PLUGIN.Author = "Merka" PLUGIN.HasConfig = truefunction PLUGIN:LoadDefaultConfig() self.Config.ShowTimedCommands = self.Config.ShowTimedCommands or "true" self.Config.TimedCommands = self.Config.TimedCommands or {} self.Config.TimedCommands.TimedCommands = self.Config.TimedCommands.TimedCommands or "server.save" self:SaveConfig() endfunction PLUGIN:OnServerInitialized() self:TimedCommands() endfunction PLUGIN:TimedCommands() timer.Repeat(5, 0, function() rust.RunServerCommand("airdrop.massdrop 2") end, self.Plugin) end