Jump to content

Chat Reaction Game


Dead07

Recommended Posts

Basically a game where a phrase is randomly chosen from the reaction list and then each word is scrambled and the players have to guess the correct unscrambled phrase within a time limit. You need to add phrases yourself as the list starts with nothing.
 

Commands (permission required = skript.chatreaction):

/chatreaction add [phrase] - adds a new phrase
/chatreaction remove [phrase] - removes an existing phrase
/chatreaction list - lists all current phrases
/chatreaction time [seconds] - sets the time limit of the game, range is 1-60 seconds

Code:

options:
    prefix: &7[&9&lGAME&7] &f➯

on load:
    delete {chatReaction}
    delete {chatReactionTime}

command /chatreaction [<string>] [<string>]:
    trigger:
        if player has permission "skript.chatreaction":
            if arg 1 is set:
                if arg 1 is "add":
                    if arg 2 is set:
                        if {chatReaction::*} doesn't contain arg 2:
                            add arg 2 to {chatReaction::*}
                            send "{@prefix} &e&l%arg 2% &fhas been added to chat reactions!"
                        else:
                            send "{@prefix} &e&l%arg 2% &fis already a chat reaction!"
                    else:
                        send "{@prefix} Enter a chat reaction to add!"
                else if arg 1 is "remove":
                    if arg 2 is set:
                        if {chatReaction::*} contains arg 2:
                            remove arg 2 from {chatReaction::*}
                            send "{@prefix} &e&l%arg 2% &fhas been removed from chat reactions!"
                        else:
                            send "{@prefix} &e&l%arg 2% &fisn't a chat reaction!"
                    else:
                        send "{@prefix} Enter a chat reaction to add!"
                else if arg 1 is "list":
                    loop {chatReaction::*}:
                        send "&f%loop-iteration%: &e%loop-value%"
                else if arg 1 is "time":
                    if arg 2 is set:
                        set {_time} to arg 2 parsed as integer
                        if {_time} is set:
                            if {_time} <= 60:
                                if {_time} > 0:
                                    set {chatReactionTimeLimit} to {_time}
                                    send "{@prefix} Chat reaction time limit is now &e&l%{_time}%&f seconds!"
                                else:
                                    send "{@prefix} Valid time limit range is 1-60 seconds!"
                            else:
                                send "{@prefix} Valid time limit range is 1-60 seconds!"
                        else:
                            send "{@prefix} That is not a valid time limit (in seconds)!"
                    else:
                        send "{@prefix} Enter a time limit in seconds!"
                else:
                    send "", "&e/chatreaction add [phrase]", "", "&e/chatreaction remove [phrase]", "", "&e/chatreaction list &f- list all phrases", "", "&e/chatreaction time [seconds] &f- set time limit of game" and ""
            else:
                send "", "&e/chatreaction add [phrase]", "", "&e/chatreaction remove [phrase]", "", "&e/chatreaction list &f- list all phrases", "", "&e/chatreaction time [seconds] &f- set time limit of game" and ""

every 10 minutes:
    set {_size} to size of {chatReaction::*}
    set {_i} to random integer between 1 and {_size}
    set {chatReaction} to {chatReaction::%{_i}%}
    set {_reaction::*} to split "%{chatReaction}%" at " "
    loop {_reaction::*}:
        set {_x} to 1
        loop (length of loop-value) times:
            add (character at {_x} in "%loop-value-1%") to {_chars::*}
            add 1 to {_x}
        loop (size of {_chars::*}) times:
            set {_char} to random element out of {_chars::*}
            remove {_char} from {_chars::*}
            add "%{_char}%" to {_joinString::*}
        set {_word} to join {_joinString::*} by "" in lowercase
        add "%{_word}%" to {_words::*}
        delete {_joinString::*}
    set {_reaction} to join {_words::*} by " "
    broadcast "{@prefix} Unscramble &e&l%{_reaction}% &fwithin %{chatReactionTimeLimit}% seconds for a reward!"
    set {_loop} to {chatReactionTimeLimit} * 20
    loop {_loop} times:
        if {chatReaction} is set:
            wait 1 tick
            add 0.05 to {chatReactionTime}
        else:
            exit loop
    if {chatReaction} is set:
        broadcast "{@prefix} No one was able to unscramble &e&l%{chatReaction}% &f:("
        delete {chatReaction}
        delete {chatReactionTime}

on chat:
    if {chatReaction} is set:
        if message contain "%{chatReaction}%":
            broadcast "{@prefix} &e&l%player% &funscrambled &e&l%{chatReaction}% &fin &e&l%{chatReactionTime}% &fseconds!"
            
            # add prize here

            delete {chatReaction}
            delete {chatReactionTime}

 

Edited by Dead07

Discord: dead_is4

Anime Enthusiast!


Solo Leveling GIF - Solo Leveling - Discover & Share GIFs

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...