Every {variable} seconds 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 skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

EthanCW

New Member
Mar 16, 2019
5
0
0
35
I was working on a skript that would make a broadcaster to say certain things. However, I came across a bug with when I wrote "Every {duration} seconds:". It says that it cannot understand this event. Here is the code:
Code:
every {duration} seconds:
    if {active} is "true":
        set {broadinteger} to a random integer between 1 and 3
        if {broadinteger} is 1:
            set {broadcast} to {m1}
        else if {broadinteger} is 2:
            set {broadcast} to {m2}
        else if {broadinteger} is 3:
            set {broadcast} to {m3}
        broadcast "&3&l[&bBroadcaster&3&l] &9%{broadcast}%"

(Some background info: m1-m3 are the messages. Broadinteger is the random number picker to pick the message. And {active} is whether it is on or not.)
 
You can't use variables in events, you have to use the on load event with a while loop. Examle:
Code:
on load:
    set {_time} to now
    set {lastload} to {_time}
    while {lastload} is {_time}:
        broadcast "Every second!"
        wait 1 second
 
Also, from a programming view, you might want to use an incrementing message thing so you don't get the same message twice in a row (its tacky :emoji_stuck_out_tongue:)
Code:
on load:
    set {messages::1} to "Message One"
    set {messages::2} to "Message Two"
    set {messages::3} to "Message Three"
    set {_time} to now
    set {lastload} to {_time}
    set {difference} to 10 seconds #time difference
    set {loopnumber} to 1
    while {lastload} is {_time}:
        {active} is true
        add 1 to {loopnumber}
        if {loopnumber} is more than 3: #total amount of messages
            set {loopnumber} to 1
        broadcast "%{messages::%{loopnumber}%}%"
        wait ({difference} parsed as timespan)
Also I didn't test this so hopefully it just works, been a while since I've done Skript
 
Status
Not open for further replies.