Core
#10
Core needs a /give command.

Code:
function HandleGiveCommand( Split, Player )
  if  #Split < 3 then
        Player:SendMessage( cChatColor.Green .. "Usage: /give [PlayerName] [ItemID/Name] <Amount>" )
        return true
    end
  
  local World = cRoot:Get():GetWorld()
    local GivePlayer = World:GetPlayer( Split[2] )
    
  if GivePlayer == nil then
        Player:SendMessage( cChatColor.Green .. "Player " ..Split[2].. " not found." )
        return true
  end
  
  ItemID = Split[3]
  ItemMeta = 0
  sPos = string.find(Split[3], ":")
  if (sPos ~= nil) then
    ItemID = tonumber(string.sub(Split[3], 1, sPos-1))
    ItemMeta = tonumber(string.sub(Split[3], sPos+1))
  else
      ItemID = tonumber(Split[3])
  end
  if( ItemID == nil or not isValidItem( ItemID ) ) then
      Player:SendMessage( cChatColor.Green .. "Item " ..Split[3].. " not found." )
      return true
    end
    
    ItemAmount = 1
    if( #Split >= 4 ) then
        ItemAmount = tonumber(Split[4])
        if( ItemAmount == nil or ItemAmount < 1 or ItemAmount > 512 ) then
            Player:SendMessage( cChatColor.Red .. "Invalid Amount !" )
            return true
        end
    end

    local NewItem = cItem( ItemID, ItemAmount , ItemMeta)
    if( GivePlayer:GetInventory():AddItem(NewItem) == true ) then
        Player:SendMessage( cChatColor.Green .. "Gave item ("..ItemID..":"..ItemMeta..") to "..Split[2].."." )
        LOG("Gave " .. GivePlayer:GetName() .. " " .. ItemAmount .. " times " .. ItemID )
    else
        Player:SendMessage( cChatColor.Red .. "Not enough space in inventory !" )
    end
  return true  
end
Reply
Thanks given by:


Messages In This Thread
Core - by FakeTruth - 02-21-2011, 07:49 AM
RE: Core V1 - Requires r173 - by Tybor - 02-22-2011, 03:02 AM
RE: Core V1 - Requires r173 - by suicidal_banana - 02-22-2011, 03:44 AM
RE: Core V1 - Requires r173 - by FakeTruth - 02-22-2011, 06:13 AM
RE: Core V1 - Requires r173 - by distroyed123 - 04-24-2011, 01:41 AM
RE: Core V3 - Requires r176 - by FakeTruth - 04-23-2011, 12:30 AM
RE: [Plugin] Core V6 - by FakeTruth - 05-25-2011, 02:16 AM
RE: [Plugin] Core V6 - by wenisinchina - 07-01-2011, 06:58 PM
RE: [Plugin] Core V6 - by rekatluos - 07-02-2011, 12:03 AM
RE: [Plugin] Core V6 - by Luthrandel - 11-07-2011, 11:10 AM
RE: [Plugin] Core V7 - by FakeTruth - 01-26-2012, 01:40 AM
RE: [Plugin] Core V7 - by RealVaVa - 02-13-2012, 09:12 PM
RE: [Plugin] Core V7 - by NiLSPACE - 06-03-2012, 06:39 PM
RE: [Plugin] Core V7 - by NiLSPACE - 07-13-2012, 08:10 PM
RE: [Plugin] Core V7 - by Lapayo - 07-14-2012, 03:23 AM
RE: [Plugin] Core V7 - by NiLSPACE - 07-14-2012, 03:25 AM
RE: [Plugin] Core V7 - by NiLSPACE - 09-03-2012, 06:01 AM
RE: [Plugin] Core V7 - by FakeTruth - 09-09-2012, 06:22 AM
RE: [Plugin] Core V7 - by NiLSPACE - 09-09-2012, 03:34 AM
RE: [Plugin] Core V7 - by NiLSPACE - 09-09-2012, 06:49 AM
RE: [Plugin] Core V7 - by FakeTruth - 09-09-2012, 07:33 AM
RE: [Plugin] Core V7 - by NiLSPACE - 09-09-2012, 08:05 AM
RE: [Plugin] Core V7 - by NiLSPACE - 09-09-2012, 05:58 PM
RE: [Plugin] Core V7 - by FakeTruth - 09-09-2012, 08:12 PM
RE: [Plugin] Core V7 - by FakeTruth - 09-09-2012, 10:37 PM
RE: [Plugin] Core V7 - by NiLSPACE - 09-09-2012, 11:09 PM
RE: [Plugin] Core V7 - by FakeTruth - 09-09-2012, 11:34 PM
RE: [Plugin] Core V7 - by NiLSPACE - 09-09-2012, 11:36 PM
RE: [Plugin] Core V7 - by l0udPL - 09-10-2012, 02:26 AM
RE: [Plugin] Core V7 - by NiLSPACE - 09-10-2012, 03:38 AM
RE: [Plugin] Core V7 - by NiLSPACE - 11-11-2012, 07:15 PM
RE: [Plugin] Core V7 - by NiLSPACE - 11-12-2012, 03:26 AM
RE: [Plugin] Core V7 - by NiLSPACE - 11-23-2012, 02:37 AM
RE: [Plugin] Core V7 - by NiLSPACE - 01-13-2013, 12:55 AM
RE: [Plugin] Core V7 - by bearbin - 01-13-2013, 03:41 AM
RE: [Plugin] Core V7 - by xoft - 01-13-2013, 03:47 AM
RE: [Plugin] Core V7 - by NiLSPACE - 01-13-2013, 03:51 AM
RE: [Plugin] Core V7 - by FakeTruth - 01-13-2013, 06:20 AM
RE: [Plugin] Core V7 - by NiLSPACE - 01-13-2013, 06:47 AM
RE: [Plugin] Core V7 - by bearbin - 01-13-2013, 06:47 AM
RE: [Plugin] Core V7 - by xoft - 01-13-2013, 09:11 PM
RE: [Plugin] Core V7 - by bearbin - 01-13-2013, 10:01 PM
RE: [Plugin] Core V7 - by NiLSPACE - 02-17-2013, 08:35 AM
RE: [Plugin] Core V7 - by NiLSPACE - 03-02-2013, 09:23 PM
RE: [Plugin] Core V7 - by xoft - 03-03-2013, 12:43 AM
RE: [Plugin] Core V7 - by NiLSPACE - 03-03-2013, 02:21 AM
RE: [Plugin] Core V7 - by xoft - 03-03-2013, 02:23 AM
RE: [Plugin] Core V7 - by NiLSPACE - 09-01-2013, 06:41 PM
RE: [Plugin] Core V7 - by bearbin - 09-01-2013, 07:49 PM
RE: [Plugin] Core V7 - by xoft - 09-01-2013, 08:14 PM
RE: [Plugin] Core V7 - by tigerw - 09-01-2013, 09:09 PM
RE: [Plugin] Core V7 - by FakeTruth - 09-01-2013, 10:56 PM
RE: [Plugin] Core V7 - by bearbin - 09-02-2013, 12:15 AM
RE: [Plugin] Core V7 - by xoft - 09-02-2013, 12:15 AM
RE: [Plugin] Core V7 - by FakeTruth - 09-02-2013, 12:53 AM
RE: [Plugin] Core V7 - by NiLSPACE - 10-23-2013, 10:42 PM
RE: [Plugin] Core V7 - by FakeTruth - 10-23-2013, 10:50 PM
RE: [Plugin] Core V7 - by xoft - 10-24-2013, 12:04 AM
RE: [Plugin] Core V7 - by NiLSPACE - 10-24-2013, 12:08 AM
RE: [Plugin] Core V7 - by NiLSPACE - 10-24-2013, 06:51 AM
RE: [Plugin] Core V7 - by xoft - 10-24-2013, 06:43 PM
RE: [Plugin] Core V7 - by NiLSPACE - 10-24-2013, 06:59 PM
RE: [Plugin] Core V7 - by xoft - 10-24-2013, 08:13 PM
RE: [Plugin] Core V7 - by FakeTruth - 10-24-2013, 07:25 PM
RE: [Plugin] Core V7 - by NiLSPACE - 10-24-2013, 08:33 PM
RE: [Plugin] Core V7 - by FakeTruth - 10-24-2013, 08:44 PM
RE: [Plugin] Core V7 - by NiLSPACE - 10-24-2013, 08:51 PM
RE: [Plugin] Core V7 - by xoft - 10-24-2013, 10:37 PM
RE: [Plugin] Core V7 - by NiLSPACE - 10-24-2013, 10:44 PM
RE: [Plugin] Core V7 - by xoft - 10-25-2013, 12:09 AM
RE: [Plugin] Core V7 - by NiLSPACE - 10-25-2013, 01:02 AM
RE: [Plugin] Core V7 - by FakeTruth - 10-25-2013, 01:10 AM
RE: [Plugin] Core V7 - by xoft - 10-25-2013, 01:25 AM
RE: [Plugin] Core V7 - by NiLSPACE - 10-25-2013, 02:55 AM
RE: [Plugin] Core V7 - by xoft - 10-25-2013, 07:08 AM
RE: [Plugin] Core V7 - by NiLSPACE - 10-25-2013, 07:22 AM
RE: [Plugin] Core V7 - by xoft - 10-25-2013, 07:47 AM
RE: [Plugin] Core V7 - by FakeTruth - 10-25-2013, 07:57 AM
RE: [Plugin] Core V7 - by xoft - 10-25-2013, 07:59 AM
RE: [Plugin] Core V7 - by NiLSPACE - 10-25-2013, 06:29 PM
RE: [Plugin] Core V7 - by FakeTruth - 10-25-2013, 06:34 PM
RE: [Plugin] Core V7 - by tigerw - 11-09-2013, 08:00 AM
RE: [Plugin] Core V7 - by NiLSPACE - 12-12-2014, 12:07 AM
RE: [Plugin] Core V7 - by xoft - 12-12-2014, 12:35 AM
RE: [Plugin] Core V7 - by NiLSPACE - 12-12-2014, 12:46 AM
RE: [Plugin] Core V7 - by xoft - 12-12-2014, 02:25 AM
RE: [Plugin] Core V7 - by NiLSPACE - 10-08-2015, 10:57 PM
RE: [Plugin] Core V7 - by Mathias - 10-17-2015, 11:16 PM
RE: [Plugin] Core V7 - by LogicParrot - 12-24-2015, 05:35 AM



Users browsing this thread: 22 Guest(s)