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

Make player set a position

Comments in 'Plugin Development' started by GoldenSteveyt, Aug 8, 2015.

  1. GoldenSteveyt
    Offline

    GoldenSteveyt New Member

    Joined:
    Aug 5, 2015
    Posts:
    12
    Minecraft User:
    D4nl0g
    Hello Guys, im developing a Plugin but, i need a position set and then get the area set, how can i do that? please, help, its urgent i have tried it, but i can't find out how to do it! PLEASE!!!

    public function onCommand(\pocketmine\command\CommandSender $sender, \pocketmine\command\Command $command, $label, array $args) {
    $name = $player->getDisplayName();
    if($name == D4nl0g){
    switch (strtolower($command->getUsage())){
    case 'setpos1':
    $this->
    }

    Thats my code so far :(
  2. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Hi :)
    1. $name will not be defined cuz it will crash on that part!
    PHP:
    // You used
    $player
    // instead of
    $sender
    2. Why you use $player->getDisplayName()? use $player->getName();
    3. switch($command->getName()); Not ->getUsage();
    4. :
    PHP:
    $this->positions = array();

    public function 
    onCommand(...){
    switch(...){
    case 
    "setpos1":
    $this->positions[$sender->getName()]['pos1'] = $sender->getPosition();
    $sender->sendMessage('First position set to: '.$sender->getFloorX().":".$sender->getFloorY().":".$sender->getFloorZ().".");
    return 
    true;
    }
    }
    5. Use
    PHP:
    So we could read code easier! :)
  3. GoldenSteveyt
    Offline

    GoldenSteveyt New Member

    Joined:
    Aug 5, 2015
    Posts:
    12
    Minecraft User:
    D4nl0g
    On switch i need to put
    Code:
    switch (strtolower($command->getName())) {
    ?
  4. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Please learn PHP and the PocketMine API.
  5. GoldenSteveyt
    Offline

    GoldenSteveyt New Member

    Joined:
    Aug 5, 2015
    Posts:
    12
    Minecraft User:
    D4nl0g
    I want, but i can't find where to study it, all youtube videos suck
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    RekkuzaRage likes this.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Please learn PHP. You lack knowledge even in the most fundamental parts of PHP.
    RekkuzaRage likes this.
  8. GoldenSteveyt
    Offline

    GoldenSteveyt New Member

    Joined:
    Aug 5, 2015
    Posts:
    12
    Minecraft User:
    D4nl0g
    No, i know PHP, i made plugins, but only arguments with $sender and broadcastmessage and things like that
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    That isn't PHP. Those are only parts of how to make a plugin, but that isn't even coding because you don't even what they mean.
    If you so, you would spot the lack of quotes in the very first case.
    Legoboy0215 likes this.

Share This Page

Advertisement