Solved Time change vote system not working

  • 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 comminuty!

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Status
Not open for further replies.

AndrewKopera

Member
Mar 18, 2021
18
0
1
23
Hello.
I've been working on time change vote system for my server. But i have a problem. The problem is that people can spam yes/no cmds. How do i solve this? I tried using names and uuids but nothing. (dont mind the language)
Thanks
Code:
Code:
variables:
    {hlasovani::ano} = 0
    {hlasovani::ne} = 0
    {hlasovani::povoleno} = 1
    {hlasovani::probiha} = 0

command /cas [<text>]:
    trigger:
        if arg 1 is "help":
            if player has permission "narra.hlasovani.clear":
                send "&c&l/cas den &6-Začne hlasování o změnu času na <##274666>&lDen." to player
                send "&c&l/cas noc &6-Začne hlasování o změnu času na <##274666>&lNoc." to player
                send "&c&l/cas ano &6-Příkaz k hlasování pro ne." to player
                send "&c&l/cas ne &6-Příkaz k hlasování pro ne." to player
                send "&c&l/cas hlasy &6-Vypíše počet hlasů." to player
                send "&c&l/cas clear &6- &a&lModerator only &6příkaz. Resetuje počet hlasů." to player
                stop
            else:
                send "&c&l/cas den &6-Začne hlasování o změnu času na <##274666>&lDen." to player
                send "&c&l/cas noc &6-Začne hlasování o změnu času na <##274666>&lNoc." to player
                send "&c&l/cas ano &6-Příkaz k hlasování pro ne." to player
                send "&c&l/cas ne &6-Příkaz k hlasování pro ne." to player
                send "&c&l/cas hlasy &6-Vypíše počet hlasů." to player
                stop
                
        if arg 1 is not set:
            make player execute command "cas help"
            stop
        if arg 1 is "?":
            make player execute command "cas help"
            stop
        if arg 1 is "den":
            if {hlasovani::povoleno} is 1:
                broadcast "&6&oHráč <##274666>&l%player% &6&ozačal hlasování o změně času na <##274666>&l%arg-1%&6&o%newline%Použijte <##274666>&l/cas ano &6&onebo <##274666>&l/cas ne &6&opro hlasování.%newline%Čas na hlasování:<##274666>&l60 &6&osekund"
                add 1 to {hlasovani::ano}
                set {hlasovani::probiha} to 1
                set {hlasovani::povoleno} to 0
                add player's uuid to {hlasoval::ano}
                wait 50 seconds
                broadcast "&6&oHlasování o změně času končí za <##274666>&l10 &6&osekund."
                wait 7 seconds
                broadcast "&6&oHlasování o změně času končí za <##274666>&l3 &6&osekundy."
                wait 1 second
                broadcast "&6&oHlasování o změně času končí za <##274666>&l2 &6&osekundy."
                wait 1 second
                broadcast "&6&oHlasování o změně času končí za <##274666>&l1 &6&osekundu."
                wait 1 second
                if {hlasovani::ano} is greater than {hlasovani::ne}:
                    remove player's uuid from {hlasoval::ano}
                    set time in world to 06:00
                    broadcast "&6&oHlasování o změně času <##274666>&lprošlo."
                    broadcast "&6&oČas byl změněn na %arg-1%."
                    broadcast "&6&oDalší hlasování bude povolené za <##274666>&l60 &6&osekund."
                    set {hlasovani::ano} to 0
                    set {hlasovani::ne} to 0
                    set {hlasovani::probiha} to 0
                    wait 60 seconds
                    set {hlasovani::povoleno} to 1
                    stop
                if {hlasovani::ne} is greater than {hlasovani::ano}:
                    remove player's uuid from {hlasoval::ano}
                    broadcast "&6&oHlasování o změně času <##274666>&lneprošlo."
                    broadcast "&6&oDalší hlasování bude povolené za <##274666>&l60 &6&osekund."
                    set {hlasovani::ano} to 0
                    set {hlasovani::ne} to 0
                    set {hlasovani::probiha} to 0
                    wait 60 seconds
                    set {hlasovani::povoleno} to 1
                    stop
            else:
                send "&c&oMomentálně nemůžeš začít hlasování." to player
                stop
        if arg 1 is "noc":
            if {hlasovani::povoleno} is 1:
                broadcast "&6&oHráč <##274666>&l%player% &6&ozačal hlasování o změně času na <##274666>&l%arg-1%&6&o%newline%Použijte <##274666>&l/cas ano &6&onebo <##274666>&l/cas ne &6&opro hlasování.%newline%Čas na hlasování:<##274666>&l60 &6&osekund"
                add 1 to {hlasovani::ano}
                set {hlasovani::probiha} to 1
                set {hlasovani::povoleno} to 0
                add player's uuid to {hlasoval::ano}
                wait 50 seconds
                broadcast "&6&oHlasování o změně času končí za <##274666>&l10 &6&osekund."
                wait 7 seconds
                broadcast "&6&oHlasování o změně času končí za <##274666>&l3 &6&osekundy."
                wait 1 second
                broadcast "&6&oHlasování o změně času končí za <##274666>&l2 &6&osekundy."
                wait 1 second
                broadcast "&6&oHlasování o změně času končí za <##274666>&l1 &6&osekundu."
                wait 1 second
                if {hlasovani::ano} is greater than {hlasovani::ne}:
                    remove player's uuid from {hlasoval::ano}
                    set time in world to 20:00
                    broadcast "&6&oHlasování o změně času <##274666>&lprošlo."
                    broadcast "&6&oČas byl změněn na %arg-1%."
                    broadcast "&6&oDalší hlasování bude povolené za <##274666>&l60 &6&osekund."
                    set {hlasovani::ano} to 0
                    set {hlasovani::ne} to 0
                    set {hlasovani::probiha} to 0
                    wait 60 seconds
                    set {hlasovani::povoleno} to 1
                    stop
                if {hlasovani::ne} is greater than {hlasovani::ano}:
                    remove player's uuid from {hlasoval::ano}
                    broadcast "&6&oHlasování o změně času <##274666>&lneprošlo."
                    broadcast "&6&oDalší hlasování bude povolené za <##274666>&l60 &6&osekund."
                    set {hlasovani::ano} to 0
                    set {hlasovani::ne} to 0
                    set {hlasovani::probiha} to 0
                    wait 60 seconds
                    set {hlasovani::povoleno} to 1
                    stop
            else:
                send "&c&oMomentálně nemůžeš začít hlasování." to player
                stop
        if arg 1 is "hlasy":
            send "&6&lHlasy pro změnu času." to player
            send "&6&oSouhlas: <##274666>&l%{hlasovani::ano}%" to player
            send "&6&oNesouhlas: <##274666>&l%{hlasovani::ne}%" to player
        if arg 1 is "clear":
            if player has permission "narra.hlasovani.clear":
                set {hlasovani::ano} to 0
                set {hlasovani::ne} to 0
                send "&a&lHlasy resetovány." to player
                stop
            if player doesn't have permission "narra.hlasovani.clear":
                send "&cNa tento příkaz nemáš povolení." to player
                stop
        if arg 1 is "ano":
            if {hlasovani::probiha} is 1:
                if {hlasovani::ano} contains player's uuid:
                    send "&6Nemůžeš znovu hlasovat." to player
                    stop
                if {hlasovani::ne} contains player's uuid:
                    send "&6&oZměnil jsi svůj hlas z &c&lNe &6&ona &a&lAno."
                    add 1 to {hlasovani::ano}
                    remove 1 from {hlasovani::ne}
                    remove player's uuid from {hlasoval::ne}
                    add player's uuid to {hlasoval::ano}
                    wait 60 seconds
                    remove player's uuid from {hlasoval::ano}
                    stop
                if {hlasovani::ano} doesn't contain player's uuid:
                    send "&6Hlasoval jsi pro &a&lAno." to player
                    add player's uuid to {hlasoval::ano}
                    add 1 to {hlasovani::ano}
                    wait 60 seconds
                    remove player's uuid from {hlasoval::ano}
                    stop
            if {hlasovani::probiha} is 0:
                send "&c&oMomentálně neprobíhá hlasování."
                stop
        if arg 1 is "ne":
            if {hlasovani::probiha} is 1:
                if {hlasovani::ne} contains player's uuid:
                    send "&6Nemůžeš znovu hlasovat." to player
                    stop
                if {hlasovani::ano} contains player's uuid:
                    send "&6&oZměnil jsi svůj hlas z &a&lAno &6&ona &c&lNe."
                    add 1 to {hlasovani::ne}
                    remove 1 from {hlasovani::ano}
                    remove player's uuid from {hlasoval::ano}
                    add player's uuid to {hlasoval::ne}
                    wait 60 seconds
                    remove player's uuid from {hlasoval::ne}
                    stop
                if {hlasovani::ne} doesn't contain player's uuid:
                    send "&6Hlasoval jsi pro &c&lNe." to player
                    add player's uuid to {hlasoval::ne}
                    add 1 to {hlasovani::ne}
                    wait 60 seconds
                    remove player's uuid from {hlasoval::ne}
                    stop
            if {hlasovani::probiha} is 0:
                send "&c&oMomentálně neprobíhá hlasování."
                stop
        if arg 1 is "debug":
            set {hlasovani::povoleno} to 1
            set {hlasovani::probiha} to 0
            stop
        if arg 1 is "status":
            send "status hlasovani:%{hlasovani::povoleno}%"
        if arg 1 is "cmdtest":
            set time in world to 06:00
 
if you are making a list of player UUIDs, or want to check a list, be sure to have a ::* at the end of your variable name.

so "add player's uuid to {hlasoval::ano}" should be add player's uuid to {hlasoval::ano::*}
so that skript knows it is a list of variables, and not just one variable.

to compare the amount of players in that list you can use 'if size of {list varriable 1::*} is greater/smaller/equal to <number> :'
or even use a 2nd 'size of {listvariable::*}' as <number>
 
if you are making a list of player UUIDs, or want to check a list, be sure to have a ::* at the end of your variable name.

so "add player's uuid to {hlasoval::ano}" should be add player's uuid to {hlasoval::ano::*}
so that skript knows it is a list of variables, and not just one variable.

to compare the amount of players in that list you can use 'if size of {list varriable 1::*} is greater/smaller/equal to <number> :'
or even use a 2nd 'size of {listvariable::*}' as <number>
thanks it works now
 
Status
Not open for further replies.