TinyMap - map size limiter
#1
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]
Reply
Thanks given by:
#2
Cool.

You got some funky client mods going on too I seeTongue
Reply
Thanks given by:
#3
Don't know what I'd do without themTongue the clientside map especially, I never get lost in minecraft nowBig Grin
Reply
Thanks given by:




Users browsing this thread: 3 Guest(s)