Thread: Forcing Equipment to be removed?

Results 1 to 10 of 10
  1. #1 Forcing Equipment to be removed? 
    Registered Member
    Join Date
    Jul 2013
    Posts
    48
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    I am trying to figure out how to make is to where if you click on an object it will remove your cape and hat.

    I know the following code works for equipping equipment.
    Code:
    c.playerEquipment[SLOT#] = ITEM#;
    However I can't figure out how to remove the current equip item and send it to your inventory.

    Thanks in advance!

    -ElitexChaos
    Reply With Quote  
     

  2. #2  
    (Official) Thanksgiver

    Arham's Avatar
    Join Date
    Jan 2013
    Age
    23
    Posts
    3,415
    Thanks given
    7,254
    Thanks received
    1,938
    Rep Power
    3905
    Save the item (on the slot) from a variable and then make that slot -1. Then, add the item from the variable to the inventory.
    Code:
    int weapon = 0;
    c.playerEquipment[c.playerWeapon] = weapon;
    if (player.getFreeSlots() > 0) {
    	c.playerEquipment[c.playerWeapon] = -1;
    	c.addItem(weapon);
    } else {
    	c.sendMessage("You must have atleast 1 free equipment slot!");
    }
    Thats a concept of the code. Its not accurate at all since I haven't used PI in 2 years.
    Attached image
    Attached image
    Quote Originally Posted by MrClassic View Post
    Arham is the official thanker!
    List of my work here!
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jul 2013
    Posts
    48
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by RelentlessPK View Post
    Save the item (on the slot) from a variable and then make that slot -1. Then, add the item from the variable to the inventory.
    Code:
    int weapon = 0;
    c.playerEquipment[c.playerWeapon] = weapon;
    if (player.getFreeSlots() > 0) {
    	c.playerEquipment[c.playerWeapon] = -1;
    	c.addItem(weapon);
    } else {
    	c.sendMessage("You must have atleast 1 free equipment slot!");
    }
    Thats a concept of the code. Its not accurate at all since I haven't used PI in 2 years.
    Thanks, however I have to remove any item the person is wearing. Not just 1 item.
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Dec 2011
    Posts
    967
    Thanks given
    234
    Thanks received
    208
    Rep Power
    0
    Quote Originally Posted by ElitexChaos View Post
    Thanks, however I have to remove any item the person is wearing. Not just 1 item.
    Use a simple loop

    Code:
    int i = 0;
    do {
    c.getItems().addItem(playerEquipment[i], playerEquipmentN[i]);
    c.playerEquipment[i] = -1;
    c.playerEquipmentN[i] = -1;
    i++;
    }while(i < 11)
    c.getPA().requestUpdates();
    Reply With Quote  
     

  5. #5  
    (Official) Thanksgiver

    Arham's Avatar
    Join Date
    Jan 2013
    Age
    23
    Posts
    3,415
    Thanks given
    7,254
    Thanks received
    1,938
    Rep Power
    3905
    Quote Originally Posted by ElitexChaos View Post
    Thanks, however I have to remove any item the person is wearing. Not just 1 item.
    All you'd need to do is just make more variables. Not sure if this is inefficient, but it works (even though I hate the modo, I'm not sure of any other way of how to do this (besides making a for loop)).
    Code:
    int weapon = 0;
    int helmet = 0;
    int amulet = 0;
    int cape = 0;
    int ammo = 0;
    int torso = 0;
    int shield = 0;
    int legs = 0;
    int boots = 0;
    int gloves = 0;
    int rings = 0;
    helmet = c.playerEquipment[c.playerHat];
    cape = c.playerEquipment[c.playerCape];
    amulet = c.playerEquipment[c.playerAmulet];
    weapon = c.playerEquipment[c.playerWeapon];
    torso = c.playerEquipment[c.playerChest];
    shield = c.playerEquipment[c.playerShield];
    legs = c.playerEquipment[c.playerLegs];
    gloves = c.playerEquipment[c.playerHands];
    boots = c.playerEquipment[c.playerFeet];
    rings = c.playerEquipment[c.playerRing];
    ammo = c.playerEquipment[c.playerArrows];
    if (player.getFreeSlots() >= 11) {
    	c.playerEquipment[c.playerHat] = -1;
    	c.playerEquipment[c.playerCape] = -1;
    	c.playerEquipment[c.playerAmulet] = -1;
    	c.playerEquipment[c.playerWeapon] = -1;
    	c.playerEquipment[c.playerChest] = -1;
    	c.playerEquipment[c.playerShield] = -1;
    	c.playerEquipment[c.playerLegs] = -1;
    	c.playerEquipment[c.playerHands] = -1;
    	c.playerEquipment[c.playerFeet] = -1;
    	c.playerEquipment[c.playerRing] = -1;
    	c.playerEquipment[c.playerArrows] = -1;
    	c.getItems().addItem(helmet);
    	c.getItems().addItem(cape);
    	c.getItems().addItem(amulet);
    	c.getItems().addItem(weapon);
    	c.getItems().addItem(torso);
    	c.getItems().addItem(shield);
    	c.getItems().addItem(legs);
    	c.getItems().addItem(gloves);
    	c.getItems().addItem(boots);
    	c.getItems().addItem(rings);
    	c.getItems().addItem(arrows);
    } else {
    	c.sendMessage("You must have atleast 11 free slots in your inventory!");
    }
    1 bug I know there will be for sure if you do this:

    You will have only 1 arrow if you had any amount of arrows.

    Also, don't count on the variables that i called (like c.playerHands) to be correct. I told you, I haven't used the base in ages.

    EDIT: Yeah, follow what icandoit said.
    Attached image
    Attached image
    Quote Originally Posted by MrClassic View Post
    Arham is the official thanker!
    List of my work here!
    Reply With Quote  
     

  6. #6  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,092
    Thanks given
    2,402
    Thanks received
    2,823
    Rep Power
    4550
    Guy above is an idiot

    Code:
    case OBJECT_ID:
         int cape, hat;
         cape = c.playerEquipment[c.playerCape];
         hat = c.playerEquipment[c.playerHat];
         c.getItems().deleteEquipment(c.playerEquipment[c.playerCape], c.playerCape);
         c.getItems().deleteEquipment(c.playerEquipment[c.playerHat], c.playerHat);
         c.getItems().addItem(cape, 1);
         c.getItems().addItem(hat, 1);
    break;
    Code:
    public void deleteEquipment(int i, int j) {
    		synchronized (c) {
    			if (Server.playerHandler.players[c.playerId] == null) {
    				return;
    			}
    			if (i < 0) {
    				return;
    			}
    
    
    			c.playerEquipment[j] = -1;
    			c.playerEquipmentN[j] = c.playerEquipmentN[j] - 1;
    			c.getOutStream().createFrame(34);
    			c.getOutStream().writeWord(6);
    			c.getOutStream().writeWord(1688);
    			c.getOutStream().writeByte(j);
    			c.getOutStream().writeWord(0);
    			c.getOutStream().writeByte(0);
    			getBonus();
    			if (j == c.playerWeapon) {
    				sendWeapon(-1, "Unarmed");
    			}
    			resetBonus();
    			getBonus();
    			writeBonus();
    			c.updateRequired = true;
    			c.setAppearanceUpdateRequired(true);
    		}
    	}
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Jul 2013
    Posts
    48
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    Quote Originally Posted by Jason View Post
    Guy above is an idiot

    Code:
    case OBJECT_ID:
         int cape, hat;
         cape = c.playerEquipment[c.playerCape];
         hat = c.playerEquipment[c.playerHat];
         c.getItems().deleteEquipment(c.playerEquipment[c.playerCape], c.playerCape);
         c.getItems().deleteEquipment(c.playerEquipment[c.playerHat], c.playerHat);
         c.getItems().addItem(cape, 1);
         c.getItems().addItem(hat, 1);
    break;
    Code:
    public void deleteEquipment(int i, int j) {
    		synchronized (c) {
    			if (Server.playerHandler.players[c.playerId] == null) {
    				return;
    			}
    			if (i < 0) {
    				return;
    			}
    
    
    			c.playerEquipment[j] = -1;
    			c.playerEquipmentN[j] = c.playerEquipmentN[j] - 1;
    			c.getOutStream().createFrame(34);
    			c.getOutStream().writeWord(6);
    			c.getOutStream().writeWord(1688);
    			c.getOutStream().writeByte(j);
    			c.getOutStream().writeWord(0);
    			c.getOutStream().writeByte(0);
    			getBonus();
    			if (j == c.playerWeapon) {
    				sendWeapon(-1, "Unarmed");
    			}
    			resetBonus();
    			getBonus();
    			writeBonus();
    			c.updateRequired = true;
    			c.setAppearanceUpdateRequired(true);
    		}
    	}
    Thanks for this! Exactly what I needed! Rep for you!
    Reply With Quote  
     

  8. #8  
    (Official) Thanksgiver

    Arham's Avatar
    Join Date
    Jan 2013
    Age
    23
    Posts
    3,415
    Thanks given
    7,254
    Thanks received
    1,938
    Rep Power
    3905
    Quote Originally Posted by Jason View Post
    Guy above is an idiot

    Code:
    case OBJECT_ID:
         int cape, hat;
         cape = c.playerEquipment[c.playerCape];
         hat = c.playerEquipment[c.playerHat];
         c.getItems().deleteEquipment(c.playerEquipment[c.playerCape], c.playerCape);
         c.getItems().deleteEquipment(c.playerEquipment[c.playerHat], c.playerHat);
         c.getItems().addItem(cape, 1);
         c.getItems().addItem(hat, 1);
    break;
    Code:
    public void deleteEquipment(int i, int j) {
    		synchronized (c) {
    			if (Server.playerHandler.players[c.playerId] == null) {
    				return;
    			}
    			if (i < 0) {
    				return;
    			}
    
    
    			c.playerEquipment[j] = -1;
    			c.playerEquipmentN[j] = c.playerEquipmentN[j] - 1;
    			c.getOutStream().createFrame(34);
    			c.getOutStream().writeWord(6);
    			c.getOutStream().writeWord(1688);
    			c.getOutStream().writeByte(j);
    			c.getOutStream().writeWord(0);
    			c.getOutStream().writeByte(0);
    			getBonus();
    			if (j == c.playerWeapon) {
    				sendWeapon(-1, "Unarmed");
    			}
    			resetBonus();
    			getBonus();
    			writeBonus();
    			c.updateRequired = true;
    			c.setAppearanceUpdateRequired(true);
    		}
    	}
    I told you, I haven't used PI in a while lol...

    EDIT: But yeah, my way SUCKED.
    Attached image
    Attached image
    Quote Originally Posted by MrClassic View Post
    Arham is the official thanker!
    List of my work here!
    Reply With Quote  
     

  9. #9  
    Registered Member
    Join Date
    Jul 2013
    Posts
    48
    Thanks given
    2
    Thanks received
    0
    Rep Power
    11
    It worked perfectly hopefully I can ask this without making a new topic. Is there a way to disable equiping items in a certain area? (caps and hats)
    Reply With Quote  
     

  10. #10  
    Respected Member


    George's Avatar
    Join Date
    Mar 2009
    Posts
    7,099
    Thanks given
    2,226
    Thanks received
    3,146
    Rep Power
    5000
    Quote Originally Posted by RelentlessPK View Post
    All you'd need to do is just make more variables. Not sure if this is inefficient, but it works (even though I hate the modo, I'm not sure of any other way of how to do this (besides making a for loop)).
    Code:
    int weapon = 0;
    int helmet = 0;
    int amulet = 0;
    int cape = 0;
    int ammo = 0;
    int torso = 0;
    int shield = 0;
    int legs = 0;
    int boots = 0;
    int gloves = 0;
    int rings = 0;
    helmet = c.playerEquipment[c.playerHat];
    cape = c.playerEquipment[c.playerCape];
    amulet = c.playerEquipment[c.playerAmulet];
    weapon = c.playerEquipment[c.playerWeapon];
    torso = c.playerEquipment[c.playerChest];
    shield = c.playerEquipment[c.playerShield];
    legs = c.playerEquipment[c.playerLegs];
    gloves = c.playerEquipment[c.playerHands];
    boots = c.playerEquipment[c.playerFeet];
    rings = c.playerEquipment[c.playerRing];
    ammo = c.playerEquipment[c.playerArrows];
    if (player.getFreeSlots() >= 11) {
    	c.playerEquipment[c.playerHat] = -1;
    	c.playerEquipment[c.playerCape] = -1;
    	c.playerEquipment[c.playerAmulet] = -1;
    	c.playerEquipment[c.playerWeapon] = -1;
    	c.playerEquipment[c.playerChest] = -1;
    	c.playerEquipment[c.playerShield] = -1;
    	c.playerEquipment[c.playerLegs] = -1;
    	c.playerEquipment[c.playerHands] = -1;
    	c.playerEquipment[c.playerFeet] = -1;
    	c.playerEquipment[c.playerRing] = -1;
    	c.playerEquipment[c.playerArrows] = -1;
    	c.getItems().addItem(helmet);
    	c.getItems().addItem(cape);
    	c.getItems().addItem(amulet);
    	c.getItems().addItem(weapon);
    	c.getItems().addItem(torso);
    	c.getItems().addItem(shield);
    	c.getItems().addItem(legs);
    	c.getItems().addItem(gloves);
    	c.getItems().addItem(boots);
    	c.getItems().addItem(rings);
    	c.getItems().addItem(arrows);
    } else {
    	c.sendMessage("You must have atleast 11 free slots in your inventory!");
    }
    1 bug I know there will be for sure if you do this:

    You will have only 1 arrow if you had any amount of arrows.

    Also, don't count on the variables that i called (like c.playerHands) to be correct. I told you, I haven't used the base in ages.

    EDIT: Yeah, follow what icandoit said.
    You made me fucking cry.
    Attached image

    Spoiler for Spoilers!:
    Attached image
    Attached image
    Attached image
    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. Replies: 7
    Last Post: 09-01-2010, 07:20 AM
  2. Jew stars being removed - very offensive to me
    By Zahhak in forum Complaints
    Replies: 2
    Last Post: 07-02-2009, 08:11 AM
  3. Forcing map data to be sent...
    By Stanyer in forum RS 503+ Client & Server
    Replies: 35
    Last Post: 08-23-2008, 09:17 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
  •