AFK Skript 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.

Rayy...__

Member
Mar 17, 2023
2
0
1
23
Hey! I'm working on an auto afk skript (after x amount of seconds without moving, player gets teleported to a warp), and I can't get it to work.

Code:
on load:
    wait 3 seconds
    broadcast "&a&lCreeperNet &6Skript&r has been loaded &asuccessfully!"


if %player% is afk:
    message "[&a&lCreeperNet AFK Detection] &bYou were afk. You were sent to the &elimbo&b."
    make player execute command "warp limbo"
    
options:
    afktime: 10 # how many seconds a player has to be afk before the skript runs.

command /afk:
    trigger:
        if {afk::%player%} is not set:
            set {afk::%player%} to true
            make player execute command "warp limbo"
            wait 1 second
            broadcast "&4&lServername>> &c%player% Is Now &4&lAFK"
            send title "&4&LYou are AFK!" with subtitle "&cMove in any direction." to player for {@afktime} seconds
            
            play sound "block.note_block.pling" to player
            set {_loc} to location of player
            while {afk::%player%} is set:
                wait 1 second
                if location of player != {_loc}:
                    delete {afk::%player%}
                    broadcast "&4&lServername>> &c%player% Is No Longer &4&lAFK"
                    send title "&4&LYou are no longer AFK!" to player for 2 seconds
                    play sound "block.note_block.pling" to player
                    

on chat:
    if {afk::%player%} is not set:
        stop
    else if {afk::%player%} is set:
        delete {afk::%player%}
        broadcast "&4&lServerName>> &c%player% Is No Longer &4&lAFK"
        send title "&4&LYou are no longer AFK!" to player for 2 seconds
        play sound "block.note_block.pling" to player
            
on any move:
    if {afk::%player%} is set:
        delete {afk::%player%}

        send title "&4&LYou are no longer AFK!" to player for 2 seconds
        play sound "block.note_block.pling" to player
        
every second:
    set {_loc} to location of player
    if location of player != {_loc}:
        set {afktime::%player%} to 0
        delete {afk::%player%}
        broadcast "&4&lServername>> &c%player% Is No Longer &4&lAFK"
        send title "&4&LYou are no longer AFK!" to player for 2 seconds
        play sound "block.note_block.pling" to player
    if location of player = {_loc}:
        add 1 to {afktime::%player%}
    if {afktime::%player%} = 10:
        set {afk::%player%} to true
            make player execute command "warp limbo"
            wait 1 second
        broadcast "&4&lServername>> &c%player% Is Now &4&lAFK"
        send title "&4&LYou are AFK!" with subtitle "&cMove in any direction." to player for {@afktime} seconds
        play sound "block.note_block.pling" to player
        delete {afktime::%player%}

Any help would be appriciated. (PS: I dont own this code)
 
Why is there no event here? Just remove it. And change the other stuff like Servername. Also what error did you get?
Code:
if %player% is afk:
    message "[&a&lCreeperNet AFK Detection] &bYou were afk. You were sent to the &elimbo&b."
    make player execute command "warp limbo"
 
Why is there no event here? Just remove it. And change the other stuff like Servername. Also what error did you get?
Code:
if %player% is afk:
    message "[&a&lCreeperNet AFK Detection] &bYou were afk. You were sent to the &elimbo&b."
make player execute command "warp limbo"

I removed it and this is the error

8.03 09:43:15 [Server] INFO Can't understand this event: 'on any move'
18.03 09:43:15 [Server] INFO Line: on any move:
18.03 09:43:15 [Server] INFO Line 47: (afk.sk)
18.03 09:43:15 [Server] INFO There's no player in a periodical event
18.03 09:43:15 [Server] INFO Line: set {_loc} to location of player
18.03 09:43:15 [Server] INFO Line 48: (afk.sk)
18.03 09:43:15 [Server] INFO There's no player in a periodical event
18.03 09:43:15 [Server] INFO Line: if location of player != {_loc}:
18.03 09:43:15 [Server] INFO Line 54: (afk.sk)
18.03 09:43:15 [Server] INFO There's no player in a periodical event
18.03 09:43:15 [Server] INFO Line: if location of player = {_loc}:
18.03 09:43:15 [Server] INFO Line 56: (afk.sk)
18.03 09:43:15 [Server] INFO There's no player in a periodical event
18.03 09:43:15 [Server] INFO Line: if {afktime::%player%} = 10:
 
Status
Not open for further replies.