From 983d87e44356c4cfc8f8908ec365006323a4dbe0 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 27 Jul 2013 16:24:03 +0100 Subject: Added correct core plugin --- MCServer/Plugins/Core/worldlimiter.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 MCServer/Plugins/Core/worldlimiter.lua (limited to 'MCServer/Plugins/Core/worldlimiter.lua') diff --git a/MCServer/Plugins/Core/worldlimiter.lua b/MCServer/Plugins/Core/worldlimiter.lua new file mode 100644 index 000000000..8bd9b5509 --- /dev/null +++ b/MCServer/Plugins/Core/worldlimiter.lua @@ -0,0 +1,21 @@ +function OnPlayerMoving( Player ) + if LimitWorld == true then + local World = Player:GetWorld() + local SpawnX = math.floor(World:GetSpawnX() / 16) + local SpawnZ = math.floor(World:GetSpawnZ() / 16) + local X = math.floor(Player:GetPosX() / 16) + local Z = math.floor(Player:GetPosZ() / 16) + if ( (SpawnX + LimitWorldWidth - 1) < X ) then + Player:TeleportToCoords(Player:GetPosX() - 1, Player:GetPosY(), Player:GetPosZ()) + end + if ( (SpawnX - LimitWorldWidth + 1) > X ) then + Player:TeleportToCoords(Player:GetPosX() + 1, Player:GetPosY(), Player:GetPosZ()) + end + if ( (SpawnZ + LimitWorldWidth - 1) < Z ) then + Player:TeleportToCoords(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() - 1) + end + if ( (SpawnZ - LimitWorldWidth + 1) > Z ) then + Player:TeleportToCoords(Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() + 1) + end + end +end \ No newline at end of file -- cgit v1.2.3