Salary & AFK system

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

L2T

Member
Mar 12, 2023
1
0
1
20
Category: Skript

Suggested name: AFK - Salary system

Spigot/Skript Version: Newest 1.19.3

What I want:
I'm looking to create a system where every player who is not AFK receives 5$.
This is what I have come up with so far for the salary system without the AFK feature.

Code:
on join:
    set join message to "{@JoinMessage}"
    wait 15 minutes
    while player is online:
        add 5 to player's balance
        send "&6&lYou have just received 5 points."
        wait 15 minutes


And this is something I got from a different forum to mix it in with possibly.
Code:
options:
    afktime: 600 # 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
            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%} = {@afktime}:
        set {afk::%player%} to true
        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%}


Ideas for commands: /afk

Ideas for permissions: core.afk

When I'd like it by: A reasonable time