AFK-Rewards on certain WorldGuard region

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

2Unexpected

Member
Nov 4, 2022
19
1
3
Category: Skript

Suggested name: AFK-Rewards

Spigot/Skript Version: Skript 2.6.4 - Spigot 1.13.2

What I want:

Something that when you stay at a worldguard region called "afk" for 30minutes it will make the console execute command /example <player> and if you quit during the 30minutes, the timer will be reseted. and also when the reward is given the timer resets too, there's a action bar as well that shows how much time is left to get the next reward, Thanks.

Ideas for commands: /resettimer <player> which resets the timer of the time the selected player has been on the worldguard region

Ideas for permissions: command.resettimer for /resettimer


When I'd like it by: As soon as possible
 
Here's an idea of how this kind of script would look:

Code:
command resettimer [<player>]:
   permission: reset.admin
   trigger:
      set  {warn::%arg-1%} to "true"
      send "&c[AFK] &aSuccess&2! &b%arg-1%'s &3timer has been reset&b!" to player

on first join:
set {time::%player%} to 30

on join:
   if {warn::%player%} is "true":
      send "&c[AFK] &4Since you logged out, your AFK reward timer has reset, sorry&c!" to player
clear {warn::%player%}

on leave:
set {_p} to player
   if {time::%{_p}%} isn't 0:
set {time::%{_p}%} to 30
set {warn::%{_p}%} to "true"

every second:
   loop all players:
      set {_p} to loop-player
      if {warn::%{_p}%} is set:
         send "&c[AFK] &4Your AFK reward timer has been manually reset, sorry&c!" to loop-player
clear {warn::%{_p}%}

every minute:
loop all players:
      set {_p} to loop-player
      if {time::%{_p}%} isn't 0 or 1:
remove 1 from {time::%{_p}%}
send actionbar "&c[AFK] &4You'll be rewarded in &b%{time::%{_p}%}% &3Minutes!" to {_p}
if {time::%{_p}%} is 1:
remove 1 from {time::%{_p}%}
send actionbar "&c[AFK] &4You'll be rewarded in &b%{time::%{_p}%}% &3Minute!" to {_p}
else:
execute console command "op %{_p}%" # Pls change this in final version of this script
         send actionbar "&c[AFK] &4You have been rewarded x1 TestReward&c!" to to {_p}
wait 2 ticks
set {time::%{_p}%} to 30

Keep in mind: This has not been tested and could have a few minor errors/typos which in turn would cause this kind of script to fail.