Fixed The MagicCarpet plugin
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1590 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
def8f859ba
commit
92fc62fb4b
@ -1,83 +1,83 @@
|
|||||||
local PLUGIN = {}
|
local PLUGIN = {}
|
||||||
local Carpets = {}
|
local Carpets = {}
|
||||||
|
|
||||||
function Initialize( Plugin )
|
function Initialize( Plugin )
|
||||||
PLUGIN = Plugin
|
PLUGIN = Plugin
|
||||||
|
|
||||||
Plugin:SetName( "MagicCarpet" )
|
Plugin:SetName( "MagicCarpet" )
|
||||||
Plugin:SetVersion( 1 )
|
Plugin:SetVersion( 1 )
|
||||||
|
|
||||||
PluginManager = cRoot:Get():GetPluginManager()
|
PluginManager = cRoot:Get():GetPluginManager()
|
||||||
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING)
|
PluginManager:AddHook(Plugin, cPluginManager.HOOK_PLAYER_MOVING)
|
||||||
PluginManager:AddHook(Plugin, cPluginManager.HOOK_DISCONNECT)
|
PluginManager:AddHook(Plugin, cPluginManager.HOOK_DISCONNECT)
|
||||||
|
|
||||||
PluginManager:BindCommand("/mc", "magiccarpet", HandleCarpetCommand, " - Spawns a magical carpet");
|
PluginManager:BindCommand("/mc", "magiccarpet", HandleCarpetCommand, " - Spawns a magical carpet");
|
||||||
|
|
||||||
Log( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
|
LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function OnDisable()
|
function OnDisable()
|
||||||
Log( PLUGIN:GetName() .. " v." .. PLUGIN:GetVersion() .. " is shutting down..." )
|
LOG( PLUGIN:GetName() .. " v." .. PLUGIN:GetVersion() .. " is shutting down..." )
|
||||||
for i, Carpet in pairs( Carpets ) do
|
for i, Carpet in pairs( Carpets ) do
|
||||||
Carpet:remove()
|
Carpet:remove()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function HandleCarpetCommand( Split, Player )
|
function HandleCarpetCommand( Split, Player )
|
||||||
Carpet = Carpets[ Player ]
|
Carpet = Carpets[ Player ]
|
||||||
if( Carpet == nil ) then
|
if( Carpet == nil ) then
|
||||||
Carpets[ Player ] = cCarpet:new()
|
Carpets[ Player ] = cCarpet:new()
|
||||||
Player:SendMessage("You're on a magic carpet!" )
|
Player:SendMessage("You're on a magic carpet!" )
|
||||||
else
|
else
|
||||||
Carpet:remove()
|
Carpet:remove()
|
||||||
Carpets[ Player ] = nil
|
Carpets[ Player ] = nil
|
||||||
Player:SendMessage("The carpet vanished!" )
|
Player:SendMessage("The carpet vanished!" )
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function OnDisconnect( Reason, Player )
|
function OnDisconnect( Reason, Player )
|
||||||
local Carpet = Carpets[ Player ]
|
local Carpet = Carpets[ Player ]
|
||||||
if( Carpet ~= nil ) then
|
if( Carpet ~= nil ) then
|
||||||
Carpet:remove()
|
Carpet:remove()
|
||||||
end
|
end
|
||||||
Carpets[ Player ] = nil
|
Carpets[ Player ] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function OnPlayerMoving(Player)
|
function OnPlayerMoving(Player)
|
||||||
local Carpet = Carpets[ Player ]
|
local Carpet = Carpets[ Player ]
|
||||||
if( Carpet == nil ) then
|
if( Carpet == nil ) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if( Player:GetPitch() == 90 ) then
|
if( Player:GetPitch() == 90 ) then
|
||||||
Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY() - 1, Player:GetPosZ() ) )
|
Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY() - 1, Player:GetPosZ() ) )
|
||||||
else
|
else
|
||||||
if( Player:GetPosY() < Carpet:getY() ) then
|
if( Player:GetPosY() < Carpet:getY() ) then
|
||||||
LOGINFO("Fell tru mc!")
|
LOGINFO("Fell tru mc!")
|
||||||
Player:TeleportTo( Player:GetPosX(), Carpet:getY(), Player:GetPosZ() )
|
Player:TeleportTo( Player:GetPosX(), Carpet:getY(), Player:GetPosZ() )
|
||||||
end
|
end
|
||||||
Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) )
|
Carpet:moveTo( cLocation:new( Player:GetPosX(), Player:GetPosY(), Player:GetPosZ() ) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user