diff options
author | madmaxoft <github@xoft.cz> | 2013-08-16 09:20:05 +0200 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2013-08-16 09:20:34 +0200 |
commit | 98d574f05ea46763fc9e762b0719ab3ef2271230 (patch) | |
tree | 65d6a2f1bc97f800839fd65c7f459bb908e459c2 /MCServer/Plugins/Core/give.lua | |
parent | Merge pull request #96 from mc-server/buildsystest (diff) | |
download | cuberite-98d574f05ea46763fc9e762b0719ab3ef2271230.tar cuberite-98d574f05ea46763fc9e762b0719ab3ef2271230.tar.gz cuberite-98d574f05ea46763fc9e762b0719ab3ef2271230.tar.bz2 cuberite-98d574f05ea46763fc9e762b0719ab3ef2271230.tar.lz cuberite-98d574f05ea46763fc9e762b0719ab3ef2271230.tar.xz cuberite-98d574f05ea46763fc9e762b0719ab3ef2271230.tar.zst cuberite-98d574f05ea46763fc9e762b0719ab3ef2271230.zip |
Diffstat (limited to '')
-rw-r--r-- | MCServer/Plugins/Core/give.lua | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/MCServer/Plugins/Core/give.lua b/MCServer/Plugins/Core/give.lua deleted file mode 100644 index 04f01614d..000000000 --- a/MCServer/Plugins/Core/give.lua +++ /dev/null @@ -1,66 +0,0 @@ -function HandleGiveCommand(Split, Player) - - -- Make sure there are a correct number of arguments. - if #Split ~= 3 and #Split ~= 4 and #Split ~= 5 then - SendMessage( Player, "Usage: /give <player> <item> [amount] [meta]" ) - return true - end - - -- Get the item from the arguments and check it's valid. - local Item = cItem() - if #Split == 5 then - local FoundItem = StringToItem( Split[3] .. ":" .. Split[5], Item ) - else - local FoundItem = StringToItem( Split[3], Item ) - end - - if not IsValidItem( Item.m_ItemType ) then -- StringToItem does not check if item is valid - FoundItem = false - end - - if not FoundItem then - SendMessageFailure( Player, "Invalid item id or name!" ) - return true - end - - -- Work out how many items the user wants. - local ItemAmount = 1 - if #Split > 3 then - ItemAmount = tonumber( Split[4] ) - if ItemAmount == nil or ItemAmount < 1 or ItemAmount > 512 then - SendMessageFailure( Player, "Invalid amount!" ) - return true - end - end - - Item.m_ItemCount = ItemAmount - - -- Get the playername from the split. - local playerName = Split[2] - - local function giveItems( newPlayer ) - local ItemsGiven = newPlayer:GetInventory():AddItem( Item ) - if ItemsGiven == ItemAmount then - SendMessageSuccess( newPlayer, "You were given " .. Item.m_ItemCount .. " of " .. Item.m_ItemType .. "." ) - if not newPlayer == Player then - SendMessageSuccess( Player, "Items given!" ) - end - LOG("Gave " .. newPlayer:GetName() .. " " .. Item.m_ItemCount .. " times " .. Item.m_ItemType .. ":" .. Item.m_ItemDamage ) - else - SendMessageFailure( Player, "Not enough space in inventory, only gave " .. ItemsGiven ) - LOG( "Player " .. Player:GetName() .. " asked for " .. Item.m_ItemCount .. " times " .. Item.m_ItemType .. ":" .. Item.m_ItemDamage ..", but only could fit " .. ItemsGiven ) - end - return true - end - - -- Finally give the items to the player. - itemStatus = cRoot:Get():FindAndDoWithPlayer( playerName, giveItems ) - - -- Check to make sure that giving items was successful. - if not itemStatus then - SendMessageFailure( Player, "There was no player that matched your query." ) - end - - return true - -end |