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.

Solved Why does it crash my server after someone moves when he was afk?

Discussion in 'Skript' started by NeptunePlayz, Jan 5, 2020.

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

    NeptunePlayz Member

    Joined:
    Apr 23, 2017
    Messages:
    13
    Likes Received:
    0
    Well for some reason my code just makes the server crash when someone comes back from being afk. I have no idea why.

    Here is my code:
    Code (Text):
    1. command /setlimbo:
    2.     permission: admin
    3.     trigger:
    4.         set {limbo} to location of player
    5.         send "&eYou set the Limbo spawn to your current location!"
    6.  
    7. on any move:
    8.     if {afk.%player%} is true:
    9.         loop all blocks in radius 2 around player:
    10.             loop-block is water or piston or sticky_piston:
    11.                 stop
    12.         loop all players in radius 2 around player:
    13.             loop-player is not "%player%":
    14.                 stop
    15.         loop all animals in radius 2 around player:
    16.             loop-animal is set:
    17.                 stop
    18.         teleport player to {hub}
    19.         set {afk.%player%} to false
    20.     delete {auto%player%}
    21.  
    22. every 1 seconds:
    23.     loop all players:
    24.         add 1 to {auto%loop-player%}
    25.         wait 1 tick
    26.         if {auto%loop-player%} is more than 294:
    27.             if {afk.%loop-player%} is true:
    28.                 stop
    29.             else:
    30.                 teleport loop-player to {limbo}
    31.                 loop 10 times:
    32.                     send "&c" to loop-player
    33.                 send "&cYou became AFK and got sent to the limbo." to loop-player
    34.                 wait 4 seconds
    35.                 set {afk.%loop-player%} to true
    36.                 stop
    Any help I can get would be appreciated.

    - Narpzy
    --- Double Post Merged, Jan 5, 2020, Original Post Date: Jan 5, 2020 ---
    it usually crashes after long periods of time
     
  2. Best Answer:
    Post #2 by TPGamesNL, Jan 5, 2020
  3. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    108
    Medals:
    If you look at lines 18 and 19 from the `on any move` trigger. Line 18 (the teleport) teleport the player, which triggers the event again, which teleports the player again, which triggers the event again, and so on, until the server crashes. What you have to do, is set afk variable before teleporting, so that the teleport won't be called again.
     
  4. NeptunePlayz

    NeptunePlayz Member

    Joined:
    Apr 23, 2017
    Messages:
    13
    Likes Received:
    0
    Thank you!
     
Thread Status:
Not open for further replies.

Share This Page

Loading...