1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

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

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Every {variable} seconds not working

Discussion in 'Skript' started by EthanCW, Mar 31, 2019.

Thread Status:
Not open for further replies.
  1. EthanCW

    EthanCW New Member

    Joined:
    Mar 16, 2019
    Messages:
    5
    Likes Received:
    0
    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 (Text):
    1. every {duration} seconds:
    2.     if {active} is "true":
    3.         set {broadinteger} to a random integer between 1 and 3
    4.         if {broadinteger} is 1:
    5.             set {broadcast} to {m1}
    6.         else if {broadinteger} is 2:
    7.             set {broadcast} to {m2}
    8.         else if {broadinteger} is 3:
    9.             set {broadcast} to {m3}
    10.         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.)
     
  2. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    108
    Medals:
    You can't use variables in events, you have to use the on load event with a while loop. Examle:
    Code (Text):
    1. on load:
    2.     set {_time} to now
    3.     set {lastload} to {_time}
    4.     while {lastload} is {_time}:
    5.         broadcast "Every second!"
    6.         wait 1 second
     
  3. Noblesuntzu

    Noblesuntzu Active Member

    Joined:
    Feb 18, 2017
    Messages:
    63
    Likes Received:
    4
    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 (Text):
    1. on load:
    2.     set {messages::1} to "Message One"
    3.     set {messages::2} to "Message Two"
    4.     set {messages::3} to "Message Three"
    5.     set {_time} to now
    6.     set {lastload} to {_time}
    7.     set {difference} to 10 seconds #time difference
    8.     set {loopnumber} to 1
    9.     while {lastload} is {_time}:
    10.         {active} is true
    11.         add 1 to {loopnumber}
    12.         if {loopnumber} is more than 3: #total amount of messages
    13.             set {loopnumber} to 1
    14.         broadcast "%{messages::%{loopnumber}%}%"
    15.         wait ({difference} parsed as timespan)
    16.  
    Also I didn't test this so hopefully it just works, been a while since I've done Skript
     
Thread Status:
Not open for further replies.

Share This Page

Loading...