Cuberite Forum
TinyMap - map size limiter - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Releases (https://forum.cuberite.org/forum-2.html)
+---- Forum: Archived Plugins (https://forum.cuberite.org/forum-18.html)
+---- Thread: TinyMap - map size limiter (/thread-45.html)



TinyMap - map size limiter - codename_B - 03-02-2011

PHP Code:
local MapPlugin = {}
MapPlugin.__index MapPlugin
local MapSize 
200

function MapPlugin:new()
   
local t = {}
   
setmetatable(tMapPlugin)
   
local w Lua__cPlugin:new()
   
tolua.setpeer(wt)
   
w:tolua__set_instance(w)
   return 
w
end

function MapPlugin:OnDisable()
    
LOGPlugin:GetName() .. " v." .. Plugin:GetVersion() .. " is shutting down..." )
end

function MapPlugin:Initialize()
    
self:SetName"TinyMap" )
    
self:SetVersion)

    
PluginManager cRoot:Get():GetPluginManager()
    
PluginManager:AddHookselfcPluginManager.E_PLUGIN_PLAYER_MOVE)
end
function MakeObsidian(XYZ)
         
local World cRoot:Get():GetWorld();
World:SetBlock(XYZE_BLOCK_OBSIDIAN0);
World:SetBlock(XY+1ZE_BLOCK_OBSIDIAN0);
World:SetBlock(XY+2ZE_BLOCK_OBSIDIAN0);
World:SetBlock(XY+3ZE_BLOCK_OBSIDIAN0);
World:SetBlock(XY+4ZE_BLOCK_OBSIDIAN0);
World:SetBlock(XY+5ZE_BLOCK_OBSIDIAN0);
end

function MapPlugin:OnPlayerMovePlayer )
Server cRoot:Get():GetServer()


  
local PlayerName Player:GetName()
  
local X math.floor(Player:GetPosX())
    
local Y math.floor(Player:GetPosY())
      
local Z math.floor(Player:GetPosZ())

if(
X>MapSizethen
MakeObsidian
(XYZ)
Player:TeleportTo(MapSize,Y,Z);
Log(X..','..Y..','..Z);
end

if(Z>MapSizethen
MakeObsidian
(XYZ)
Player:TeleportTo(X,Y,MapSize)
Log(X..','..Y..','..Z);
end

--

if(
X<-MapSizethen
MakeObsidian
(XYZ)
Player:TeleportTo(X,Y,-MapSize)
Log(X..','..Y..','..Z);
end

if(Z<-MapSizethen
MakeObsidian
(XYZ)
Player:TeleportTo(X,Y,-MapSize)
Log(X..','..Y..','..Z);
end
end

Plugin 
MapPlugin:new()
cRoot:Get():GetPluginManager():AddPluginPlugin 

If you read the code, basically it prevents players from going beyond the "limit" of the mapsize you set in the first bits of the plugin. The default "mapsize" is 200x200 which will allow you to run a ridiculous amount of players on a server with only 128mb ram due to the incredibly small footprint of MCServer and the fact that ram usage is due to chunks loaded and nothing else!Big Grin

I also added the it creates a 6 block tall single block tower of obsidian where the player tries to go beyond the barrier, which will have the eventual effect of creating an impenetrable wall around your "map" beyond which noone can travel.

Obviously you could set admin permissions to allow them to go beyond, but I'm not going to use that, I just wanted something to keep everyone in the one area quickly and easily, and this does the job just fineBig Grin

The obsidian wall in action!
[Image: 2qjyatd.png]


RE: TinyMap - map size limiter - FakeTruth - 03-02-2011

Cool.

You got some funky client mods going on too I seeTongue


RE: TinyMap - map size limiter - codename_B - 03-02-2011

Don't know what I'd do without themTongue the clientside map especially, I never get lost in minecraft nowBig Grin