Problem with setting the activation of mini-games alternately.

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

krzywy

Member
Oct 26, 2024
1
0
1
Error:
Line 12:
Can't understand this structure: set {currentGame} to 1
Line: set {currentGame} to 1


Code:
options:
    # Settings for the first game (guessing the word)
    words: "ZoAtIx, tEmPeRoWkA, MiNeCrAfT, creeper, oLowek, diAmEEnty, SzkIelEt, prawnIk, twiTCH, doNAte, krzYwYGoat, JasperBeka, stReam, spELL, GoLFik, MuREK, RaTAYhui, SzczEbrzeSZyN, RoCketSsie, RakIEtowaLiGA"  # Words to draw from
    responseTime: 30 seconds  # Time for responses
    rewardAmount: 1000  # Reward for winning
    
    # Settings for the second game (guessing the number)
    min-number: 1  # Minimum number
    max-number: 100  # Maximum number


# Variable to control which game is active (1 - guessing number, 2 - guessing word)
set {currentGame} to 1


every 15 minutes:  # Every 15 minutes
    if {currentGame} is 1:  # Check if the current game is guessing the number
        # Start guessing the number
        set {game.number} to random integer between {@min-number} and {@max-number}  # Draw a number
        broadcast "&8--------"
        broadcast "&e&lMini game&r &6> &aGuess the number from &c{@min-number} to {@max-number}!&r &a(You have 30 seconds!)"
        broadcast "&8--------"
        execute console command "say The number to guess is: %{game.number}%"  # Display the number in the console
        set {game.active} to true  # Activate the game
        delete {game.winner}  # Ensure there is no previous winner
        wait 30 seconds  # Time for responses
        if {game.active} is true:  # Check if the game is still active
            set {game.active} to false  # Deactivate the game
            if {game.winner} is not set:
                broadcast "&8--------"
                broadcast "&e&lMini game&r &6> &4Time's up! No one guessed the number: &c%{game.number}%&4!"
                broadcast "&8--------"
            else:
                set {_winner} to {game.winner}
                broadcast "&aCongratulations to %{_winner}% for guessing the number! You receive {@rewardAmount}!"
                
        # Set a new game for guessing the word
        set {currentGame} to 2  # Set the current game to guessing the word


    else:  # If the current game is guessing the word
        # Start guessing the word
        set {game.active} to true  # Activate the game
        set {_words::*} to split {@words} by ", "  # Split words into an array
        set {_randomIndex} to random integer between 1 and size of {_words::*}  # Draw an index
        set {lastWord} to {_words::%{_randomIndex}%}  # Get the word based on the random index


        broadcast "&8--------"
        broadcast "&e&lMini game&r &6> &aWho will be the first to write the correct word: &c%{lastWord}%&a? (you have 30 seconds!)"
        broadcast "&8--------"


        wait {@responseTime}  # Time for responses
        if {game.active} is true:  # Check if the game is still active
            set {game.active} to false  # Deactivate the game
            
            broadcast "&8--------"
            broadcast "&e&lMini game&r &6> &4Time's up! No one wrote the word: &c%{lastWord}%&4!"
            broadcast "&8--------"
        
        # Set a new game for guessing the number
        set {currentGame} to 1  # Set the current game to guessing the number


# Events for guessing the number
on chat:
    if {game.active} is true:
        if {currentGame} is 1:  # Check if the current game is guessing the number
            set {_guessedNumber} to message parsed as number
            if {_guessedNumber} is not set:
                stop  # Stop further execution of the script
            if {_guessedNumber} = {game.number}:  # Check if the guessed number is correct
                set {game.winner} to player's name  # Set the winner
                
                broadcast "&8--------"
                broadcast "&e&lMini game&r &6> &6%player% &a guessed the correct number: &n&c%{game.number}%&r&a first!"
                broadcast "&8--------"
                
                execute console command "eco give %player% {@rewardAmount}"  # Grant the reward
                set {game.active} to false  # Deactivate the game after winning
                cancel event  # Cancel the message


# Events for guessing the word
on chat:
    if {game.active} is true:
        if {currentGame} is 2:  # Check if the current game is guessing the word
            if message matches {lastWord}:  # Check if the message is the correct word, considering case sensitivity
                
                broadcast "&8--------"
                broadcast "&e&lMini game&r &6> &6%player% &a wrote the correct word: &n&c%{lastWord}%&r&a first!"
                broadcast "&8--------"
                
                execute console command "eco give %player% {@rewardAmount}"  # Grant the reward
                set {game.active} to false  # Deactivate the game after winning
                cancel event  # Cancel the message
 
The problem is that the line of code (12) isn't connected to anything. You should add an "on join:" or "on every (second/minute/tick/hour/day):" for Skript to know when to set {currentGame} to 1.
 
  • Like
Reactions: krzywy