1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

setName

Discussion in 'Development' started by Teamblocket, Apr 15, 2017.

  1. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    hey , how can i set a name to a item the player is holding , thanks.
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    $player->getInventory()->getItemInHand()->setCustomName("custom name");
     
  3. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    can i do
    PHP:
    $player->getInventory()->getItemInHand()->setCustomName($name $level);
    ?
     
  4. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    What are $name and $level? If they are both strings, you just need to put a . in between them as a concatenation.
     
    HimbeersaftLP likes this.
  5. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    No you can not, even if the variables are defined correctly. Almost all functions in the PMMP API return a clone of the object you want to use, not the actual object. This means, that you have to remove the original item, and then add the renamed item to the inventory. If you don't do this, nothing will happen.
     
    jasonwynn10 and HimbeersaftLP like this.
  6. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    I think he's referring to custom spells
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.