Problem With Sensing Block

Discussion in 'Plugin Development' started by TheHandfish, May 14, 2014.

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

    TheHandfish

    Code:javascript
    1. if(checkFor(Material.PISTON_MOVING_PIECE, p, 1, 1, 1))
    2. {
    3. p.sendMessage("§2Player in line? " + p.getMetadata("playerInLine").get(0).asBoolean());
    4. if(Join.racing)
    5. {
    6. if(p.getLocation().getYaw() > -90 && p.getLocation().getYaw() < 90)
    7. {
    8. if(p.hasMetadata("playerLap") && p.hasMetadata("playerInLine"))
    9. {
    10. if(!p.getMetadata("playerInLine").get(0).asBoolean())
    11. {
    12. p.setMetadata("playerInLine", new FixedMetadataValue(plugin, true));
    13. int lap = p.getMetadata("playerLap").get(0).asInt();
    14. p.setMetadata("lap", null);
    15. int newLap = lap + 1;
    16. p.sendMessage("§bPlayer lap is now: " + newLap);
    17. }
    18. else
    19. {
    20. p.sendMessage("§6Failed PlayerInLine test.");
    21. }
    22. }
    23. else
    24. {
    25. p.sendMessage("§5Failed has metadata test.");
    26. }
    27. }
    28. else
    29. {
    30. p.damage(30.00);
    31. p.sendMessage("§4Near piston moving piece! - Wrong way!");
    32. }
    33. }
    34. }
    35. else
    36. {
    37. p.setMetadata("playerInLine", new FixedMetadataValue(plugin, false));
    38. }


    ^ My code. ^

    I'm trying to make it so when a player comes within range of a lap-marker, it checks to see if he's on the finish line and if he hasn't been before, it adds a lap (stored in Metadata), and marks him as on the line so he doesn't get laps added to him every time he moved while on the line. However, I keep getting the "Failed PlayerInLine test" which should be impossible. I set his metadata so I should be getting the message about what the player lap is now once. But I'm not. On player join, his metadata for PlayerInLine is set to false.

    Any help is appreciated. Thanks! :)
     
Thread Status:
Not open for further replies.

Share This Page