--Weather-- --Author: STR_Warrior local Weather = {} Weather.__index = Weather warps = {} function Weather:new() local t = {} setmetatable(t, Weather) local w = Lua__cPlugin:new() tolua.setpeer(w, t) w:tolua__set_instance(w) return w end function Weather:Initialize() self:SetName( "Weather" ) self:SetVersion( 1 ) PluginManager = cRoot:Get():GetPluginManager() PluginManager:AddHook( self, cPluginManager.E_PLUGIN_PLAYER_MOVE) PluginManager:AddHook( self, cPluginManager.E_PLUGIN_PLAYER_JOIN ) PluginManager:AddHook( self, cPluginManager.E_PLUGIN_CHAT ) PluginManager:AddHook( self, cPluginManager.E_PLUGIN_TICK ) PluginManager:AddHook( self, cPluginManager.E_PLUGIN_BLOCK_DIG ) PluginManager:AddHook( self, cPluginManager.E_PLUGIN_BLOCK_PLACE ) PluginManager:AddHook( self, cPluginManager.E_PLUGIN_LOGIN ) self:AddCommand("/rain", " set weather to rain.", "Weather.rain") self:AddCommand("/sun", " set weather to sun.", "Weather.sun") self:BindCommand("/rain", "rain.weather", HandleRain) self:BindCommand("/sun", "Sun.weather", HandleSun) self:BindCommand("/weather", "weather.Weather", HandleWeather) end function HandleSun( Split, Player ) local World = cRoot:Get():GetDefaultWorld() local Server = cRoot:Get():GetServer() World:SetWeather( 0 ) Server:SendMessage( cChatColor.Green .. "Weather set to Sun!" ) return true end function HandleRain( Split, Player ) local World = cRoot:Get():GetDefaultWorld() local Server = cRoot:Get():GetServer() World:SetWeather( 1 ) Server:SendMessage( cChatColor.Green .. "Weather set to Rain!" ) return true end function HandleWeather( Split, Player ) local World = cRoot:Get():GetDefaultWorld() local Server = cRoot:Get():GetServer() if( string.upper( Split[2] ) == "DAY" ) then World:SetWeather( 0 ) Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the weather to day.") elseif( string.upper( Split[2] ) == "SUN" ) then World:SetWeather( 0 ) Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the weather to day.") elseif( string.upper( Split[2] ) == "RAIN") then World:SetWeather( 1 ) Server:SendMessage( cChatColor.Green .. Player:GetName() .. " set the weather to rain") end return true end Plugin = Weather:new() cRoot:Get():GetPluginManager():AddPlugin( Plugin )