Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[old api] count items

Comments in 'Plugin Development' started by swagboy47, Jun 26, 2014.

  1. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    how do you count how many blocks/items in the player's hand ?
  2. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    anybody know's ?
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What event is it? You can always track the change and save it in your memory if it is player.equipment.change, and you can get the item object by $data["item"] if the event is player.block.*** or player.equipment.change, and you can get the count by $item->count (not sure if it is public field. Or check economys airport for examples).
  4. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    It is public :)
    PEMapModder likes this.
  5. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    What about player.action? And you used the player slot
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Look at TPCompass then
  7. Killman2
    Offline

    Killman2 Active Member Plugin Developer

    Joined:
    May 5, 2014
    Posts:
    81
    Plugins:
    1
    Minecraft User:
    Killman2
    Player action is when you just take an item and long tap to the screen. This won't work in this case. So, most likely, you should use player.equipment.change
  8. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    it doesn't work out for me :(. i am doing a plugin called eateverything . and i should use player.action
  9. Killman2
    Offline

    Killman2 Active Member Plugin Developer

    Joined:
    May 5, 2014
    Posts:
    81
    Plugins:
    1
    Minecraft User:
    Killman2
    Oh, I see what you want to do) when you have an item and "act" with it, it cleans your inventory and heals you, right?
  10. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    not heal you but it gives you special effects
  11. Killman2
    Offline

    Killman2 Active Member Plugin Developer

    Joined:
    May 5, 2014
    Posts:
    81
    Plugins:
    1
    Minecraft User:
    Killman2
    Well , for cleaning inventory just use

    PHP:
          public function inventoryClean($cmd$params$issuer$alias$args$issuer)
          {
             
    $username $params[0];
             if(
    $username === '' && $username === null)
                return 
    "use /inventory clean ";

             
    $player $this->api->player->get($username);
             if(! (
    $player instanceof Player) and ! ($player->entity instanceof Entity)) {
    return 
    "player not found.";
             }
             
    $player->inventory = array();
             
    $player->sendInventory();
          }

          
  12. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    i want clean a certian amount and in one slot not the whole inv
  13. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Last time... Use isset() not $params[0]!
  14. Killman2
    Offline

    Killman2 Active Member Plugin Developer

    Joined:
    May 5, 2014
    Posts:
    81
    Plugins:
    1
    Minecraft User:
    Killman2
    Whyyyy? )
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If the player doesn't give any parameters, $args[0] will be not defined. It will still work, but with an E_NOTICE level error.

Share This Page

Advertisement