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

  • 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.

NeptunePlayz

Member
Apr 23, 2017
13
0
0
36
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:
command /setlimbo:
    permission: admin
    trigger:
        set {limbo} to location of player
        send "&eYou set the Limbo spawn to your current location!"

on any move:
    if {afk.%player%} is true:
        loop all blocks in radius 2 around player:
            loop-block is water or piston or sticky_piston:
                stop
        loop all players in radius 2 around player:
            loop-player is not "%player%":
                stop
        loop all animals in radius 2 around player:
            loop-animal is set:
                stop
        teleport player to {hub}
        set {afk.%player%} to false
    delete {auto%player%}

every 1 seconds:
    loop all players:
        add 1 to {auto%loop-player%}
        wait 1 tick
        if {auto%loop-player%} is more than 294:
            if {afk.%loop-player%} is true:
                stop
            else:
                teleport loop-player to {limbo}
                loop 10 times:
                    send "&c" to loop-player
                send "&cYou became AFK and got sent to the limbo." to loop-player
                wait 4 seconds
                set {afk.%loop-player%} to true
                stop
Any help I can get would be appreciated.

- Narpzy
[doublepost=1578231628,1578230635][/doublepost]it usually crashes after long periods of time
 
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:
command /setlimbo:
    permission: admin
    trigger:
        set {limbo} to location of player
        send "&eYou set the Limbo spawn to your current location!"

on any move:
    if {afk.%player%} is true:
        loop all blocks in radius 2 around player:
            loop-block is water or piston or sticky_piston:
                stop
        loop all players in radius 2 around player:
            loop-player is not "%player%":
                stop
        loop all animals in radius 2 around player:
            loop-animal is set:
                stop
        teleport player to {hub}
        set {afk.%player%} to false
    delete {auto%player%}

every 1 seconds:
    loop all players:
        add 1 to {auto%loop-player%}
        wait 1 tick
        if {auto%loop-player%} is more than 294:
            if {afk.%loop-player%} is true:
                stop
            else:
                teleport loop-player to {limbo}
                loop 10 times:
                    send "&c" to loop-player
                send "&cYou became AFK and got sent to the limbo." to loop-player
                wait 4 seconds
                set {afk.%loop-player%} to true
                stop
Any help I can get would be appreciated.

- Narpzy
[doublepost=1578231628,1578230635][/doublepost]it usually crashes after long periods of time
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.
 
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.
Thank you!
 
Status
Not open for further replies.