1
0

Core: Updated with new features (contributed by STR_Warrior)

http://forum.mc-server.org/showthread.php?tid=4&pid=6634#pid6634

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1235 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-03-02 14:43:46 +00:00
parent e4a0c284c1
commit 476cd25ade
8 changed files with 56 additions and 11 deletions

View File

@ -0,0 +1,9 @@
function HandleBackCommand( Split, Player )
if (X[Player:GetName()] == nil) or (Y[Player:GetName()] == nil) or (Z[Player:GetName()] == nil) then
Player:SendMessage(cChatColor.Green .. "There is no last position known")
else
Player:TeleportTo(X[Player:GetName()], Y[Player:GetName()], Z[Player:GetName()])
Player:SendMessage(cChatColor.Green .. "You teleported back to your last known position")
end
return true
end

View File

@ -7,6 +7,9 @@ SHOW_PLUGIN_NAMES = true -- If true, plugin name will be shown before commands
PLUGIN = {} -- Reference to own plugin object
BannedPlayersIni = {}
WhiteListIni = {}
X = {}
Y = {}
Z = {}
@ -27,6 +30,8 @@ function Initialize(Plugin)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CRAFTING_NO_RECIPE)
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHAT) -- used in web_chat.lua
PluginManager:BindCommand("/back", "core.back", HandleBackCommand, " - Return to your last position");
PluginManager:BindCommand("/save-all", "core.save-all", HandleSaveAllCommand, " - Saves all your worlds");
PluginManager:BindCommand("/help", "core.help", HandleHelpCommand, " [Page] - Show available commands");
PluginManager:BindCommand("/pluginlist", "core.pluginlist", HandlePluginListCommand, " - Show list of plugins");
PluginManager:BindCommand("/tp", "core.teleport", HandleTPCommand, " [Player] - Teleport yourself to a player");

View File

@ -1,4 +1,5 @@
function OnPlayerJoined(Player)
ShowMOTDTo( Player )
AddMessage( Player:GetName() .. " has joined the game", " " )
return false
end

View File

@ -0,0 +1,5 @@
function HandleSaveAllCommand( Split, Player )
cRoot:Get():SaveAllChunks();
Player:SendMessage(cChatColor.Green .. "All the worlds are saved")
return true;
end

View File

@ -1,5 +1,8 @@
function HandleSpawnCommand( Split, Player )
World = Player:GetWorld()
X[Player:GetName()] = Player:GetPosX()
Y[Player:GetName()] = Player:GetPosY()
Z[Player:GetName()] = Player:GetPosZ()
Player:TeleportTo( World:GetSpawnX(), World:GetSpawnY(), World:GetSpawnZ() )
LOGINFO( Player:GetName() .. " returned to spawn." )
return true

View File

@ -1,23 +1,26 @@
function HandleTPCommand( Split, Player )
if( #Split ~= 2 ) then
Player:SendMessage( cChatColor.Green .. "Usage: /tp [PlayerName]" )
if( Split[2] == nil ) then
Player:SendMessage( cChatColor.Green .. "Usage: /tp [PlayerName] (-h)" )
return true
end
World = Player:GetWorld()
local TeleportDestination = function(OtherPlayer)
if( OtherPlayer == Player ) then
Player:SendMessage( cChatColor.Green .. "Already there :)" )
else
X[Player:GetName()] = Player:GetPosX()
Y[Player:GetName()] = Player:GetPosY()
Z[Player:GetName()] = Player:GetPosZ()
Player:TeleportToEntity( OtherPlayer )
Player:SendMessage( cChatColor.Green .. "You teleported to "..OtherPlayer:GetName().."!" )
OtherPlayer:SendMessage( cChatColor.Green .. Player:GetName().." teleported to you!" )
if Split[3] ~= "-h" then
OtherPlayer:SendMessage( cChatColor.Green .. Player:GetName().." teleported to you!" )
end
end
end
if (not(World:DoWithPlayer(Split[2], TeleportDestination))) then
end
World = Player:GetWorld()
if (not(World:DoWithPlayer(Split[2], TeleportDestination))) then
Player:SendMessage( cChatColor.Green .. "Can't find player " .. Split[2] )
end
end
return true
end
end

View File

@ -3,7 +3,9 @@ function HandleTopCommand( Split, Player )
local PlayerPos = Player:GetPosition()
local Height = World:GetHeight( math.floor(PlayerPos.x), math.floor(PlayerPos.z) )
X[Player:GetName()] = Player:GetPosX()
Y[Player:GetName()] = Player:GetPosY()
Z[Player:GetName()] = Player:GetPosZ()
Player:TeleportTo( PlayerPos.x, Height+1, PlayerPos.z )
Player:SendMessage("Teleported to the top block")

View File

@ -125,6 +125,23 @@ function HandleRequest_Chat( Request )
end
if( Request.PostParams["ChatMessage"] ~= nil ) then
if( Request.PostParams["ChatMessage"] == "/help" ) then
Commands = "Available commands"
AddMessage(Commands, "<br>" .. "/help, /reload" )
return Commands
elseif( Request.PostParams["ChatMessage"] == "/reload" ) then
Server = cRoot:Get():GetServer()
Server:SendMessage( cChatColor.Green .. "Reloading all plugins." )
AddMessage("Reloading all plugins", "")
cRoot:Get():GetPluginManager():ReloadPlugins()
return ""
else
cmd = Request.PostParams["ChatMessage"]
if string.sub(cmd,1,string.len("/")) == "/" then
AddMessage('Unknown Command "' .. Request.PostParams["ChatMessage"] .. '"', "")
return ""
end
end
local Message = "[WebAdmin]: " .. Request.PostParams["ChatMessage"]
cRoot:Get():GetServer():SendMessage( Message )
AddMessage("WebAdmin", Request.PostParams["ChatMessage"] )