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

Positions and Arrays

Comments in 'Plugin Development' started by SuperChipsLP, Jan 25, 2014.

  1. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Hey Guys!

    I have a little question:

    When i do:

    PHP:
    $x $data->x;
    $y $data->y;
    $z $data->z;

    $this->api->chat->broadcast($x."-".$y."-".$z);
    within the player.move handler, i get strings like these:

    87.768493652344-4-143.30000305176

    How do i just get the ones before the . ?

    Thanks.

    Edit: I know this will spam the chat. It is just for testing purposes. ;)
    Edit 2: And i have fixed the Array Problem i had. :)
    Last edited: Jan 25, 2014
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $integer=(int)$decimalOrAnyNumberInStringForm;
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    What array?
  4. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Read the last line of my post. Thanks for your help. :)
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I read. I was asking about what you tried to say
  6. wies
    Offline

    wies Notable Member

    Joined:
    Aug 23, 2013
    Posts:
    392
    Use round($num) for this purpose because (int)$num will round 1.9999 to 1 instead of 2
  7. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Oh. I didn't get it to save it to an array. But i have fixed that. :)
  8. SuperChipsLP
    Offline

    SuperChipsLP Active Member Plugin Developer

    Joined:
    Sep 15, 2013
    Posts:
    204
    Plugins:
    5
    Minecraft User:
    Redmol
    Ok.I will use that instead.
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    but if you want to get the coords of the block the player has his feet in, use the (int) method to get the floor of the doubles, not round.
    wies likes this.

Share This Page

Advertisement