Thread: Item command

Results 1 to 7 of 7
  1. #1 Item command 
    Banned

    Join Date
    Jun 2015
    Posts
    1,517
    Thanks given
    31
    Thanks received
    143
    Rep Power
    0
    Hello guys i need item command, but i need to disable some items, so players cant spawn it, like 11694, Any1 could help me?
    Reply With Quote  
     

  2. #2  
    ¯\_(ツ)_/¯


    Join Date
    Jul 2014
    Posts
    1,803
    Thanks given
    928
    Thanks received
    550
    Rep Power
    299
    You already made a thread, i posted on it. You dont need to make 2 threads for no reason.
    I suggest you learn to program before hosting a server. Nobody will spoonfeed you everything
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Jun 2015
    Posts
    1,517
    Thanks given
    31
    Thanks received
    143
    Rep Power
    0
    Quote Originally Posted by Hitten View Post
    You already made a thread, i posted on it. You dont need to make 2 threads for no reason.
    I suggest you learn to program before hosting a server. Nobody will spoonfeed you everything
    I was doing that in adving , so im trying to do that in help.

    Quote Originally Posted by Hitten View Post
    You already made a thread, i posted on it. You dont need to make 2 threads for no reason.
    I suggest you learn to program before hosting a server. Nobody will spoonfeed you everything
    and btw yours isnt working lmao.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Oct 2015
    Posts
    136
    Thanks given
    3
    Thanks received
    7
    Rep Power
    11
    James, just add an if statement that checks for certain item id's?
    Not that hard to be honest.
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Oct 2015
    Posts
    119
    Thanks given
    16
    Thanks received
    5
    Rep Power
    10
    James you can't code so just stop lmfao
    Reply With Quote  
     

  6. #6  
    Registered Member ohemtjee's Avatar
    Join Date
    Dec 2015
    Posts
    12
    Thanks given
    0
    Thanks received
    3
    Rep Power
    11
    Code:
    if (cmd[0].equals("giveitem")) {
    			name = "";
    			int itemId = Integer.parseInt(cmd[1]);
    			int amount = Integer.parseInt(cmd[2]);
    			for (int i = 3; i < cmd.length; i++) {
    				name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
    			}
    			
    			target = World.findPlayer(name);
    			
    			if (target == null || !World.isOnline(name)) {
    				player.sendMessage("The player '"+name+"' can't be found.");
    				return true;
    			}
    
    			if (itemId== 11694) {
    				player.sendMessage("This item can not be spawned.");
    				return true;
    			}
    			
    			Item item = new Item(itemId, amount);
    			target.getInventory().addItem(itemId, amount);
    			SerializableFilesManager.savePlayer(target);
    			target.getPackets().sendGameMessage("" + player.getDisplayName() + " has given you an item!");
    			player.sendMessage("You have given "+item.getName()+" (Amount: "+amount+") to "+target.getDisplayName()+".");
    			return true;
    		}
    This code can give an item to a player.
    Try to understand it and try to modify it to fit your needs
    Reply With Quote  
     

  7. #7  
    现场大

    tiller's Avatar
    Join Date
    Dec 2015
    Posts
    757
    Thanks given
    335
    Thanks received
    164
    Rep Power
    303
    Here you go lil homie

    Code:
     if (playerCommand.startsWith("item")) {
                            if (c.inWild()) {
                            c.sendMessage("you can't spawn items in the wilderness!");
                            return;
                            }
                                    try {
                                    String[] args = playerCommand.split(" ");
                                    if (args.length == 3) {
                                    int newItemID = Integer.parseInt(args[1]);
                                    int newItemAmount = Integer.parseInt(args[2]);
                                                    // add restricted items here.
                                                    int restrictedItems[] = {2438, 2439, 18202, 18203, 18204, 18205, 18206, 18207, 18208, 18209, 18210, 18211, 18212, 18213, 18214, 18215, 18216, 18217, 18218, 18219, 18220, 18221, 18222, 18223, 
    18224, 18225, 18226, 18227, 18228, 18229, 18230, 18231, 18232, 18233, 18234, 18235, 18236, 18237, 18238, 18239, 18240, 18241, 18242, 18243, 18244, 18245, 18246, 18247, 18248, 18249, 18250, 18251, 18252, 18253, 18254, 18255, 
    18256, 18257, 18258, 18259, 18260, 18261, 18262, 18263, 18264, 18265, 18266, 18267, 18268, 18269, 18270, 18271, 18272, 18273, 18274, 18275, 18276, 18277, 18278, 18279, 18280, 18281, 18282, 18283, 18284, 18285, 18286, 18287, 
    18288, 18289, 18290, 18291, 18292, 18293, 18294, 18295, 18296, 18297, 18298, 18299, 18300, 18301, 18302, 18303, 18304, 18305, 18306, 18307, 18308, 18309, 18310, 18311, 18312, 18313, 18314, 18315, 18316, 18317, 18318, 18319, 18320, 18321, 18322, 18323, 18324, 18325, 18326, 18327, 18328, 18329, 
    151, 152, 153, 154, 155, 156, 13746, 13747, 13748, 13749, 13750, 13751, 13752, 13753, 16033, 16044, 11694, 13363, 13362, 15328, 15329, 15330, 15331, 15332, 15333, 15334, 15335, 13845, 13846, 13847, 13848, 13849, 13850, 13851,
    13359, 13358, 15512, 15511, 13361, 13360, 15510, 15509, 15504, 15503, 15506, 15505, 15508, 15507, 14606, 14605, 16712, 
    16711, 18336, 18335, 17260, 17259, 16668, 16667, 16956, 16955, 16710, 16709, 17258, 17257, 16666, 16665, 16708, 16707, 
    17256, 17255, 16664, 16663, 17362, 17361, 17360, 17359, 17358, 17357, 16756, 16755, 16866, 16865, 17238, 17237, 17062, 
    17061, 996, 995, 17194, 17193, 17340, 17339, 16956, 16955, 16954, 16953, 16952, 16951, 16404, 16403, 16402, 16401, 16400, 
    16399, 16910, 16909, 16908, 16907, 16906, 16905, 18350, 18349, 18354, 18353, 18358, 18357, 18356, 18355, 18352, 18351, 
    13356, 13355, 13351, 13350, 13349, 13348, 13347, 13346, 13353, 13352, 13355, 13354, 19670, 19669, 18360, 18359, 18362, 
    18361, 18364, 18363, 4448, 4447, 13852, 13853, 13854, 13855, 13856, 13857, 13858, 13859, 13860, 13861, 13862, 13863, 
    13864, 13865, 13866, 13867, 13868, 13869, 13870, 13871, 13872, 13873, 13874, 13875, 13876, 13877, 13878, 13879, 13880, 
    13881, 13882, 13883, 13884, 13885, 13886, 13887, 13888, 13889, 13890, 13891, 13892, 13893, 13894, 13895, 13896, 13897, 
    13898, 13899, 13900, 13901, 13902, 13903, 13904, 13905, 13906, 13907, 13908, 13909, 13910, 13911, 13912, 13913, 13914, 
    13915, 13916, 13917, 13918, 13919, 
    13920, 13921, 13922, 13923, 13924, 13925, 13926, 13927, 13928, 13929, 13930, 13931, 13932, 13933, 13934, 13935, 13936, 
    13937, 13938, 13939, 13940, 13941, 13942, 13943, 13944, 13945, 13946, 13947, 13948, 13949, 13950, 13951, 13952, 13953, 
    13954, 13955, 13956, 13957, 1038, 1037, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 
    1053, 1054, 1055, 1056, 1057, 1058, 2422, 13531, 13532, 13533, 13534, 13535, 13536, 13537, 13538, 13539, 13540, 
    20072, 19784, 19785, 19786, 19787, 19788, 19789, 19790, 19780, 18786, 15300, 15301, 15302, 15303, 
    15773,  15774,  15818, 15888, 15890, 15891, 15924, 15935, 15946, 16001, 16023, 
    16034, 16045, 16090, 16126, 16137, 16152, 16184, 16206, 16217, 16258, 16259, 
    16260, 16261, 16272, 16293, 16294, 16315, 16316, 16359, 16360, 16381, 16382, 
    16403, 16404, 16425, 16426, 16667, 16668, 16689, 16690, 16711, 16712, 16733, 
    16734, 16837, 16838, 16839, 16840, 16841, 16842, 16843, 16844, 16909, 16910, 
    16955, 16956, 17039, 17040, 17143, 17144, 17145, 17146, 17147, 17148, 17149, 
    17150, 17259, 17260, 17361, 17362, 20822, 20823, 20824, 20825, 20826, 20833, 
    13734, 13735, 13737, 13738, 13739, 13740, 13741, 13742, 13743, 13744, 
    13745, 4716, 4717, 4718, 4719, 4720, 4721, 4722, 4723, 4753, 4754, 4755, 4756, 
    4757, 4758, 4759, 4760, 4732, 4733, 4734, 4735, 4736, 4737, 4738, 4739, 4708, 
    4709, 4710, 4711, 4712, 4713, 4714, 4715, 14484, 14485, 14486, 11695, 13450, 
    18349, 18350, 18351, 18352, 18353, 18354, 18355, 18356, 18357, 18358, 18359, 
    18360, 11702, 11703, 11704, 11705, 11706, 11707, 11708, 11709, 15486, 15487, 
    15502, 14642, 14645, 14642, 14645, 15433, 15435, 15474, 14641, 15432, 15434, 2570, 2571, 
    4856, 4857, 4858, 4859, 4860, 4861, 4862, 4863, 4864, 4865, 4866,  4867, 4868,  4869, 4870, 4871, 4872, 4873, 4874, 4875, 4876, 4877, 4878, 4879, 4880, 4881, 4882, 4883, 4884, 4885, 4886, 4887, 4888, 4889, 4890, 4891, 4892, 4893, 4894, 4895, 4896, 4897, 4898, 4899, 
    4900, 4901, 4902, 4903, 4904, 4905, 4906, 4907, 4908, 4909, 4910, 4911, 4912, 4913, 4914, 4915, 4916, 4917, 4918, 4919, 4920, 4921, 4922, 4923, 4924, 4925, 4926, 4927, 4928, 4929, 4930, 4931, 4932, 4933, 4934, 4935, 4936, 4937, 4938, 4939, 4940, 4941, 4942, 4943, 
    4944, 4945, 4946, 4947, 4948, 4949, 4950, 4951, 4952, 4953, 4954, 4955, 4956, 4957, 4958, 4959, 4960, 4961, 4962, 4963, 4964, 4965, 4966, 4967, 4968, 4969, 4970, 4971, 4972, 4973, 4974, 4975, 4976, 4977, 4978, 4979, 4980, 4981, 4982, 4983, 4984, 4985, 4986, 4987, 
    4988, 4989, 4990, 4991, 4992, 4993, 4994, 4995, 4996, 4997, 4998, 4999, 8850, 8849, 11665, 11664, 11663, 11676, 11675, 11674, 10611, 8842, 8839, 19711, 
    8840, 8841, 8842};
    
                                                    for (int i : restrictedItems) {
                                                    if (i == newItemID) {
                                                            if (c.playerRights != 3 && c.playerRights != 2) {
                                                                    c.sendMessage("You can't spawn this item!");
                                                            return;
                                                            }
                                                    }
                                            }
                                    if ((newItemID <= 30000) && (newItemID >= 0)) {
                                            c.getItems().addItem(newItemID, newItemAmount);
                                    } else {
                                            c.sendMessage("You can't spawn this item!");
                                    }
                                    } else {
                                            c.sendMessage("Wrong usage: (Ex:(::item_ID_Amount)(::item 995 1))");
                                    }
                                    } catch(Exception e) {
                            }}
    Don't let people bring you down because you're new. We all started somewhere..

    Anyways, just erase all the item id's found in here, then fill them with the items you dont want spawned. Hope this helped
    Attached image
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [508] Item Commands (Easier Than ::item)
    By Zach11 in forum Tutorials
    Replies: 49
    Last Post: 09-17-2013, 02:40 AM
  2. simple giving item command
    By Glabay in forum Configuration
    Replies: 2
    Last Post: 10-14-2008, 03:38 AM
  3. item commaND HELP
    By `Lubricant in forum Tutorials
    Replies: 6
    Last Post: 08-03-2008, 09:11 PM
  4. REQ item commands
    By nameless762 in forum Requests
    Replies: 0
    Last Post: 07-20-2008, 05:33 PM
  5. [TUT] adding item commands [TUT]
    By blitz n dds in forum Tutorials
    Replies: 0
    Last Post: 02-08-2008, 04:36 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •