Thread: Pet system [Tutorial]

Results 1 to 8 of 8
  1. #1 Pet system [Tutorial] 
    Banned

    Join Date
    Jun 2015
    Posts
    1,517
    Thanks given
    31
    Thanks received
    143
    Rep Power
    0


    What you are adding is a simple a Pet system!

    Difficulty: 1/10
    Knownledge: Copy & Paste
    Base: PI

    What are you adding!

    Attached image





    Go to src.server.model.npcs and add FOLDER called pet
    2. make Class on it Called DropPet.java, Pet.java, PetData

    DropPet.java
    Code:
    package server.model.npcs.pet;
    
    import server.model.players.Client;
    
    
    /**
     * Drop the pet.
     * @author MGT Madness, created on 11-12-2013.
     */
    public class DropPet 
    {
    	
    	/**
         * The class instance.
         */
        private static final DropPet instance = new DropPet();
    
        /**
         * Returns a visible encapsulation of the class instance.
         *
         * @return The returned encapsulated instance.
         */
        public final static DropPet getInstance()
        {
                return instance;
        }
    	
        /**
         * Check if the player has requirements to drop the pet.
         * @param player
         * 			The player dropping the pet.
         * @param itemId
         * 			The pet item identity being dropped.
         * @param slot
         * 			The slot of the item being dropped.
         */
    	public void dropPetRequirements(Client player, int itemId, int slot)
    	{
    		if (player.getPetSummoned())
            {
    			player.sendMessage("You already have a pet following you.");
    			return;
            }
    		for (int i = 0; i < PetData.petData.length; i++)
            {
    				if (PetData.petData[i][1] == itemId)
                    {
    
                    	dropPet(player, itemId, slot);
                    }
            }
    
    	}
    	
    	/**
    	 * Summon the pet and delete inventory pet item.
    	 * @param player
    	 * 			The player dropping the pet.
    	 * @param itemId
    	 * 			The pet identity item in inventory.
    	 * @param slot
    	 * 			The slot of the pet item in inventory.
    	 */
    	private void dropPet(Client player, int itemId, int slot)
    	{
    		for (int i = 0; i < PetData.petData.length; i++)
            {
                    if (PetData.petData[i][1] == itemId)
                    {
                    	player.sendMessage("You drop your pet and it starts following you.");
                    	Pet.summonPet(player, PetData.petData[i][0], player.absX, player.absY - 1, player.heightLevel);
                    }
            }
            player.getItems().deleteItem(itemId, slot, player.playerItemsN[slot]);
    	}
    
    }
    Pet.java
    Code:
    package server.model.npcs.pet;
    
    import server.model.npcs.NPC;
    import server.model.npcs.NPCHandler;
    import server.model.players.Client;
    import server.model.players.Player;
    
    /**
     *	@author Jordon
     *	@author Animeking1120
     *	@author Erick
     *  @author MGT Madness, started editing at 11-12-2013.
     *  <p>
     *  Pet system.
     */
    public class Pet
    {
    
            /**
             * Find if this NPC is a pet to pickup.
             * @param player
             * 			The player interacting with the the NPC.
             * @param npcType
             * 			The NPC type being interacted with.
             */
            public static void pickUpPetRequirements(Client player, int npcType)
            {
            	 for (int i = 0; i < PetData.petData.length; i++)
                 {
                         if (PetData.petData[i][0] == npcType)
                         {
                         	if (NPCHandler.npcs[player.npcClickIndex].summonedBy == player.playerId)
                             {
                         		if (player.getItems().freeSlots() > 0)
                         		{
                         				pickUpPet(player, npcType);
                         		}
                             	else
                             	{
                             		player.sendMessage("Not enough space in your inventory.");
                             	}
                             }
                         	else
                         	{
                         		player.sendMessage("This is not your pet.");
                         	}
                         }
                 }
            }
    
            /**
             * Pick up the pet and place in inventory of the player.
             * @param player
             * 			The player picking up the pet.
             * @param pet
             * 			The identity of the pet being picked up
             */
            public static void pickUpPet(Client player, int pet)
            {
            		player.sendMessage("You pick up your pet.");
            		player.startAnimation(827);
                    for (int i = 0; i < PetData.petData.length; i++)
                    {
                            if (PetData.petData[i][0] == pet)
                            {
                                    player.getItems().addItem(PetData.petData[i][1], 1);
                            }
                    }
                    for (int i = 0; i < NPCHandler.maxNPCs; i++)
                    {
                            if (NPCHandler.npcs[i] == null)
                            {
                                    continue;
                            }
                            if (NPCHandler.npcs[i].summonedBy == player.playerId)
                            {
                                    deletePet(NPCHandler.npcs[i]);
                            }
                    }
                    player.setPetSummoned(false);
                    player.petID = 0;
            }
    
            /**
             * Summon the pet.
             * @param player
             * 			The player who summoned the pet.
             * @param npcType
             * 			The pet being summoned.
             * @param x
             * 			The x coord of the pet.
             * @param y
             * 			The x coord of the pet.
             * @param heightLevel
             * 			The height of the pet.
             */
            public static void summonPet(Player player, int npcType, int x, int y, int heightLevel)
            {
                    int slot = -1;
                    for (int i = 1; i < NPCHandler.maxNPCs; i++)
                    {
                            if (NPCHandler.npcs[i] == null)
                            {
                                    slot = i;
                                    break;
                            }
                    }
                    if (slot == -1)
                    {
                            return;
                    }
                    NPC newNPC = new NPC(slot, npcType);
                    newNPC.absX = x;
                    newNPC.absY = y;
                    newNPC.makeX = x;
                    newNPC.makeY = y;
                    newNPC.heightLevel = heightLevel;
                    newNPC.walkingType = 0;
                    newNPC.HP = 0;
                    newNPC.MaxHP = 0;
                    newNPC.maxHit = 0;
                    newNPC.attack = 0;
                    newNPC.defence = 0;
                    newNPC.spawnedBy = player.getId();
                    newNPC.underAttack = true;
                    newNPC.facePlayer(player.playerId);
                    newNPC.summoned = true;
                    newNPC.summonedBy = player.playerId;
                    player.petID = npcType;
                    player.setPetSummoned(true);
                    NPCHandler.npcs[slot] = newNPC;
            }
    
            /**
             * Delete the current pet to summon a new one.
             * This is for cases such as the Player is too far away from Pet, so the pet gets deleted and summoned close to player. Or if pet is picked up.
             */
            public static void deletePet(NPC pet)
            {
                    pet.absX = -1;
                    pet.absY = -1;
                    pet.makeX = -1;
                    pet.makeY = -1;
                    pet.heightLevel = -1;
                    pet.walkingType = -1;
                    pet.HP = -1;
                    pet.MaxHP = -1;
                    pet.maxHit = -1;
                    pet.attack = -1;
                    pet.defence = -1;
                    pet.isDead = true;
                    pet.applyDead = true;
            }
            
            /**
             * Spawn the pet for the player that just logged in
             * @param player
             * 			The associated player.
             */
            public static void ownerLoggedIn(Client player)
            {
            	if (player.getPetSummoned() && player.petID > 0)
                {
                        Pet.summonPet(player, player.petID, player.absX, player.absY - 1, player.heightLevel);
                        player.sendMessage("Your loyal pet finds you!");
                }
            }
            
    }
    Code:
    package server.model.npcs.pet;
    
    /**
     * Handle large pet data.
     * @author MGT Madness, created on 12-12-2013.
     */
    public class PetData 
    {
    	
    	/**
         * NPC spawn identity and Pet identity in inventory.
         */
        public static int[][] petData = {
    	     
        	    {
        	    	498, 12653 // King Black Dragon. // F
                },
    		    {
                	130, 12649 // Kree arra. // F
    	        },
    		    {
    	        	2573, 12650 // General Graardor. // F
    	        },
    		    {
    	        	857, 12652 // K'ril Tsutsaroth. // F
    	        },
    		    {
    	        	858, 12651 // Commander Zilyana. // F
    	        },	        
        		{
    	        	454, 12694 // Chaos elemental. // F
        		},
        		{
        			859, 12643 // Supreme // F
        		},
        		{
        			860, 12644 // Prime // F
        		},
        		{
        			861, 12645 // Rex // F
        		},
        		{
        				6305, 12655 // Kraken
        		},
        		{
        				25, 15574 // Vet'ion // 90% working - Walking anim needed F
        		},
        		{
        			1593, 15573 // Callisto Added F
        		},
        		{
        			1552, 14073 // Santa guy pet
        		},
        		{
        				4020, 15571 // Venenatis
        		},
        		{
        				4021, 15572 // Scorpia
        		},
        		{
        			864, 16672 // Kalphite queen Jr
    		},
        		{
    			863, 17672 // Baby mole
    	},
        		
        		{            
                        761, 1555 // Pet kitten.
                },
                {
                        762, 1556 // Pet kitten.
                },
                {
                        763, 1557 // Pet kitten.
                },
                {
                        764, 1558 // Pet kitten.
                },
                {
                        765, 1559 // Pet kitten.
                },
                {
                        766, 1560 // Pet kitten.
                },
                {
                        768, 1561 // Pet cat.
                },
                {
                        769, 1562 // Pet cat.
                },
                {
                        770, 1563 // Pet cat.
                },
                {
                        771, 1564 // Pet cat.
                },
                {
                        772, 1565 // Pet cat.
                },
                {
                        773, 1566 // Pet cat.
                },
                {
                        80, 7001 // Camel.
                },
                {
                        3505, 7583 // Hell-kitten.
                },
                {
                        3506, 7584 // Lazy hellcat.
                },
                {
                        3507, 7585 // Wily hellcat.
                },
                {
                        6900, 12469 // Red Hatchling dragon.
                },
                {
                        6901, 12470 // Red Baby Dragon.
                },
                {
                        6902, 12471 // Blue Hatchling dragon.
                },
                {
                        6903, 12472 // Blue Baby Dragon.
                },
                {
                        6904, 12473 // Green Hatchling Dragon.
                },
                {
                        6905, 12474 // Green Baby Dragon.
                },
                {
                        6906, 12475 // Black Hatchling Dragon.
                },
                {
                        6907, 12476 // Black Baby Dragon.
                },
                {
                        6908, 12481 // Baby Penguin.
                },
                {
                        6909, 12482 // Penguin.
                },
                {
                        6910, 12762 // Penguin.
                },
                {
                        6911, 12484 // Raven Chick.
                },
                {
                        6912, 12485 // Raven.
                },
                {
                        6913, 12486 // Baby Raccoon.
                },
                {
                        6914, 12487 // Raccoon.
                },
                {
                        6915, 12488 // Orange Baby Gecko.
                },
                {
                        6916, 12489 // Orange Gecko.
                },
                {
                        6919, 12490 // Baby Squirrel.
                },
                {
                        6920, 12491 // Squirrel.
                },
                {
                        6922, 12492 // Baby Chameleon (Green).
                },
                {
                        6923, 12493 // Chameleon (Green).
                },
                {
                        6942, 12496 // Baby Monkey.
                },
                {
                        6943, 12497 // Monkey.
                },
                {
                        6945, 12498 // Baby Vulture.
                },
                {
                        6946, 12499 // Vulture.
                },
                {
                        6947, 12500 // Baby Giant Crab.
                },
                {
                        6948, 12501 // Giant Crab.
                },
                {
                        6949, 12503 // Saradomin chick.
                },
                {
                        6950, 12504 // Saradomin bird.
                },
                {
                        6951, 12505 // Saradomin owl.
                },
                {
                        6952, 12506 // Zamorak chick.
                },
                {
                        6953, 12507 // Zamorak bird.
                },
                {
                        6954, 12508 // Zamorak hawk.
                },
                {
                        6955, 12509 // Guthix chick.
                },
                {
                        6956, 12510 // Guthix bird.
                },
                {
                        6957, 12511 // Guthix raptor.
                },
                {
                        6958, 12512 // Terrier Puppy.
                },
                {
                        6959, 12513 // Terrier.
                },
                {
                        6960, 12514 // Greyhound puppy.
                },
                {
                        6961, 12515 // Greyhound.
                },
                {
                        6962, 12516 // Labrador puppy.
                },
                {
                        6963, 12517 // Labrador.
                },
                {
                        6964, 12518 // Dalmatian puppy.
                },
                {
                        6965, 12519 // Dalmatian.
                },
                {
                        6966, 12520 // Sheepdog puppy.
                },
                {
                        6967, 12521 // Sheepdog.
                },
                {
                        6968, 12522 // Bulldog puppy.
                },
                {
                        6969, 12523 // Bulldog.
                }
        };
    
    }
    At Client.java Imoport
    Code:
    import server.model.npcs.pet.Pet;
    import server.model.players.Pets;
    and under public boolean usingCarpet = false; add
    Code:
    	private Pets pets = new Pets();
    add this somewhere
    Code:
    	private static final Pets Pets = null;
    on
    public void initialize() {
    add
    Code:
    Pet.ownerLoggedIn(this);
    some where on initazlize add
    Code:
    	if (hasNpc == true) {
    				if (summonId == 498) {
    					getItems().addItem(12653, 1);
    				}
    				if (summonId == 4003) {
    					getItems().addItem(12694, 1);
    				}
    				if (summonId == 454) {
    					getItems().addItem(12650, 1);
    				}
    				if (summonId == 130) {
    					getItems().addItem(12649, 1);
    				}
    				if (summonId == 857) {
    					getItems().addItem(12652, 1);
    				}
    				if (summonId == 858) {
    					getItems().addItem(12651, 1);
    				}
    				if (summonId == 859) {
    					getItems().addItem(12643, 1);
    				}
    				if (summonId == 860) {
    					getItems().addItem(12644, 1);
    				}
    				if (summonId == 861) {
    					getItems().addItem(12645, 1);
    				}
    				if (summonId == 859) {
    					getItems().addItem(12655, 1);
    				}
    				// Server.npcHandler.spawnNpc3(this, summonId, absX, absY-1,
    				// heightLevel, 0, 120, 25, 200, 200, true, false, true);
    				summonId = 0;
    				hasNpc = false;
    				this.sendMessage("Your pet has been added to your inventory.");
    			}
    under
    public Crafting getCrafting() {
    return crafting;
    }

    add
    Code:
    public Pets getSummon() {
    		return Pets;
    	}
    We are done from Client.java Save n close!

    Npchandler.java import:
    Code:
    import server.model.npcs.pet.Pet;
    at public void process() {
    add
    Code:
    for (int i = 0; i < maxNPCs; i++) {
    			if (npcs[i] != null) {
    				NPC npc = npcs[i];
                            Client petOwner = (Client) PlayerHandler.players[npc.summonedBy];
                            if (petOwner == null && npc.summoned)
                            {
                                    Pet.deletePet(npc);
                            }
                            if (petOwner != null && petOwner.isDead)
                            {
                                    Pet.deletePet(npc);
                            }
                            if (petOwner != null && petOwner.getPetSummoned() && npc.summoned)
                            {
                                    if (petOwner.goodDistance(npc.getX(), npc.getY(), petOwner.absX, petOwner.absY, 15))
                                    {
                                            Server.npcHandler.followPlayer(i, petOwner.playerId);
                                    }
                                    else
                                    {
                                            Pet.deletePet(npc);
                                            Pet.summonPet(petOwner, petOwner.petID, petOwner.absX, petOwner.absY - 1, petOwner.heightLevel);
                                    }
                            }
    				}
    		}
    We are from Npchandler.java

    Actionhandler.java Import
    Code:
    import server.model.npcs.pet.Pet;
    import server.model.npcs.pet.Pet;
    and at public void firstClickNpc(int npcType) {
    add
    Code:
    Pet.pickUpPetRequirements(c, npcType);
    We are done from Actionhandler.java

    At dropItem.java import
    Code:
    import server.model.npcs.pet.DropPet;
    import server.model.npcs.pet.PetData;
    import server.model.players.Pets;
    add
    Code:
     for (int i = 0; i < PetData.petData.length; i++)
    	        {
    	                if (PetData.petData[i][1] == itemId)
    	                {
    	                	if (c.getPetSummoned())
    	                    {
    	                            droppable = false;
    	                            break;
    	                    }
    	                }
    	        }
    		DropPet.getInstance().dropPetRequirements(c, itemId, slot);
    		if (c.playerItemsN[slot] == 0 || itemId < 0
    				|| c.playerItems[slot] != itemId + 1) {
    			return;
    		}
    Save n close it

    At Player.java under public byte getChatTextSize() {
    return chatTextSize;
    }
    add
    Code:
    //Pets
    	public boolean petSummoned;
    
        /**
         * Change the state of petSummoned.
         * @param state
         * 			The state of petSummoned.
         */
    	public int petID;
        public void setPetSummoned(boolean state)
        {
                petSummoned = state;
        }
    	
    	    public boolean getPetSummoned()
        {
                return petSummoned;
        }
    At PlayerSave.java

    Under
    } else if (token.equals("special-amount")) {
    p.specAmount = Double.parseDouble(token2);
    add
    Code:
          } else if (token.equals("petID")) {
                                p.petID = Integer.parseInt(token2);
                        } else if (token.equals("petSummoned")) {
    							p.setPetSummoned(Boolean.parseBoolean(token2));
    and under characterfile.write("character-rights = ", 0, 19);
    characterfile.write(Integer.toString(p.playerRight s), 0, Integer.toString(p.playerRights).length());
    characterfile.newLine();
    add
    Code:
         characterfile.write("petSummoned = ", 0, 14);
                characterfile.write(Boolean.toString(p.getPetSummoned()), 0, Boolean.toString(p.getPetSummoned()).length());
                characterfile.newLine();
                characterfile.write("petID = ", 0, 8);
                characterfile.write(Integer.toString(p.petID), 0, Integer.toString(p.petID).length());
                characterfile.newLine();
    THIS BEEN TESTED MANY TIMES AND IT WORKS FINE!

    Thanks Enjoy it!
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member
    Join Date
    Apr 2016
    Posts
    29
    Thanks given
    119
    Thanks received
    1
    Rep Power
    12
    Amazing, Thanks for the Tutorial!
    Reply With Quote  
     

  4. #3  
    Registered Member
    Join Date
    May 2016
    Posts
    39
    Thanks given
    2
    Thanks received
    3
    Rep Power
    0
    thanks alot james
    Reply With Quote  
     

  5. #4  
    Respected Member


    George's Avatar
    Join Date
    Mar 2009
    Posts
    7,099
    Thanks given
    2,226
    Thanks received
    3,146
    Rep Power
    5000
    Not gonna lie man, that's alot of code for such simple thing.

    Also you could probably use an enum to store the pet information.
    Code:
    package com.kandarin.model.entity.player.content.pets;
    
    import java.util.EnumSet;
    
    import com.google.common.collect.ImmutableSet;
    import com.google.common.collect.Sets;
    
    /**
     * 
     * @author Jack
     *
     */
    
    public enum PetInformation {
    
    	ABYSSAL_ORPHAN(13262, 5883);
    
    	private PetInformation(final int itemId, final int typeIdentifier) {
    		this.itemId = itemId;
    		this.typeIdentifier = typeIdentifier;
    	}
    
    	/**
    	 * A immutable set containining all pet information
    	 */
    	private static final ImmutableSet<PetInformation> SET = Sets.immutableEnumSet(EnumSet.allOf(PetInformation.class));
    
    	/**
    	 * Fetches pet information by item id
    	 * 
    	 * @param id
    	 *            The id
    	 * @return {@link PetInformation}
    	 */
    	public static final PetInformation get(final int id) {
    		return SET.stream().filter(set -> set.getItemId() == id).findFirst().orElse(null);
    	}
    
    	/**
    	 * Fetches pet information by type identifier
    	 * 
    	 * @param typeIdentifier
    	 *            The type identifier
    	 * @return {@link Pet information}
    	 */
    	public static final PetInformation getByIdentifier(final int typeIdentifier) {
    		return SET.stream().filter(set -> set.getTypeIdentifier() == typeIdentifier).findFirst().orElse(null);
    	}
    
    	/**
    	 * @return the itemId
    	 */
    	public int getItemId() {
    		return itemId;
    	}
    
    	/**
    	 * @return the typeIdentifier
    	 */
    	public int getTypeIdentifier() {
    		return typeIdentifier;
    	}
    
    	/**
    	 * The item id
    	 */
    	private final int itemId;
    
    	/**
    	 * The type identifier
    	 */
    	private final int typeIdentifier;
    
    }
    Some of your code is really a huge bottleneck , I'll point out a few things.

    From what I can tell from this code, you're looping through the entire worlds NPC entities, to check if an NPC is too far away from it's owner or if its owner is dead, every game tick?
    Code:
    	for (int i = 0; i < maxNPCs; i++) {
    		if (npcs[i] != null) {
    			NPC npc = npcs[i];
                    Client petOwner = (Client) PlayerHandler.players[npc.summonedBy];
                    if (petOwner == null && npc.summoned) {
                        Pet.deletePet(npc);
                    }
                    if (petOwner != null && petOwner.isDead) {
                           Pet.deletePet(npc);
                    }
                    if (petOwner != null && petOwner.getPetSummoned() && npc.summoned) {
                          if (petOwner.goodDistance(npc.getX(), npc.getY(), petOwner.absX, petOwner.absY, 15)) {
                                Server.npcHandler.followPlayer(i, petOwner.playerId);
                          } else {
                          	    Pet.deletePet(npc);
                                Pet.summonPet(petOwner, petOwner.petID, petOwner.absX, petOwner.absY - 1, petOwner.heightLevel);
                          }
                    }
    	 }
    Could just handle this within the players game tick and instead of looping through the entire worlds NPC list, just fetch it by using the spawned NPC's identifier.
    Code:
    		if (player.getPetIdentifier() > -1) {
    			final NPC npc = (NPC) World.getSingleton().getPlayers().get(player.getPetIdentifier());
    			if (npc != null) {
    				if (!npc.getPosition().isWithinDistance(player.getPosition())) {
    					npc.setTeleportTarget(player.getPosition());
    				}
    				if (player.isDead()) {
    					// TODO DELETE NPC 
    				}
    			}
    		}
    You could store all of these item ids inside of the array / enum
    Code:
    if (hasNpc == true) {
    				if (summonId == 498) {
    					getItems().addItem(12653, 1);
    				}
    				if (summonId == 4003) {
    					getItems().addItem(12694, 1);
    				}
    				if (summonId == 454) {
    					getItems().addItem(12650, 1);
    				}
    				if (summonId == 130) {
    					getItems().addItem(12649, 1);
    				}
    				if (summonId == 857) {
    					getItems().addItem(12652, 1);
    				}
    				if (summonId == 858) {
    					getItems().addItem(12651, 1);
    				}
    				if (summonId == 859) {
    					getItems().addItem(12643, 1);
    				}
    				if (summonId == 860) {
    					getItems().addItem(12644, 1);
    				}
    				if (summonId == 861) {
    					getItems().addItem(12645, 1);
    				}
    				if (summonId == 859) {
    					getItems().addItem(12655, 1);
    				}
    				// Server.npcHandler.spawnNpc3(this, summonId, absX, absY-1,
    				// heightLevel, 0, 120, 25, 200, 200, true, false, true);
    				summonId = 0;
    				hasNpc = false;
    				this.sendMessage("Your pet has been added to your inventory.");
    			}
    Attached image

    Spoiler for Spoilers!:
    Attached image
    Attached image
    Attached image
    Attached image
    Reply With Quote  
     

  6. Thankful users:


  7. #5  
    Registered Member
    Join Date
    Sep 2015
    Posts
    68
    Thanks given
    41
    Thanks received
    75
    Rep Power
    36
    Thanks for this! Nice post.
    Reply With Quote  
     

  8. #6  
    Registered Member
    Remi's Avatar
    Join Date
    Jan 2015
    Posts
    628
    Thanks given
    572
    Thanks received
    212
    Rep Power
    574
    Quote Originally Posted by jon1388 View Post
    hmm....
    i dont got import server.model.players.Pets;
    ?
    Make it.
    Where the fuck is my cigarettes, I need my cancer. [C]44..
    Reply With Quote  
     

  9. #7  
    Registered Member
    _Ali's Avatar
    Join Date
    Apr 2014
    Posts
    382
    Thanks given
    67
    Thanks received
    147
    Rep Power
    252
    Quote Originally Posted by Idiot Bird View Post
    Could just handle this within the players game tick and instead of looping through the entire worlds NPC list, just fetch it by using the spawned NPC's identifier.
    Code:
    		if (player.getPetIdentifier() > -1) {
    			final NPC npc = (NPC) World.getSingleton().getPlayers().get(player.getPetIdentifier());
    			if (npc != null) {
    				if (!npc.getPosition().isWithinDistance(player.getPosition())) {
    					npc.setTeleportTarget(player.getPosition());
    				}
    				if (player.isDead()) {
    					// TODO DELETE NPC 
    				}
    			}
    		}
    final NPC npc = (NPC) World.getSingleton().getPlayers().get(player.getPe tIdentifier()); //You will get a cast exception here, you can't cast from player to npc. xd @whoever's going to use it. Get some sleep Jack!
    Reply With Quote  
     

  10. Thankful user:


  11. #8  
    Registered Member
    Join Date
    Jan 2018
    Posts
    37
    Thanks given
    0
    Thanks received
    1
    Rep Power
    12
    in dropitem.java, where do I add the code:
    Code:
     for (int i = 0; i < PetData.petData.length; i++)
    	        {
    	                if (PetData.petData[i][1] == itemId)
    	                {
    	                	if (c.getPetSummoned())
    	                    {
    	                            droppable = false;
    	                            break;
    	                    }
    	                }
    	        }
    		DropPet.getInstance().dropPetRequirements(c, itemId, slot);
    		if (c.playerItemsN[slot] == 0 || itemId < 0
    				|| c.playerItems[slot] != itemId + 1) {
    			return;
    		}
    ?
    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. Pet system for PI
    By _James in forum Buying
    Replies: 11
    Last Post: 11-07-2016, 01:00 AM
  2. Announcement system for [PI]
    By FuzzyAvacado in forum Snippets
    Replies: 0
    Last Post: 05-29-2013, 03:34 AM
  3. Pk point system for PI
    By GoOd-LoOk-BrOo in forum Snippets
    Replies: 16
    Last Post: 04-16-2013, 05:35 AM
  4. [REQ] auto donation system for [PI]
    By RsTurm in forum Requests
    Replies: 0
    Last Post: 03-23-2012, 09:02 PM
  5. A new NPC drop system for PI and Emulous.
    By Rune Division in forum Tutorials
    Replies: 8
    Last Post: 01-04-2011, 07:04 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •