AFK room help.

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

伊藤布哥

Member
Jul 22, 2017
10
0
0
25
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_language.skript:
command /afkset:
    permission: op
    permission: {@nopermission}
    trigger:
        set {_loc} to location of player
        set {location.of.afk} to location of player # Sets the variable '{location.of.afk}' to where the player is standing
        message "&cafkroom> &fyou are set a afk room! to the following coordinates: &e%{_loc}%"
     
command /afkdel:
    permission: op
    permission: {@nopermission}
    trigger:
        set {_loc} to location of player
        clear {location.of.afk} # Clears the variable
        message "&cSpawn> &fYou are deleted a afkroom, just type '/afkset' to reset it !"

command /afk [<player>]:
    permission: afk.tp.other
    permission message: {@nopermission}
    trigger:
        if player has permission "afk.tp.other":
            if {location.of.afk} is not set: # If they haven't done /afkset yet, it tells them that they have not
                message "&cafkroom> &fthe afk room has not set yet. just type'/setspawn' to set it!."
                stop
            if arg 1 is not set:
                message "&cafkroom> &fPlayer argument missing."
            if arg 1 is set:
                set {_p} to player
                teleport arg 1 to {location.of.afk}
                message "&cafkroom> &fYou sent &e%{_p}% &fto the afkroom!."
                message "&cafkroom> &fYou are sent to the afkroom !."
        else:
            teleport player to {location.of.afk}

command /afk:
    permission: afk.tp.me
    permission message: {@nopermission}
    trigger:
        set {is.%uuid of player%.afk} to true # Sets the variable to true
        broadcast "&e%player%&f is now AFK." # Broadcasts that they are AFK
       set {_p} to player
       teleport {_p} {location.of.afk}
on any movement: # In other words, whenever the player moves
    if {is.%uuid of player%.afk} is true: # Checks if the variable is true
        set {is.%uuid of player%.afk} to false # If it is, it sets it to false, as you can see
        wait 1 tick
        broadcast "&e%player%&f is no longer AFK." # Then, it broadcasts that the player is no longer AFK.

please help me this ~~~~~~ please ~~
 
Last edited:
This should work :emoji_slight_smile:

Code:
command /afk:
    permission: afk.tp.me
    permission message: {@nopermission}
    trigger:
        Set {_afkback.%uuid of player%} to location of player #On any move, teleport the player to this variable
        set {is.%uuid of player%.afk} to true # Sets the variable to true
        broadcast "&e%player%&f is now AFK." # Broadcasts that they are AFK
       set {_p} to player
       teleport {_p} {location.of.afk}
 
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
command /afk [<player>]:
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_language.skript:
command /afkset:
    permission: op
    permission: {@nopermission}
    trigger:
        set {_loc} to location of player
        set {location.of.afk} to location of player # Sets the variable '{location.of.afk}' to where the player is standing
        message "&9AFKroom> &fyou are set a AFK room to the following coordinates: &e%{_loc}%"
    
command /afkdel:
    permission: op
    permission: {@nopermission}
    trigger:
        set {_loc} to location of player
        clear {location.of.afk} # Clears the variable
        message "&9AFKroom&7> &fYou are deleted a AFKroom, just type '/afkset' to reset it !"
 
command /afk [<player>]:
    permission: afk.tp.other
    permission message: {@nopermission}
    trigger:
        if player has permission "afk.tp.other":
            if {location.of.afk} is not set: # If they haven't done /afkset yet, it tells them that they have not
                message "&cAFKroom> &fthe AFK room has not set yet, just type'/afkset' to set it!."
                stop
            if arg 1 is not set:
                message "&9AFKroom&7> &fPlayer argument missing."
            if arg 1 is set:
                set {_p} to player
                teleport arg 1 to {location.of.afk}
                message "&9AFKroom&7> &fYou sent &e%{_p}% &fto the AFK room!."
                message "&9AFKroom&7> &fYou are sent to the AFK room!."
        else:
            teleport player to {location.of.afk}

command /afk:
    permission: afk.tp.me
    permission message: {@nopermission}
    trigger:
        Set {_afkback.%uuid of player%} to location of player #On any move, teleport the player to this variable
        set {is.%uuid of player%.afk} to true # Sets the variable to true
        broadcast "&e%player%&f is now AFK." # Broadcasts that they are AFK
        set {_p} to player
        teleport {_p} {location.of.afk}
 
Haven't tried this, but it should work :emoji_slight_smile:
Code:
On any move:
    If {Is.%uuid of player%.afk} is true:
        Teleport player to {_afkback.%uuid of player%}
        Set {Is.%uuid of player%.afk} to false
        Delete {_afkback.%uuid of player%}
        Broadcast "&e%player%&f is no longer AFK."
 
I have made your skript a little more easy to get in, Instead of 2 /afk commands, i've made 1.
Code:
command /afkset:
    permission: op
    permission message: {@nopermission}
    trigger:
        set {_loc} to location of player
        set {location.of.afk} to location of player # Sets the variable '{location.of.afk}' to where the player is standing
        message "&9AFKroom> &fyou are set a AFK room to the following coordinates: &e%{_loc}%"
   
