Thread: How To Check if Player Is Holding Something

Results 1 to 7 of 7
  1. #1 How To Check if Player Is Holding Something 
    Registered Member
    Join Date
    Apr 2018
    Posts
    13
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    So I was wondering, how do I check wether a player is holding a specific weapon?
    I tried playing around with this

    Code:
    if(player.getEquipment().update(Slot.WEAPON, ));
    But it didnt get me very far
    Reply With Quote  
     

  2. #2  
    Blurite

    Corey's Avatar
    Join Date
    Feb 2012
    Age
    26
    Posts
    1,491
    Thanks given
    1,245
    Thanks received
    1,729
    Rep Power
    5000
    likely something along the lines of
    Code:
    player.getEquipment().contains(...)
    Attached image
    Reply With Quote  
     

  3. #3  
    Registered Member 8109's Avatar
    Join Date
    Mar 2018
    Posts
    37
    Thanks given
    10
    Thanks received
    9
    Rep Power
    11
    of course it depends on your source which you haven't provided but will be along the lines of what Tesla said above. If you use an IDE (eclipse, intelliji) you can type

    Code:
    player.getEquipment().
    (type it not copy and paste it), and a list of available methods will pop up after the period. Of course if you don't have player declared or your source does not contain these methods then it won't, but that should be self explanatory.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Apr 2018
    Posts
    13
    Thanks given
    0
    Thanks received
    0
    Rep Power
    11
    With a bit of some trial and error I managed to fix it if anyone else is wondering here is the code.

    Code:
    if(c.getItems().isWearingItem(tboww.getId())) {
    			c.sendMessage("Player is wearing Twisted Bow!");
    		}else {
    			c.sendMessage("Player is not wearing a Twisted Bow!");
    		}
    Reply With Quote  
     

  5. #5  
    Respected Member


    Join Date
    Jan 2009
    Posts
    5,743
    Thanks given
    1,162
    Thanks received
    3,603
    Rep Power
    5000
    Quote Originally Posted by BananaSplit View Post
    With a bit of some trial and error I managed to fix it if anyone else is wondering here is the code.

    Code:
    if(c.getItems().isWearingItem(tboww.getId())) {
    			c.sendMessage("Player is wearing Twisted Bow!");
    		}else {
    			c.sendMessage("Player is not wearing a Twisted Bow!");
    		}
    does isWearingItem not take slot? Seeing as isWearingItem will be looping all equipment when it doesn't need to, can do c.playerEquipment[3] == tboww.getId()
    Reply With Quote  
     

  6. #6  
    Registered Member 8109's Avatar
    Join Date
    Mar 2018
    Posts
    37
    Thanks given
    10
    Thanks received
    9
    Rep Power
    11
    Code:
    if(c.getItems().isWearingItem(tboww.getId())) {
    is the same as

    Code:
    player.getEquipment().contains(...)
    just different method names
    Reply With Quote  
     

  7. #7  
    Banned

    Join Date
    Nov 2014
    Posts
    611
    Thanks given
    180
    Thanks received
    156
    Rep Power
    0
    I'm so glad im done with pi
    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: 2
    Last Post: 08-26-2014, 12:41 AM
  2. How to check if a signature/tag is ripped
    By nudiustertian in forum Tutorials
    Replies: 1
    Last Post: 05-21-2013, 02:48 PM
  3. [PI] How to check if a familiar is a players
    By Spencer4678 in forum Help
    Replies: 9
    Last Post: 04-26-2012, 06:19 AM
  4. [PI] How to check if inventory is empty?
    By Shaqattack118. in forum Help
    Replies: 1
    Last Post: 06-30-2011, 08:25 PM
  5. How to: Check if a login is vulnerable to SQL Injection
    By Zixt2 in forum Website Development
    Replies: 8
    Last Post: 01-16-2009, 12:17 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
  •