From eb942797b8a1321f7460cea7763bb6891affd475 Mon Sep 17 00:00:00 2001 From: faketruth Date: Mon, 26 Dec 2011 21:54:08 +0000 Subject: Players can switch worlds on the fly with the command /gotoworld [worldName]. This uses the function cPlayer::MoveToWorld() Changed isValidItem to IsValidItem in Core.lua git-svn-id: http://mc-server.googlecode.com/svn/trunk@126 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- Plugins/Core.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'Plugins') diff --git a/Plugins/Core.lua b/Plugins/Core.lua index 5090dcf95..517b48394 100644 --- a/Plugins/Core.lua +++ b/Plugins/Core.lua @@ -46,6 +46,7 @@ function CorePlugin:Initialize() self:AddCommand("/unban", " - [Player] - Unban a player", "core.unban") self:AddCommand("/top", " - Teleport yourself to the top most block", "core.top") self:AddCommand("/gm", " - [Gamemode (0|1)] - Change your gamemode", "core.changegm") + self:AddCommand("/gotoworld", " - Move to a different world!", "core.gotoworld") self:BindCommand( "/help", "core.help", HandleHelpCommand ) self:BindCommand( "/pluginlist","core.pluginlist", HandlePluginListCommand ) @@ -65,6 +66,7 @@ function CorePlugin:Initialize() self:BindCommand( "/unban", "core.unban", HandleUnbanCommand ) self:BindCommand( "/top", "core.top", HandleTopCommand ) self:BindCommand( "/gm", "core.changegm", HandleChangeGMCommand ) + self:BindCommand( "/gotoworld", "core.gotoworld", HandleGotoWorldCommand ) local IniFile = cIniFile("settings.ini") if ( IniFile:ReadFile() == true ) then @@ -347,7 +349,7 @@ function HandleItemCommand( Split, Player ) foundItem = false ItemID = tonumber( Split[2] ) - if( ItemID == nil or not isValidItem( ItemID ) ) then + if( ItemID == nil or not IsValidItem( ItemID ) ) then -- nothing else foundItem = true @@ -358,7 +360,7 @@ function HandleItemCommand( Split, Player ) itemValue = itemsINI:GetValueI('Items', ''..Split[2]..'', 0) if itemValue ~= 0 then ItemID = itemValue - if( ItemID == nil or not isValidItem( tonumber(itemValue) ) ) then + if( ItemID == nil or not IsValidItem( tonumber(itemValue) ) ) then -- nothing else foundItem = true @@ -420,6 +422,21 @@ function HandleChangeGMCommand( Split, Player ) return true end +function HandleGotoWorldCommand( Split, Player ) + if( #Split ~= 2 ) then + Player:SendMessage( cChatColor.Green .. "Usage: /gotoworld [WorldName]" ) + return true + end + + if( Player:MoveToWorld(Split[2]) == false ) then + Player:SendMessage( cChatColor.Green .. "Could not move to world '" .. Split[2] .. "'!" ) + return true + end + + + Player:SendMessage( cChatColor.Green .. "Moved successfully to '" .. Split[2] .. "'! :D" ) + return true +end function CorePlugin:OnPlayerJoin( Player ) ShowMOTDTo( Player ) -- cgit v1.2.3