Dominate the flag problem

Discussion in 'Plugin Development' started by ExecuterMC, Jan 26, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    ExecuterMC

    Hi,
    i have a littel problem ... I want to make a game where you can conquere (flags) specified points when you're on it how can i do this?
    I thaugt about an array listwith a scheduler and a player move event is that a good idea?
     
    Last edited: Jan 26, 2017
  2. Offline

    Zombie_Striker

    @ExecuterMC
    You can either use Schedulers or PlayerMoveEvent. Every time it is triggered, check the player's location. If they are on the specified points, "conquer" them.

    If you need the player to stand on the area for a period of time before they conquer it, then use schedulers. If not, (if it's an instantaneous conquer), use PlayerMoveEvent.
     
  3. Offline

    ExecuterMC

  4. Offline

    mythbusterma

    @ExecuterMC

    You haven't even explained what you're trying to do well enough for us to understand, so we couldn't give you code even if we wanted to.
     
    ChipDev likes this.
  5. You might want to check the read me first sticky. We can't spoon feed you code, nor can we help you with a problem without all the details. Could you elaborate on your problem?


    Sent from my iPhone using Tapatalk
     
    ChipDev and Zombie_Striker like this.
  6. Offline

    ExecuterMC

    Ok i thaught about a check with the Player moveevent to get if he is near enough to a flag to make the count down tick...
    Some like that...
    Code:
    private ArrayList<String> nearbyP = new ArrayList<String>();
    private ArrayList<String> red = new ArrayList<String>();
    private ArrayList<String> blue = new ArrayList<String>();
    @EventHandler
    public void (PlayerMoveEvent e){
    Player p = e.getPlayer();
    for(Entity en : p.getNearbyEntity(5,5,5)){
       if(en.getType == EntityType.ARMOR_STAND){
           if(en.getCustumName().equals("flag"){
            
               if(!nearbyP.contains(p.getName()){
                 nearbyP.add(p.getName());
                 countdown(20,p.getName());
              }
          }
    }
    }else if(nearbyP.contains(p.getName()){
    nearbyP.remove(p.getName());
    }
    }
    public void countdown(long zeit,String name){
    if(nearbyP.contains(name)){
    int time = 0;
    Bukkit.getScheluders().
    .scheduleSyncRepeatingTask(this, new Runnable() {
    public void run() {
    time++;
    if(time == 10){
    if(red.contains("flag"){
    red.remove("flag");
    blue.add("flag");
    }
    if(blue.contains("flag"){
    blue.remove("flag");
    red.add("flag");
    }
    nearbyP.remove(name);
    break;
    }
    },0, zeit);
    
    }
    
    ? should it work?
     
    Last edited: Jan 28, 2017
  7. The best way to find out is to try


    Sent from my iPhone using Tapatalk
     
    ChipDev likes this.
  8. Offline

    JanTuck

    You could just make a scheduler and have a HashSet with all the flags in it and then check once in a while for nearby players. That might be less intensive on the server.
     
    ChipDev likes this.
  9. Offline

    ExecuterMC

    @JanTuck donĀ“t think so because it only has to do 1 "if" if the Player is not i rannge..
    I will try my version but if someone has a betterone feel free to post i;):D
    will spawn the armor stand with holograpics plugin
     
    Last edited: Jan 28, 2017
Thread Status:
Not open for further replies.

Share This Page