command /afkdel:
    permission: op
    permission message: {@nopermission}
    trigger:
        set {_loc} to location of player
        clear {location.of.afk} # Clears the variable
        message "&9AFKroom&7> &fYou are deleted a AFKroom, just type '/afkset' to reset it !"

command /afk [<player>]:
    trigger:
        If arg-1 is set:
            If player has permission "afk.tp.other":
                if {location.of.afk} is set: # If they haven't done /afkset yet, it tells them that they have not
                    Set {afkback.%arg-1%} to location of arg-1
                    teleport arg 1 to {location.of.afk}
                    Set {Is.%arg-1%.afk} to true
                    Wait 1 tick
                    message "&9AFKroom&7> &fYou sent &e%arg-1% &fto the AFK room!."
                    message "&9AFKroom&7> &fYou are sent to the AFK room!." to arg-1
                Else:
                    message "&cAFKroom> &fthe AFK room has not set yet, just type'/afkset' to set it!."
                    stop
            Else:
                message "{@nopermission}"
        Else:
            If player has permission "afk.tp.me":
                If {location.of.afk} is set:
                    Set {afkback.%player%} to location of player #On any move, teleport the player to this variable
                    set {is.%player%.afk} to true
                    broadcast "&e%player%&f is now AFK."
                    wait 1 tick
                    teleport player to {location.of.afk}
                Else:
                    message "&cAFKroom> &fthe AFK room has not set yet, just type'/afkset' to set it!."
            Else:
                message "{@nopermission}"
               
               
On any move:
    If {Is.%player%.afk} is true:
        Wait 2 ticks
        Teleport player to {afkback.%player%}
        Wait 1 tick
        Clear {is.%player%.afk}
        clear {afkback.%uuid of player%}
        If {Is.%player%} is not set:
            Wait 1 second
            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
 
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_language.skript:
every 1 minutes:
    loop all players:
        if loop-player's location is {afk.location.%loop-player%}:
            if {is.%loop-player%.afk} is false:
                set {_p} to player
                teleport loop-player to {location.of.afk}
                broadcast "&a&l%loop-player% &7est désormais afk"
                set {is.%loop-player%.afk} to true
        else:
            set {afk.location.%loop-player%} to loop-player's location
 
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_language.skript:
command /afkset:
    permission: op
    permission message: {@nopermission}
    trigger:
        set {_loc} to location of player
        set {location.of.afk} to location of player # Sets the variable '{location.of.afk}' to where the player is standing
        message "&9AFKroom> &fyou are set a AFK room to the following coordinates: &e%{_loc}%"
 
command /afkdel:
    permission: op
    permission message: {@nopermission}
    trigger:
        set {_loc} to location of player
        clear {location.of.afk} # Clears the variable
        message "&9AFKroom&7> &fYou are deleted a AFKroom, just type '/afkset' to reset it !"
 
command /afk [<player>]:
    trigger:
        If arg-1 is set:
            If player has permission "afk.tp.other":
                if {location.of.afk} is set: # If they haven't done /afkset yet, it tells them that they have not
                    Set {afkback.%arg-1%} to location of arg-1
                    teleport arg 1 to {location.of.afk}
                    Set {Is.%arg-1%.afk} to true
                    Wait 1 tick
                    message "&9AFKroom&7> &fYou sent &e%arg-1% &fto the AFK room!."
                    message "&9AFKroom&7> &fYou are sent to the AFK room!." to arg-1
                Else:
                    message "&cAFKroom> &fthe AFK room has not set yet, just type'/afkset' to set it!."
                    stop
            Else:
                message "{@nopermission}"
        Else:
            If player has permission "afk.tp.me":
                If {location.of.afk} is set:
                    Set {afkback.%player%} to location of player #On any move, teleport the player to this variable
                    set {is.%player%.afk} to true
                    broadcast "&e%player%&f is now AFK."
                    wait 1 tick
                    teleport player to {location.of.afk}
                Else:
                    message "&cAFKroom> &fthe AFK room has not set yet, just type'/afkset' to set it!."
            Else:
                message "{@nopermission}"

every 1 minutes:
    loop all players:
        if loop-player's location is {afk.location.%loop-player%}:
            if {is.%loop-player%.afk} is false:
                set {_p} to player
                teleport loop-player to {location.of.afk}
                broadcast "&a&l%loop-player% &7est désormais afk"
                set {is.%loop-player%.afk} to true
        else:
            set {afk.location.%loop-player%} to loop-player's location

On any move:
    If {Is.%player%.afk} is true:
        Wait 2 ticks
        Teleport player to {afkback.%player%}
        Wait 1 tick
        Clear {is.%player%.afk}
        clear {afkback.%uuid of player%}
        If {Is.%player%} is not set:
            Wait 1 second
            Broadcast "&e%player% &fis no longer AFK."
 
This should do it :emoji_slight_smile:

Code:
every 1 second in world "Your world":            #Change to your world name.
    Loop all players:
        Add 1 to {afktimer.%loop-player%}
            If {afktimer.%loop-player%} is greater than 299:    #Change the number if you want to, it should just be in seconds.
                Set {afkback.%loop-player%} to loop-player's location
                Teleport loop-player to {location.of.afk}
                Set {Is.%loop-player%.afk} to true
               
   
On any move:
    Set {afktimer.%player%} to 0
 
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
 
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
In the loop-player effect you need to change all player, with loop-player that could be the problem.