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

Player telepor to random xyz

Discussion in 'Facepalm' started by WreckagePE / ZAYD, May 9, 2017.

  1. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    I want to foreach all players and teleport them randomly each around the world, but their x and y has to be less then 5000
    edit: there x and z has to be less than 5000
     
  2. Intyre

    Intyre Administrator Staff Member PMMP Team

    Messages:
    81
    GitHub:
    Intyre
    I want cake!
    PHP:
    foreach $all->players
        
    if and 5000
            teleportRandomAroundTheWorld
    ()
     
  3. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    I do too.... what the hell
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    But the cake is a lie!
    hint: mt_rand
     
  5. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    PHP:
    $x mt_rand(0,5000);
    $z mt_rand(0,5000);
    $y 50;
    $player->teleport($x$y$z);
    //Or is it vector3?
     
  6. Intyre

    Intyre Administrator Staff Member PMMP Team

    Messages:
    81
    GitHub:
    Intyre
    Or is it not a vector3? Who knows? :eek:
    :facepalm:
    if source was available and people could read it then it would be much better..... oh IT IS!
     
  7. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    oh wait of course coordinates does not have negative integer what am i talking about anyways??
     
  8. Intyre

    Intyre Administrator Staff Member PMMP Team

    Messages:
    81
    GitHub:
    Intyre
    coordinates only have negative intyres!
     
  9. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
    You are confusing me. :(
     
  10. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Given the information above, you only need to see this to answer your question about whether or not it needs a Vector3. As Intyre was trying to say, everything is in the source code(and in the API docs) that you will need regarding PM methods. Just learn to find them. Learning to find your own answers will benefit everyone.
     
  11. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    other information is that player can teleport -5000 as well as +5000 blocks
    I would recommend setting the y coord to the highest non-air block at those x/z coords to make sure they don't suffocate
     
  12. WreckagePE / ZAYD

    WreckagePE / ZAYD Slime

    Messages:
    82
  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.