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.

AFK Skript not working

Discussion in 'Skript' started by Rayy...__, Mar 17, 2023.

Tags:
  1. Rayy...__

    Rayy...__ Member

    Joined:
    Mar 17, 2023
    Messages:
    2
    Likes Received:
    0
    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 (Text):
    1. on load:
    2.     wait 3 seconds
    3.     broadcast "&a&lCreeperNet &6Skript&r has been loaded &asuccessfully!"
    4.  
    5.  
    6. if %player% is afk:
    7.     message "[&a&lCreeperNet AFK Detection] &bYou were afk. You were sent to the &elimbo&b."
    8.     make player execute command "warp limbo"
    9.    
    10. options:
    11.     afktime: 10 # how many seconds a player has to be afk before the skript runs.
    12.  
    13. command /afk:
    14.     trigger:
    15.         if {afk::%player%} is not set:
    16.             set {afk::%player%} to true
    17.             make player execute command "warp limbo"
    18.             wait 1 second
    19.             broadcast "&4&lServername>> &c%player% Is Now &4&lAFK"
    20.             send title "&4&LYou are AFK!" with subtitle "&cMove in any direction." to player for {@afktime} seconds
    21.            
    22.             play sound "block.note_block.pling" to player
    23.             set {_loc} to location of player
    24.             while {afk::%player%} is set:
    25.                 wait 1 second
    26.                 if location of player != {_loc}:
    27.                     delete {afk::%player%}
    28.                     broadcast "&4&lServername>> &c%player% Is No Longer &4&lAFK"
    29.                     send title "&4&LYou are no longer AFK!" to player for 2 seconds
    30.                     play sound "block.note_block.pling" to player
    31.                    
    32.  
    33. on chat:
    34.     if {afk::%player%} is not set:
    35.         stop
    36.     else if {afk::%player%} is set:
    37.         delete {afk::%player%}
    38.         broadcast "&4&lServerName>> &c%player% Is No Longer &4&lAFK"
    39.         send title "&4&LYou are no longer AFK!" to player for 2 seconds
    40.         play sound "block.note_block.pling" to player
    41.            
    42. on any move:
    43.     if {afk::%player%} is set:
    44.         delete {afk::%player%}
    45.  
    46.         send title "&4&LYou are no longer AFK!" to player for 2 seconds
    47.         play sound "block.note_block.pling" to player
    48.        
    49. every second:
    50.     set {_loc} to location of player
    51.     if location of player != {_loc}:
    52.         set {afktime::%player%} to 0
    53.         delete {afk::%player%}
    54.         broadcast "&4&lServername>> &c%player% Is No Longer &4&lAFK"
    55.         send title "&4&LYou are no longer AFK!" to player for 2 seconds
    56.         play sound "block.note_block.pling" to player
    57.     if location of player = {_loc}:
    58.         add 1 to {afktime::%player%}
    59.     if {afktime::%player%} = 10:
    60.         set {afk::%player%} to true
    61.             make player execute command "warp limbo"
    62.             wait 1 second
    63.         broadcast "&4&lServername>> &c%player% Is Now &4&lAFK"
    64.         send title "&4&LYou are AFK!" with subtitle "&cMove in any direction." to player for {@afktime} seconds
    65.         play sound "block.note_block.pling" to player
    66.         delete {afktime::%player%}
    Any help would be appriciated. (PS: I dont own this code)
     
  2. King_Creeperz

    King_Creeperz Member

    Joined:
    Oct 6, 2020
    Messages:
    44
    Likes Received:
    0
    Why is there no event here? Just remove it. And change the other stuff like Servername. Also what error did you get?
    Code (Text):
    1. if %player% is afk:
    2.     message "[&a&lCreeperNet AFK Detection] &bYou were afk. You were sent to the &elimbo&b."
    3.     make player execute command "warp limbo"
     
  3. Rayy...__

    Rayy...__ Member

    Joined:
    Mar 17, 2023
    Messages:
    2
    Likes Received:
    0
    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:
     

Share This Page

Loading...