2012-01-26 17:44:37 -05:00
|
|
|
function HandleItemCommand( Split, Player )
|
|
|
|
if( #Split ~= 2 and #Split ~=3 ) then
|
2013-01-13 06:10:26 -05:00
|
|
|
Player:SendMessage( cChatColor.Green .. "Usage: /item [ItemType/Name:Dmg] <Amount>" )
|
2012-01-26 17:44:37 -05:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2012-09-08 17:41:17 -04:00
|
|
|
local Item = cItem(E_ITEM_EMPTY, 1)
|
|
|
|
local FoundItem = StringToItem( Split[2], Item )
|
2012-01-26 17:44:37 -05:00
|
|
|
|
2012-09-08 17:41:17 -04:00
|
|
|
if( IsValidItem( Item.m_ItemType ) == false ) then -- StringToItem does not check if item is valid
|
|
|
|
FoundItem = false
|
2012-01-26 17:44:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
if( FoundItem == false ) then
|
2013-01-13 06:10:26 -05:00
|
|
|
Player:SendMessage( cChatColor.Green .. "Invalid Item type / name !" )
|
2012-01-26 17:44:37 -05:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
if( #Split == 3 ) then
|
|
|
|
ItemAmount = tonumber( Split[3] )
|
|
|
|
if( ItemAmount == nil or ItemAmount < 1 or ItemAmount > 512 ) then
|
|
|
|
Player:SendMessage( cChatColor.Green .. "Invalid Amount !" )
|
|
|
|
return true
|
2012-09-08 17:41:17 -04:00
|
|
|
else
|
|
|
|
Item.m_ItemCount = ItemAmount
|
2012-01-26 17:44:37 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-09-08 17:41:17 -04:00
|
|
|
if( Player:GetInventory():AddItem( Item ) == true ) then
|
2012-01-26 17:44:37 -05:00
|
|
|
Player:SendMessage( cChatColor.Green .. "There you go !" )
|
2012-09-08 17:41:17 -04:00
|
|
|
LOG("Gave " .. Player:GetName() .. " " .. Item.m_ItemCount .. " times " .. Item.m_ItemType .. ":" .. Item.m_ItemDamage)
|
2012-01-26 17:44:37 -05:00
|
|
|
else
|
|
|
|
Player:SendMessage( cChatColor.Green .. "Not enough space in inventory !" )
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|