sign.started(gamesignloc); rankingtable = "buttonranks"; game_short = "button"; event.load("block_click"); event.load("player_logout"); event.load("player_giveup"); event.load("player_join"); event.load("living_pre_hurt"); clicked = 0; checked = 0; tfn = 5; //timeForNext in sec factor = 0.98; //Faktor, um den tfn vermindert wird sgoto(tfn * 20, "gameover"); gamename = "§2Buttons"; @nextbutton while(toclick == lastclick) { toclick = list.getIndex(buttons, math.random(0, list.getSize(buttons) - 1)); } if(direction == "x") { markedloc = loc.mod(toclick, number, 0, 0); block.set(markedloc, markblock); } elseif(direction == "z") { markedloc = loc.mod(toclick, 0, 0, number); block.set(markedloc, markblock); } @wait wait(); if(event == "living_pre_hurt") { if(!isPlayer(living_entity)) { goto("wait"); } player = living_entity; } if(player.hasMinigameId(player, script_id)) { ignoreGoto(event); } goto("wait"); @player_join entity.teleport(player, spawn_loc); living.setHealth(player, 20); player.setHunger(player, 20); player.setSaturation(player, 5); player.clearInventory(player); display.reset(player); display.add(player, 1, gamename); display.add(player, 2, "Time for next click:"); display.add(player, 3, math.roundComma(tfn, 2)); status.addTimed(player, 0, tfn * 20, "Timer"); display.add(player, 4, "Points: ", text.number(clicked)); msg.prefix(player, "§2Buttons", "Click the correct button in time."); gameover_player = player; goto("wait"); @living_pre_hurt cancel = true; goto("wait"); @block_click cancel = true; if(block_loc == toclick) { tfn *= factor; tfn = math.roundComma(tfn, 2); display.add(player, 3, tfn); status.addTimed(player, 0, tfn * 20, "Timer"); display.add(player, 4, "Points: ", text.number(++clicked)); sgoto(tfn * 20, "gameover"); block.set(markedloc, originblock); lastclick = toclick; goto("nextbutton"); } else { msg.prefix(player, gamename, "You clicked the wrong button."); goto("coregameover"); } goto("wait"); @gameover player = gameover_player; if(++checked > clicked) { msg.prefix(player, gamename, "You were too slow."); goto("coregameover"); } goto("wait"); @coregameover player_id = player.getId(player); playedgames = minigame.getPlayed(player_id, game_short) + 1; minigame.setPlayed(player_id, game_short, playedgames); last_record = ranking.getPoints(rankingtable, player_id); if(last_record < clicked) { record = clicked; diff = clicked - last_record; } else { record = last_record; } ranking.setPoints(rankingtable, player_id, record); minigame.statsHeader(player, gamename, "§e"); minigame.statsLine(player, "§e", "Points", text.number(clicked)); minigame.statsLine(player, "§e", "Your record", text.number(last_record)); if(diff != null) { msg(player, " §e- §rBeat own record by §e", text.number(diff)); } minigame.statsLine(player, "§e", "Played games", text.number(playedgames)); money.addBoost(player, math.round(clicked / 4)); @player_giveup @player_logout block.set(markedloc, originblock); script = script.getFromId(script_id); minigame.kickPlayer(script, player); minigame.term(script, gamesignloc); term();