local TntPlugin = {} TntPlugin.__index = TntPlugin function TntPlugin:new() local t = {} setmetatable(t, TntPlugin) local w = Lua__cPlugin:new() tolua.setpeer(w, t) w:tolua__set_instance(w) return w end function TntPlugin:Initialize() self:SetName( "Tnt" ) self:SetVersion( 1 ) local PluginManager = cRoot:Get():GetPluginManager() 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_CHAT ) self:AddCommand("/Tnt r", " Turns on/off random tnt mode.", "tnt.r") self:AddCommand("/Tnt t", " Turns on/off tnt.", "tnt.t") local World = cRoot:Get():GetWorld() return true -- Make sure you return true, otherwise the plugin is not added end function TntPlugin:OnChat( Message, Player ) local Server = cRoot:Get():GetServer() if( GetChar(Message, 0) ~= '/' ) then -- Not a command return false end local Split = StringSplit(Message, " ") if( Split[1] == "/tnt" ) then if( not Player:HasPermission("tnt.r") and not Player:HasPermission("tnt.s") ) then return false end Server = cRoot:Get():GetServer() if(Split[2] == "r") then if Tnt_r == 1 then Tnt_r = 0 Server:SendMessage("Random tnt mode off!", Player ) else Tnt_r = 1 Server:SendMessage("Random tnt mode on!", Player ) end else if(Split[2] == "t") then if Tnt_off == 1 then Tnt_off = 0 Server:SendMessage("Tnt off!", Player ) else Tnt_off = 1 Server:SendMessage("Tnt on!", Player ) end else Server:SendMessage("Unknown Command!", Player ) end end end end function TntPlugin:OnBlockPlace( PacketData, Player ) if( PacketData.m_ItemType == E_BLOCK_TNT ) then local X = PacketData.m_PosX local Y = PacketData.m_PosY local Z = PacketData.m_PosZ local World = cRoot:Get():GetWorld(); if math.random(30) == 1 then Radius = 5 + math.random(3) else Radius = 4 + math.random(3) end Material = 0 Entf = 0 if Tnt_off == 1 then for New_X = -Radius, Radius do for New_Y = -Radius, Radius do for New_Z = -Radius, Radius do Entf = New_X*New_X + New_Y*New_Y + New_Z*New_Z if Entf < Radius*Radius then if Tnt_r == 1 then Random = math.random(8) else Random = 1 end if Random == 1 or Random == 4 or Random == 6 or Random == 8 then if World:GetBlock( X + New_X, Y + New_Y, Z + New_Z ) ~= 7 and World:GetBlock( X + New_X, Y + New_Y, Z + New_Z ) ~= 49 then World:SetBlock( X + New_X, Y + New_Y, Z + New_Z, E_BLOCK_AIR, 0 ) end end end end end end end end if Tnt_off == 1 then return true else return false end end Plugin = TntPlugin:new() cRoot:Get():GetPluginManager():AddPlugin( Plugin )