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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

AFK room help.

Discussion in 'Requests' started by 伊藤布哥, Jul 22, 2017.

Tags:
  1. 伊藤布哥

    伊藤布哥 Member

    Joined:
    Jul 22, 2017
    Messages:
    10
    Likes Received:
    0
    I've look so many sk file, but I could not find the best afk plugin, what I want is make player teleport to a specific afkroom by Skript automatic detect!

    here is following I've done with sk, but I don't know how to do the listener when player typed /afk and the sk will gets record a location before player be sent to the afk room, but not cover the Essentials command /back

    Code (Skript):
    1. command /afkset:
    2.     permission: op
    3.     permission: {@nopermission}
    4.     trigger:
    5.         set {_loc} to location of player
    6.         set {location.of.afk} to location of player # Sets the variable '{location.of.afk}' to where the player is standing
    7.         message "&cafkroom> &fyou are set a afk room! to the following coordinates: &e%{_loc}%"
    8.      
    9. command /afkdel:
    10.     permission: op
    11.     permission: {@nopermission}
    12.     trigger:
    13.         set {_loc} to location of player
    14.         clear {location.of.afk} # Clears the variable
    15.         message "&cSpawn> &fYou are deleted a afkroom, just type '/afkset' to reset it !"
    16.  
    17. command /afk [<player>]:
    18.     permission: afk.tp.other
    19.     permission message: {@nopermission}
    20.     trigger:
    21.         if player has permission "afk.tp.other":
    22.             if {location.of.afk} is not set: # If they haven't done /afkset yet, it tells them that they have not
    23.                 message "&cafkroom> &fthe afk room has not set yet. just type'/setspawn' to set it!."
    24.                 stop
    25.             if arg 1 is not set:
    26.                 message "&cafkroom> &fPlayer argument missing."
    27.             if arg 1 is set:
    28.                 set {_p} to player
    29.                 teleport arg 1 to {location.of.afk}
    30.                 message "&cafkroom> &fYou sent &e%{_p}% &fto the afkroom!."
    31.                 message "&cafkroom> &fYou are sent to the afkroom !."
    32.         else:
    33.             teleport player to {location.of.afk}
    34.  
    35. command /afk:
    36.     permission: afk.tp.me
    37.     permission message: {@nopermission}
    38.     trigger:
    39.         set {is.%uuid of player%.afk} to true # Sets the variable to true
    40.         broadcast "&e%player%&f is now AFK." # Broadcasts that they are AFK
    41.        set {_p} to player
    42.        teleport {_p} {location.of.afk}
    43. on any movement: # In other words, whenever the player moves
    44.     if {is.%uuid of player%.afk} is true: # Checks if the variable is true
    45.         set {is.%uuid of player%.afk} to false # If it is, it sets it to false, as you can see
    46.         wait 1 tick
    47.         broadcast "&e%player%&f is no longer AFK." # Then, it broadcasts that the player is no longer AFK.
    please help me this ~~~~~~ please ~~
     
    #1 伊藤布哥, Jul 22, 2017
    Last edited: Jul 22, 2017
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    This should work :emoji_slight_smile:

    Code (Text):
    1.  
    2. command /afk:
    3.     permission: afk.tp.me
    4.     permission message: {@nopermission}
    5.     trigger:
    6.         Set {_afkback.%uuid of player%} to location of player #On any move, teleport the player to this variable
    7.         set {is.%uuid of player%.afk} to true # Sets the variable to true
    8.         broadcast "&e%player%&f is now AFK." # Broadcasts that they are AFK
    9.        set {_p} to player
    10.        teleport {_p} {location.of.afk}
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    All right... I'm confused with my sk file :emoji_frowning: :emoji_frowning: ,
    here's my sk file, I still can't get what I want, when I typed /afk, then it will cause crash with
    and tells me "AFKroom> &fPlayer argument missing.",

    what I want is make a location(AFKroom) that player will be gets teleported when they are AFK, and once player moves player will gets teleported back the location that before AFKroom teleported them,

    Code (Skript):
    1. command /afkset:
    2.     permission: op
    3.     permission: {@nopermission}
    4.     trigger:
    5.         set {_loc} to location of player
    6.         set {location.of.afk} to location of player # Sets the variable '{location.of.afk}' to where the player is standing
    7.         message "&9AFKroom> &fyou are set a AFK room to the following coordinates: &e%{_loc}%"
    8.    
    9. command /afkdel:
    10.     permission: op
    11.     permission: {@nopermission}
    12.     trigger:
    13.         set {_loc} to location of player
    14.         clear {location.of.afk} # Clears the variable
    15.         message "&9AFKroom&7> &fYou are deleted a AFKroom, just type '/afkset' to reset it !"
    16.  
    17. command /afk [<player>]:
    18.     permission: afk.tp.other
    19.     permission message: {@nopermission}
    20.     trigger:
    21.         if player has permission "afk.tp.other":
    22.             if {location.of.afk} is not set: # If they haven't done /afkset yet, it tells them that they have not
    23.                 message "&cAFKroom> &fthe AFK room has not set yet, just type'/afkset' to set it!."
    24.                 stop
    25.             if arg 1 is not set:
    26.                 message "&9AFKroom&7> &fPlayer argument missing."
    27.             if arg 1 is set:
    28.                 set {_p} to player
    29.                 teleport arg 1 to {location.of.afk}
    30.                 message "&9AFKroom&7> &fYou sent &e%{_p}% &fto the AFK room!."
    31.                 message "&9AFKroom&7> &fYou are sent to the AFK room!."
    32.         else:
    33.             teleport player to {location.of.afk}
    34.  
    35. command /afk:
    36.     permission: afk.tp.me
    37.     permission message: {@nopermission}
    38.     trigger:
    39.         Set {_afkback.%uuid of player%} to location of player #On any move, teleport the player to this variable
    40.         set {is.%uuid of player%.afk} to true # Sets the variable to true
    41.         broadcast "&e%player%&f is now AFK." # Broadcasts that they are AFK
    42.         set {_p} to player
    43.         teleport {_p} {location.of.afk}
    44.            
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Haven't tried this, but it should work :emoji_slight_smile:
    Code (Text):
    1.  
    2. On any move:
    3.     If {Is.%uuid of player%.afk} is true:
    4.         Teleport player to {_afkback.%uuid of player%}
    5.         Set {Is.%uuid of player%.afk} to false
    6.         Delete {_afkback.%uuid of player%}
    7.         Broadcast "&e%player%&f is no longer AFK."
     
  5. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    No... it still not works, did you test that on your server yet?
     
  6. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    No i did not.
     
  7. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    so... can you figure out that for me? because I really want that
     
  8. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    I have made your skript a little more easy to get in, Instead of 2 /afk commands, i've made 1.
    Code (Text):
    1.  
    2. command /afkset:
    3.     permission: op
    4.     permission message: {@nopermission}
    5.     trigger:
    6.         set {_loc} to location of player
    7.         set {location.of.afk} to location of player # Sets the variable '{location.of.afk}' to where the player is standing
    8.         message "&9AFKroom> &fyou are set a AFK room to the following coordinates: &e%{_loc}%"
    9.    
    10. command /afkdel:
    11.     permission: op
    12.     permission message: {@nopermission}
    13.     trigger:
    14.         set {_loc} to location of player
    15.         clear {location.of.afk} # Clears the variable
    16.         message "&9AFKroom&7> &fYou are deleted a AFKroom, just type '/afkset' to reset it !"
    17.  
    18. command /afk [<player>]:
    19.     trigger:
    20.         If arg-1 is set:
    21.             If player has permission "afk.tp.other":
    22.                 if {location.of.afk} is set: # If they haven't done /afkset yet, it tells them that they have not
    23.                     Set {afkback.%arg-1%} to location of arg-1
    24.                     teleport arg 1 to {location.of.afk}
    25.                     Set {Is.%arg-1%.afk} to true
    26.                     Wait 1 tick
    27.                     message "&9AFKroom&7> &fYou sent &e%arg-1% &fto the AFK room!."
    28.                     message "&9AFKroom&7> &fYou are sent to the AFK room!." to arg-1
    29.                 Else:
    30.                     message "&cAFKroom> &fthe AFK room has not set yet, just type'/afkset' to set it!."
    31.                     stop
    32.             Else:
    33.                 message "{@nopermission}"
    34.         Else:
    35.             If player has permission "afk.tp.me":
    36.                 If {location.of.afk} is set:
    37.                     Set {afkback.%player%} to location of player #On any move, teleport the player to this variable
    38.                     set {is.%player%.afk} to true
    39.                     broadcast "&e%player%&f is now AFK."
    40.                     wait 1 tick
    41.                     teleport player to {location.of.afk}
    42.                 Else:
    43.                     message "&cAFKroom> &fthe AFK room has not set yet, just type'/afkset' to set it!."
    44.             Else:
    45.                 message "{@nopermission}"
    46.                
    47.                
    48. On any move:
    49.     If {Is.%player%.afk} is true:
    50.         Wait 2 ticks
    51.         Teleport player to {afkback.%player%}
    52.         Wait 1 tick
    53.         Clear {is.%player%.afk}
    54.         clear {afkback.%uuid of player%}
    55.         If {Is.%player%} is not set:
    56.             Wait 1 second
    57.             Broadcast "&e%player% &fis no longer AFK."
    The skript should work like did earlier, just fixed some things. :emoji_slight_smile: - Sorry for bad english
     
  9. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Obviously, it works good, but lack 1 thing, is how to loop all players?
    I've done with this, but I don't know why it is not works

    Code (Skript):
    1.  
    2. every 1 minutes:
    3.     loop all players:
    4.         if loop-player's location is {afk.location.%loop-player%}:
    5.             if {is.%loop-player%.afk} is false:
    6.                 set {_p} to player
    7.                 teleport loop-player to {location.of.afk}
    8.                 broadcast "&a&l%loop-player% &7est désormais afk"
    9.                 set {is.%loop-player%.afk} to true
    10.         else:
    11.             set {afk.location.%loop-player%} to loop-player's location
    12.  
     
  10. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    I'm sorry, but i can't see what your skript should be done for. Can you explain to me, what your skript ^^ should do?
     
  11. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    Like I want to add server to detect player when they are afk they will be tp to {location.of.afk} by every 1m to loop all players

    and here's my code,
    Code (Skript):
    1. command /afkset:
    2.     permission: op
    3.     permission message: {@nopermission}
    4.     trigger:
    5.         set {_loc} to location of player
    6.         set {location.of.afk} to location of player # Sets the variable '{location.of.afk}' to where the player is standing
    7.         message "&9AFKroom> &fyou are set a AFK room to the following coordinates: &e%{_loc}%"
    8.  
    9. command /afkdel:
    10.     permission: op
    11.     permission message: {@nopermission}
    12.     trigger:
    13.         set {_loc} to location of player
    14.         clear {location.of.afk} # Clears the variable
    15.         message "&9AFKroom&7> &fYou are deleted a AFKroom, just type '/afkset' to reset it !"
    16.  
    17. command /afk [<player>]:
    18.     trigger:
    19.         If arg-1 is set:
    20.             If player has permission "afk.tp.other":
    21.                 if {location.of.afk} is set: # If they haven't done /afkset yet, it tells them that they have not
    22.                     Set {afkback.%arg-1%} to location of arg-1
    23.                     teleport arg 1 to {location.of.afk}
    24.                     Set {Is.%arg-1%.afk} to true
    25.                     Wait 1 tick
    26.                     message "&9AFKroom&7> &fYou sent &e%arg-1% &fto the AFK room!."
    27.                     message "&9AFKroom&7> &fYou are sent to the AFK room!." to arg-1
    28.                 Else:
    29.                     message "&cAFKroom> &fthe AFK room has not set yet, just type'/afkset' to set it!."
    30.                     stop
    31.             Else:
    32.                 message "{@nopermission}"
    33.         Else:
    34.             If player has permission "afk.tp.me":
    35.                 If {location.of.afk} is set:
    36.                     Set {afkback.%player%} to location of player #On any move, teleport the player to this variable
    37.                     set {is.%player%.afk} to true
    38.                     broadcast "&e%player%&f is now AFK."
    39.                     wait 1 tick
    40.                     teleport player to {location.of.afk}
    41.                 Else:
    42.                     message "&cAFKroom> &fthe AFK room has not set yet, just type'/afkset' to set it!."
    43.             Else:
    44.                 message "{@nopermission}"
    45.  
    46. every 1 minutes:
    47.     loop all players:
    48.         if loop-player's location is {afk.location.%loop-player%}:
    49.             if {is.%loop-player%.afk} is false:
    50.                 set {_p} to player
    51.                 teleport loop-player to {location.of.afk}
    52.                 broadcast "&a&l%loop-player% &7est désormais afk"
    53.                 set {is.%loop-player%.afk} to true
    54.         else:
    55.             set {afk.location.%loop-player%} to loop-player's location
    56.  
    57. On any move:
    58.     If {Is.%player%.afk} is true:
    59.         Wait 2 ticks
    60.         Teleport player to {afkback.%player%}
    61.         Wait 1 tick
    62.         Clear {is.%player%.afk}
    63.         clear {afkback.%uuid of player%}
    64.         If {Is.%player%} is not set:
    65.             Wait 1 second
    66.             Broadcast "&e%player% &fis no longer AFK."
     
  12. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    This should do it :emoji_slight_smile:

    Code (Text):
    1.  
    2. every 1 second in world "Your world":            #Change to your world name.
    3.     Loop all players:
    4.         Add 1 to {afktimer.%loop-player%}
    5.             If {afktimer.%loop-player%} is greater than 299:    #Change the number if you want to, it should just be in seconds.
    6.                 Set {afkback.%loop-player%} to loop-player's location
    7.                 Teleport loop-player to {location.of.afk}
    8.                 Set {Is.%loop-player%.afk} to true
    9.                
    10.    
    11. On any move:
    12.     Set {afktimer.%player%} to 0
     
  13. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    it is complex code XD , ok what I just got is it will run this whenever I move
    Broadcast "&e%player% &fis no longer AFK."

    I think "On any move" have to add something like if and else?
    and whenever I got teleport to AFK location the server won't broadcast I'm now AFK
     
  14. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    In the loop-player effect you need to change all player, with loop-player that could be the problem.
     
  15. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,184
    Likes Received:
    222
    which loop-player needs chant to all player?
     

Share This Page

Loading...