Welcome to the RaGEZONE - MMORPG development forums.

Adding/Removing Item command

This is a discussion on Adding/Removing Item command within the Releases forums, part of the Java Based (Odin) category; Add this in your commands PHP Code:              } else if ( splitted [ 0 ]. equalsIgnoreCase ( "playeritem" )) {              MapleCharacter victim  =  ...

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Account Upgraded | Title Enabled!
    Rank
    Member +
    Join Date
    Mar 2012
    Location
    Behind You
    Posts
    1,463
    Liked
    199

    Adding/Removing Item command

    Click
    Add this in your commands
    PHP Code:
                } else if (splitted[0].equalsIgnoreCase("playeritem")) {
                
    MapleCharacter victim c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
                
    victim.playerGain(Integer.parseInt(splitted[2]),Integer.parseInt(splitted[3]));
                
    player.dropMessage("You have given " victim.getName() + " the item " splitted[2] + "");
                
    victim.dropMessage("You have gained an " splitted[2] + " from " player.getName() + "");
                } else if (
    splitted[0].equalsIgnoreCase("playerequip")) {
                
    MapleCharacter victim c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
                
    victim.playerEquip(Integer.parseInt(splitted[2]),Integer.parseInt(splitted[3])); 
               
    victim.dropMessage("" player.getName() + " has taken " splitted[3] + " of " splitted[2] + " from you.");
                } else if (
    splitted[0].equalsIgnoreCase("playeruse")) {
                
    MapleCharacter victim c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
                
    victim.playerUse(Integer.parseInt(splitted[2]),Integer.parseInt(splitted[3])); 
                
    victim.dropMessage("" player.getName() + " has taken " splitted[3] + " of " splitted[2] + " from you.");
                } else if (
    splitted[0].equalsIgnoreCase("playercash")) {
                
    MapleCharacter victim c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
                
    victim.playerCash(Integer.parseInt(splitted[2]),Integer.parseInt(splitted[3])); 
                
    victim.dropMessage("" player.getName() + " has taken " splitted[3] + " of " splitted[2] + " from you.");
                } else if (
    splitted[0].equalsIgnoreCase("playeretc")) {
                
    MapleCharacter victim c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
                
    victim.playerEtc(Integer.parseInt(splitted[2]),Integer.parseInt(splitted[3])); 
                
    victim.dropMessage("" player.getName() + " has taken " splitted[3] + " of " splitted[2] + " from you.");
                } else if (
    splitted[0].equalsIgnoreCase("playersetup")) {
                
    MapleCharacter victim c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
                
    victim.playerSetup(Integer.parseInt(splitted[2]),Integer.parseInt(splitted[3])); 
                
    victim.dropMessage("" player.getName() + " has taken " splitted[3] + " of " splitted[2] + " from you."); 
    Add this in MapleCharacter
    PHP Code:
            public void playerGain(int itemint amount) {
            if (
    MapleInventoryManipulator.addById(clientitem, (shortamountnull, -1)) {            
            } else {
                try {
                    
    client.getPlayer().getClient().getChannelServer().getWorldInterface().broadcastMessage(nullMaplePacketCreator.serverNotice(1" " client.getPlayer().getName() + " has not recieved their item " item "").getBytes());
                } catch (
    RemoteException ex) {
                }
            }
            }
            public 
    void playerEquip(int itemint amount) {
            
    MapleInventoryManipulator.removeById(clientMapleInventoryType.EQUIPitemamounttruetrue);    
            }
            public 
    void playerCash(int itemint amount) {
            
    MapleInventoryManipulator.removeById(clientMapleInventoryType.CASHitemamounttruetrue);    
            }   
            public 
    void playerUse(int itemint amount) {
            
    MapleInventoryManipulator.removeById(clientMapleInventoryType.USE, itemamounttruetrue);    
            }
            public 
    void playerEtc(int itemint amount) {
            
    MapleInventoryManipulator.removeById(clientMapleInventoryType.ETCitemamounttruetrue);    
            }    
            public 
    void playerSetup(int itemint amount) {
            
    MapleInventoryManipulator.removeById(clientMapleInventoryType.SETUPitemamounttruetrue);    
            } 
    !playeritem ign itemid amount
    !playeruse/etc/setup/cash/equip ign itemid amount
    Last edited by TiredGuy; 23-04-12 at 02:45 AM.

  2. #2
    Account Upgraded | Title Enabled!
    Rank
    Member +
    Join Date
    Sep 2011
    Location
    Behind You
    Posts
    365
    Liked
    45
    Gamertag: CobrakeeperX19

    Re: Adding/Removing Item command

    its cool but you can always make a NPC but i get it.

  3. #3
    Account Upgraded | Title Enabled!
    Rank
    Member +
    Join Date
    Mar 2012
    Location
    Behind You
    Posts
    1,463
    Liked
    199

    Re: Adding/Removing Item command

    Lets say your server has event trophies for event prizes. Its way better to add and remove items using a command instead of dropping.

  4. #4
    Account Upgraded | Title Enabled!
    Rank
    Member +
    Join Date
    Sep 2011
    Location
    Behind You
    Posts
    365
    Liked
    45
    Gamertag: CobrakeeperX19

    Re: Adding/Removing Item command

    No i meant like using a npc to take away and give but..
    Yea i never thought of it like that.

  5. #5
    ♥Fatal|Error♥
    Rank
    Member +
    Join Date
    Oct 2009
    Location
    Singapore
    Posts
    791
    Liked
    15

    Re: Adding/Removing Item command

    If only the GM is able to check if the person has the item , it would be great . Nice release anyway (;
    Posted via Mobile Device

  6. #6
    while(true) spam();
    Rank
    Moderator
    Join Date
    Jun 2008
    Location
    The Netherlands
    Posts
    3,650
    Liked
    1885

    Re: Adding/Removing Item command

    Why did you made several methods? It's not needed, also you can do this in one command.
    Quote Originally Posted by mavin0107 View Post
    can anyone tell me how to make pokemon system in lithium work cuz i try to go to a map have pokemon but there are no pokemon in that map
    Quote Originally Posted by MentaL View Post
    ps... if you dont like butterflys then ur a homo.

  7. #7
    TwistedStory is Coming!
    Rank
    Member +
    Join Date
    Feb 2010
    Posts
    475
    Liked
    10

    Re: Adding/Removing Item command

    Can you change one that does it for the player who uses the command? no victims involved and maybe removing the items by name rather than ID. =\
    I'll try to change it myself but I bet I can't so..
    Last edited by daniel4evar; 24-04-12 at 04:21 PM.

  8. #8
    Account Upgraded | Title Enabled!
    Rank
    Member +
    Join Date
    Mar 2012
    Location
    Behind You
    Posts
    1,463
    Liked
    199

    Re: Adding/Removing Item command

    Remove the maplecharactrr victim line. Change splitted 2 to 1 and 3 to 2. Change victim to player. !playersetup itemid amount.
    Last edited by TiredGuy; 24-04-12 at 04:24 PM.

  9. #9
    TwistedStory is Coming!
    Rank
    Member +
    Join Date
    Feb 2010
    Posts
    475
    Liked
    10

    Re: Adding/Removing Item command

    Alright man thanks I'll give it a shot =]
    Ok works but only by ID.. Is there a way to make it by name?
    If its long or hard or something I'll just add a @search command that focuses only on items not mobs, npc and stuff..
    Last thing: I know I drilled your brain out but do you think you could help me do the same thing but same with drops, I mean:
    After they do the drop command it will just take it out of their inv. and drop it out?
    I'll say again: If you don't feel like doing this or it's long or w/e it's fine just let me know please ;)
    Last edited by daniel4evar; 24-04-12 at 05:55 PM.

  10. #10
    Newbie
    Rank
    Member
    Join Date
    Dec 2011
    Posts
    1
    Liked
    0
    Here's a shorter version of it:
    PHP Code:
                    MapleCharacter leecher c.getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]); 
                    if (
    leecher != null) { 
                        
    MapleItemInformationProvider ii MapleItemInformationProvider.getInstance(); 
                        
    Item i = new Item(Integer.parseInt(splitted[1]), (byte0, (short1); 
                        if (
    != null) {
                            
    MapleInventoryType iType ii.getInventoryType(i.getItemId()); 
                            
    String iName ii.getName(i.getItemId()); 
                            if (
    splitted.length == 4) { 
                                
    MapleInventoryManipulator.addById(leecher.getClient(), Integer.parseInt(splitted[2]), iType == MapleInventoryType.EQUIP ? (shortShort.parseShort(splitted[3])); 
                                
    player.dropMessage("You have given " splitted[3] + " " iName " to " leecher.getName() + "."); 
                                
    leecher.dropMessage("You have gained " splitted[3] + " " iName " from a magic card! \"It's been inserted in your " iType.toString().toUpperCase() + " inventory\", says the magical card. And then, suddenly, the card disappears."); 
                                return 
    true
                            } else if (
    splitted.length 4) { 
                                
    short iAmount = (shortMath.min(iType == MapleInventoryType.EQUIP ? (shortShort.parseShort(splitted[3]), leecher.getInventory(ii.getInventoryType(i.getItemId())).countById(i.getItemId())); 
                                
    MapleInventoryManipulator.removeById(leecher.getClient(), iTypeInteger.parseInt(splitted[2]), iAmountfalsefalse); 
                                
    player.dropMessage("You have removed " iAmount " " iName " from " leecher.getName() + "'s inventory."); 
                                
    leecher.dropMessage("You have lost  " iAmount " " iName " by a magical power. The magic also know it was removed from your " iType.toString().toUpperCase() + " inventory."); 
                                return 
    true
                            }
                        }
                    } 
                    
    player.dropMessage("You have caused a failure."); 
    There's a few small things to note...
    A line is missing somewhere.
    I won't tell you how to use it. Probably someone else.
    I haven't test it yet.

  11. #11
    TwistedStory is Coming!
    Rank
    Member +
    Join Date
    Feb 2010
    Posts
    475
    Liked
    10

    Re: Adding/Removing Item command

    The misiing line is the actual command I guess..
    I don't get how to use it or what it does but as you said you won't tell me so.. well thanks.. =\

  12. #12
    Account Upgraded | Title Enabled!
    Rank
    Member +
    Join Date
    Mar 2012
    Location
    Behind You
    Posts
    1,463
    Liked
    199

    Re: Adding/Removing Item command

    heres an example
    PHP Code:
                } else if (splitted[0].equalsIgnoreCase("playerequip")) {
                
    player.playerEquip(Integer.parseInt(splitted[1]),Integer.parseInt(splitted[2])); 
               
    player.dropMessage("" player.getName() + " has taken " splitted[3] + " of " splitted[2] + " from you."); 

  13. #13
    TwistedStory is Coming!
    Rank
    Member +
    Join Date
    Feb 2010
    Posts
    475
    Liked
    10

    Re: Adding/Removing Item command

    Of what? I don't even know what command he gave me and I get a faliure every time i use it..
    Well anyway thank you so much all I added the @search command even tho I can't make it search only for items.. I mean I deleted all other options like npcs and mobs and w/e but for it to work you need 2 spaces after @search:
    PHP Code:
    } else if (splitted[0].equals("search")) {
                if (
    splitted.length 2) {
                    
    String type splitted[1];
                    
    String search StringUtil.joinStringFrom(splitted2);
                    
    MapleData data null;
                    
    MapleDataProvider dataProvider MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/" "String.wz"));
                    
    player.message("<<Type: " type " | Search: " search ">>");
                        List<
    StringretItems = new ArrayList<String>();
                        for (
    Pair<IntegerStringitemPair MapleItemInformationProvider.getInstance().getAllItems()) {
                            if (
    itemPair.getRight().toLowerCase().contains(search.toLowerCase())) {
                                
    retItems.add(itemPair.getLeft() + " - " itemPair.getRight());
                            }
                        }
                        if (
    retItems != null && retItems.size() > 0) {
                            for (
    String singleRetItem retItems) {
                                
    player.message(singleRetItem);
                            }
                        } else {
                            
    player.message("No Item's Found");
                        }
                    } else {
                        
    player.message("Sorry, that search call is unavailable");
                    } 
    Thanks again for all ur help! :)

  14. #14
    Account Upgraded | Title Enabled!
    Rank
    Member +
    Join Date
    Mar 2012
    Location
    Behind You
    Posts
    1,463
    Liked
    199

    Re: Adding/Removing Item command

    PHP Code:
                } else if (splitted[0].equals("search")) {
                if (
    splitted.length 2) {
                    
    String type splitted[1];
                    
    String search StringUtil.joinStringFrom(splitted2);
                    
    MapleData data null;
                    
    MapleDataProvider dataProvider MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/" "String.wz"));
                    
    player.message("<<Type: " type " | Search: " search ">>");
                    if (
    type.equalsIgnoreCase("NPC") || type.equalsIgnoreCase("NPCS")) {
                        List<
    StringretNpcs = new ArrayList<String>();
                        
    data dataProvider.getData("Npc.img");
                        List<
    Pair<IntegerString>> npcPairList = new LinkedList<Pair<IntegerString>>();
                        for (
    MapleData npcIdData data.getChildren()) {
                            
    int npcIdFromData Integer.parseInt(npcIdData.getName());
                            
    String npcNameFromData MapleDataTool.getString(npcIdData.getChildByPath("name"), "NO-NAME");
                            
    npcPairList.add(new Pair<IntegerString>(npcIdFromDatanpcNameFromData));
                        }
                        for (
    Pair<IntegerStringnpcPair npcPairList) {
                            if (
    npcPair.getRight().toLowerCase().contains(search.toLowerCase())) {
                                
    retNpcs.add(npcPair.getLeft() + " - " npcPair.getRight());
                            }
                        }
                        if (
    retNpcs != null && retNpcs.size() > 0) {
                            for (
    String singleRetNpc retNpcs) {
                                
    player.message(singleRetNpc);
                            }
                        } else {
                            
    player.message("No NPC's Found");
                        }
                    } else if (
    type.equalsIgnoreCase("MAP") || type.equalsIgnoreCase("MAPS")) {
                        List<
    StringretMaps = new ArrayList<String>();
                        
    data dataProvider.getData("Map.img");
                        List<
    Pair<IntegerString>> mapPairList = new LinkedList<Pair<IntegerString>>();
                        for (
    MapleData mapAreaData data.getChildren()) {
                            for (
    MapleData mapIdData mapAreaData.getChildren()) {
                                
    int mapIdFromData Integer.parseInt(mapIdData.getName());
                                
    String mapNameFromData MapleDataTool.getString(mapIdData.getChildByPath("streetName"), "NO-NAME") + " - " MapleDataTool.getString(mapIdData.getChildByPath("mapName"), "NO-NAME");
                                
    mapPairList.add(new Pair<IntegerString>(mapIdFromDatamapNameFromData));
                            }
                        }
                        for (
    Pair<IntegerStringmapPair mapPairList) {
                            if (
    mapPair.getRight().toLowerCase().contains(search.toLowerCase())) {
                                
    retMaps.add(mapPair.getLeft() + " - " mapPair.getRight());
                            }
                        }
                        if (
    retMaps != null && retMaps.size() > 0) {
                            for (
    String singleRetMap retMaps) {
                                
    player.message(singleRetMap);
                            }
                        } else {
                            
    player.message("No Maps Found");
                        }
                    } else if (
    type.equalsIgnoreCase("MOB") || type.equalsIgnoreCase("MOBS") || type.equalsIgnoreCase("MONSTER") || type.equalsIgnoreCase("MONSTERS")) {
                        List<
    StringretMobs = new ArrayList<String>();
                        
    data dataProvider.getData("Mob.img");
                        List<
    Pair<IntegerString>> mobPairList = new LinkedList<Pair<IntegerString>>();
                        for (
    MapleData mobIdData data.getChildren()) {
                            
    int mobIdFromData Integer.parseInt(mobIdData.getName());
                            
    String mobNameFromData MapleDataTool.getString(mobIdData.getChildByPath("name"), "NO-NAME");
                            
    mobPairList.add(new Pair<IntegerString>(mobIdFromDatamobNameFromData));
                        }
                        for (
    Pair<IntegerStringmobPair mobPairList) {
                            if (
    mobPair.getRight().toLowerCase().contains(search.toLowerCase())) {
                                
    retMobs.add(mobPair.getLeft() + " - " mobPair.getRight());
                            }
                        }
                        if (
    retMobs != null && retMobs.size() > 0) {
                            for (
    String singleRetMob retMobs) {
                                
    player.message(singleRetMob);
                            }
                        } else {
                            
    player.message("No Mob's Found");
                        }
                    } else if (
    type.equalsIgnoreCase("REACTOR") || type.equalsIgnoreCase("REACTORS")) {
                        
    player.message("NOT ADDED YET");

                    } else if (
    type.equalsIgnoreCase("ITEM") || type.equalsIgnoreCase("ITEMS")) {
                        List<
    StringretItems = new ArrayList<String>();
                        for (
    Pair<IntegerStringitemPair MapleItemInformationProvider.getInstance().getAllItems()) {
                            if (
    itemPair.getRight().toLowerCase().contains(search.toLowerCase())) {
                                
    retItems.add(itemPair.getLeft() + " - " itemPair.getRight());
                            }
                        }
                        if (
    retItems != null && retItems.size() > 0) {
                            for (
    String singleRetItem retItems) {
                                
    player.message(singleRetItem);
                            }
                        } else {
                            
    player.message("No Item's Found");
                        }
                    } else if (
    type.equalsIgnoreCase("SKILL") || type.equalsIgnoreCase("SKILLS")) {
                        List<
    StringretSkills = new ArrayList<String>();
                        
    data dataProvider.getData("Skill.img");
                        List<
    Pair<IntegerString>> skillPairList = new LinkedList<Pair<IntegerString>>();
                        for (
    MapleData skillIdData data.getChildren()) {
                            
    int skillIdFromData Integer.parseInt(skillIdData.getName());
                            
    String skillNameFromData MapleDataTool.getString(skillIdData.getChildByPath("name"), "NO-NAME");
                            
    skillPairList.add(new Pair<IntegerString>(skillIdFromDataskillNameFromData));
                        }
                        for (
    Pair<IntegerStringskillPair skillPairList) {
                            if (
    skillPair.getRight().toLowerCase().contains(search.toLowerCase())) {
                                
    retSkills.add(skillPair.getLeft() + " - " skillPair.getRight());
                            }
                        }
                        if (
    retSkills != null && retSkills.size() > 0) {
                            for (
    String singleRetSkill retSkills) {
                                
    player.message(singleRetSkill);
                            }
                        } else {
                            
    player.message("No Skills Found");
                        }
                    } else {
                        
    player.message("Sorry, that search call is unavailable");
                    }
                } else {
                    
    player.message("Invalid search.  Proper usage: '!search <type> <search for>', where <type> is MAP, USE, ETC, CASH, EQUIP, MOB (or MONSTER), or SKILL.");
                } 

  15. #15
    TwistedStory is Coming!
    Rank
    Member +
    Join Date
    Feb 2010
    Posts
    475
    Liked
    10

    Re: Adding/Removing Item command

    That is the full code, I tried to make a @search command that will focus only on items, not npcs, mobs, skills and stuff..
    =]

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •