All pastes #47556 Raw Edit

Mine

public text v1 · immutable
#47556 ·published 2006-03-30 03:04 UTC
rendered paste body
		//GIVEMADD command by morrow, //giveitem id# #ofitems
        else if(command.startsWith("admin_giveitem"))
        {
			try
			{
				String targetName = command.substring(14);
				String val = command.substring(17);
				StringTokenizer st = new StringTokenizer(targetName);
				if (st.countTokens()== 2)
				{
			        L2PcInstance player = L2World.getInstance().getPlayer(targetName);
					String id = st.nextToken();
					int idval = Integer.parseInt(id);
					String num = st.nextToken();
					int numval = Integer.parseInt(num);
					System.out.println(player);
					System.out.println(idval);
					System.out.println(numval);
					giveItem(player,idval,numval);
				}
				else if (st.countTokens()== 1)
				{
			        L2PcInstance player = L2World.getInstance().getPlayer(targetName);
					String id = st.nextToken();
					int idval = Integer.parseInt(id);
					System.out.println(player);
					System.out.println(idval);
					giveItem(player,idval,1);
				}
			}
    		catch (StringIndexOutOfBoundsException e)
    		{
    		SystemMessage sm = new SystemMessage(614);
    		sm.addString("Error while creating item.");
			activeChar.sendPacket(sm);
            }
        }
		//----------------------
		return true;
	}

	public String[] getAdminCommandList()
	{
		return _adminCommands;
	}

	private boolean checkLevel(int level) 
	{
		return (level >= REQUIRED_LEVEL);
	}
    
    /**
     * 
     * @param type - atmosphere type (signssky,sky)
     * @param state - atmosphere state(night,day)
     */
	//---------for //giveitem
	private void giveItem(L2PcInstance player, int id, int num)
	{
        player.getInventory().addItem("Admin", id, num, player, null);
		
        ItemList il = new ItemList(player, true);
        player.sendPacket(il);
		
		SystemMessage sm = new SystemMessage(614);
		sm.addString("An Admin has spawned " + num + " item(s) number " + id + " in your inventory.");
		player.sendPacket(sm);
	}
	//-------------