Solved Need Help With Regions

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

    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!

Doodle

Well-Known Member
Sep 3, 2023
490
63
28
This code for some reason pops up with no errors, yet simply does not work. I know that the problem is line 4, but I don't know what the problem with line 4 is.

I am using the latest version of Skript (2.12.2), and the latest version of SkBee. I use worldguard as my region plugin.

code_language.skript:
on enter of region "afk":
    send "&aYou have entered the AFK zone!" to player
    set {_afktime} to 0
    while player's location is in event-region: # problem child
        wait 1 second
        add 1 to {_afktime}
        send title "&a&lAFK" with subtitle "&7AFK TIME: &d%{_afktime}% &7seconds!" to player with fadein 0 seconds
        if mod({_afktime}, 300) = 0:
            add 6 to player's balance
            send action bar "&aYou have received &d6☽&a for being AFK for &d%{_afktime}% seconds!" to player
            chance of 1%:
                add 30 to player's balance
                send "&aYou have received a &dbonus &aof &d30☽&a!" to player
    stop

on exit of region "afk":
    send "&cYou have exited the AFK zone!" to player

(I did try debugging this myself before I posted it here.)

Any help would be very much appreciated. Thank you.
 
This is the code, it you guys want it. You should probably edit it a bit, but here is the working version:

Python:
on enter of region "afk":
    send "&aYou have entered the AFK zone!" to player
    set {-afk::%player's uuid%} to 0 seconds
    set {_amount} to 0
    set {_give} to 1
    while {-afk::%player's uuid%} is set:
        add 1 second to {-afk::%player's uuid%}
        send title "&a&lAFK" with subtitle "&7AFK TIME: &e%{-afk::%player's uuid%}%!" to player for 1 second with fadein 0 seconds and fadeout 0.7 seconds
        if mod({-afk::%player's uuid%}'s seconds, 60) = 0:
            if mod({-afk::%player's uuid%}'s minutes, 60) = 0:
                set {_give} to min(5, {_give} + 1)
            add {_give} to player's balance
            add {_give} to {_amount}
            send action bar "&aYou have received &d%{_give}%☽&a for being AFK for &d%{-afk::%player's uuid%}%!" to player
            chance of 1%:
                add 15 to player's balance
                add 15 to {_amount}
                send "&aYou have received a &dbonus &aof &d15☽&a!" to player
        loop 9 times:
            wait 0.1 seconds
            exit 2 sections if {-afk::%player's uuid%} is not set
        wait 0.1 seconds
    stop if {_amount} = 0
    send title "&eYOU HAVE EARNED:" with subtitle "" to player with fadein 0 seconds
    play sound "item.armor.equip_diamond" with volume 1 and pitch 1 to player
    wait 1 second
    send title "&eYOU HAVE EARNED:" with subtitle "&d%{_amount}%☽" to player with fadein 0 seconds
    play sound "entity.player.levelup" with volume 1 and pitch 1 to player

on exit of region "afk":
    send "&cYou have exited the AFK zone!" to player
    delete {-afk::%player's uuid%}