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

[NewAPI] Running commands once

Comments in 'Plugin Development' started by iFootball, Jul 3, 2014.

  1. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    Hello, iFootball again.
    I have a couple of questions,
    • 1 if you have a command in a if function like -
    PHP:
    if ($world === "World")
    Then a command giving the @player stake, how would you make it only give the player stake once?
    (I know theirs a separate function for a player entering a world but that's not the point.)
    • How would I make it so when a player enters 2 sets of coordinates a command is run? Like a box area. (The hole function)
    If anyone can give me both of these I'll include credit to them in my plugin,
    Thanks!
    [UPDATE] View GitHub here
    Last edited: Jul 4, 2014
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    1. Fix your spelling and grammar please.
    2. What do you mean "enter 2 sets of coords"?
    3. Run what command?
    4. A command in a if function?
    swagboy47 likes this.
  3. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    Do you know the answer to #3 in your list because I would like to know.
  4. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    1. Did
    2. A square/rectangular box
    3. Doesn't matter just want the function (It won't actually be a command)
    4. Yes, if (blah blah) {run blah blan)
    ShaderGamingYT likes this.
  5. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    Hey was that your 2,000th post?
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No. I deleted some posts.
    2. Learn about fields and sessioning.
    4. Yes, and if what then what?
  7. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    i really want help you but first you have to help me understand your question
  8. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    for 4 i think he is talking about playercommandprocess
  9. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    It doesn't really matter... If theirs a function that you would only want to run once (Like for example if you are in a area you don't want /give wood 64 run on you constantly but only as you enter the area)
    I'm making a plugin that runs a command on you as you enter a area.
  10. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    sorry . but i am half way done with that plugin . if you want to take it ( you are more then welcome ) :) . and for area select look at worldboarder
  11. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    Ok, can you at least tell me the function for player movement?
  12. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    entitymoveevent and it's an event . and depends on what you are doing you have to set the entity as player because entity is can be anything
    iFootball likes this.
  13. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    iFootball likes this.
  14. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    Ok thanks:). I'm having a hard time finding a example I can use for area select. I don't think World Border helped very much since its not the same select. I'm looking for something that I can connect the two sets of coordinates up (With variables) and do a if statement of if the entire is inside the two pairs of coordinates. Their is no area protecting plugins in the new API yet, and that's a need ;). Other than that I'm almost done, (We can compare codes swagboy, even though mine is probably worse:p)
  15. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    Just get the entities x and y coords. And run an if statement to see if the player's x is between the two set xs. And if that returns true, than do an if to see if the player's y is between the two ys.
  16. iFootball
    Offline

    iFootball Active Member

    Joined:
    Jun 9, 2014
    Posts:
    84
    Minecraft User:
    iFootball
    Already got the coords, and what would those if statements look like?
    PHP:
    if ($playerscoords $selectionx $playercoords)
    {.......}
    ? But their is 2 "x" & "y" coords for the selection.
  17. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    435
    Plugins:
    4
    Minecraft User:
    Lambo
    PHP:
    function onMove(EntityMoveEvent $event){if($event->getEntity() instanceof Player){
       
    $x1 //first x of the coords
       
    $x2 //second x of the coords
       
    $y1 //first y of the coords
       
    $y2 //second y of the coords
       
    $z1 //first z of the coords
       
    $z2 //second z of the coords
       
    $minx min($x1,$x2);
       
    $maxx max($x,$x2);
       
    $miny min($y1,$y2);
       
    $maxy max($y,$y2);
       
    $minz min($z1,$z2);
       
    $maxz max($z1,$z2);
       if(
    $event->getEntity()->getFloorX() >= $minx and $event->getEntity()->getFloorX() <= $maxx){
          if(
    $event->getEntity()->getFloorY() >= $miny and $event->getEntity()->getFloorY() <= $maxy){
             if(
    $event->getEntity()->getFloorY() >= $minz and $event->getEntity()->getFloorZ() <= $maxz)}
                
    //run code when player is in area
             
    }
          }
       }
    }}
    Something like this should work
    iFootball and Tuff like this.
  18. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    I was almost done with my own example, but you beat me to it. :p
    Well @iFootball, now that we've coded half the plugin for you I hope you know what to do.
    iFootball likes this.
  19. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    I don't think he wants the z, just x and y.
  20. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    he could use MYSQL (that's what i used
    Dinokiller likes this.

Share This Page

Advertisement