Help for offline warn script

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Hysean

Member
Feb 10, 2024
3
0
1
25
Hi ! I'm new to Skript and I need a /warn script where I can warn offline users, then they will be notified on join.
There is a good Skript by Frog to warn an offline player but it just does a /broadcast and doesnt notify the concerned player when he joins.
Thanks !


Code:
#Made by BigBrainFrog / Frog

variables:
  {warns}  = 0

# Warn Command
command /warn <offline player> <text>:
  permission: warn.sk
  permission message: &4&lYou do not have permission to use this command!
  trigger:
    if arg-1 is set:
      if arg-2 is set:
        add 1 to {warns.%arg-1's uuid%}
        broadcast "&a----------------------------------------------"
        broadcast "&c[&6Warning System&c] &6%player% &cwarned &6%arg-1%"
        broadcast "&c[&6Warning System&c] They now have %{warns.%arg-1's uuid%}% warn(s)."
        broadcast "&c[&6Warning System&c] Reason: &6%arg-2%"
        broadcast "&a----------------------------------------------"
# Checks if warn count is divisible by 5 and if it is, it bans the player
        {warns.%arg-1's uuid%} is divisible by 5:
          {warns.%arg-1's uuid%} is not 0:
            console command "tempban %arg-1% 3h &4&lHaving too many warnings!"

# Unwarn Command
command /unwarn <offline player>:
  permission: warn.sk
  permission message: &4&lYou do not have permission to use this command!
  trigger:
    if arg-1 is set:
      if {warns.%arg-1's uuid%} is 0:
        send "&a----------------------------------------------" to player
        send "&c[&6Warning System&c] You can't have negative warns!" to player
        send "&a----------------------------------------------" to player
      if {warns.%arg-1's uuid%} is not 0:
        remove 1 from {warns.%arg-1's uuid%}
        broadcast "&a----------------------------------------------"
        broadcast "&c[&6Warning System&c] &6%player% &cunwarned &6%arg-1%"
        broadcast "&c[&6Warning System&c] They now have %{warns.%arg-1's uuid%}% warn(s)."
        broadcast "&a----------------------------------------------"

# Check Warns Command
command /checkwarns <offline player>:
  permission: warn.sk
  permission message: &4&lYou do not have permission to use this command!
  trigger:
    broadcast "&a----------------------------------------------"
    broadcast "&c[&6Warning System&c] &6%arg-1% &chas %{warns.%arg-1's uuid%}% &cwarn(s)."
    broadcast "&a----------------------------------------------"

# Clear Warns Command
command /clearwarns <offline player>:
  permission: warn.sk
  permission message: &4&lYou do not have permission to use this command!
  trigger:
    set {warns.%arg-1's uuid%} to 0
    broadcast "&a----------------------------------------------"
    broadcast "&c[&6Warning System&c] &6%player% &chas cleared &6%arg-1%&6's &cwarnings."
    broadcast "&a----------------------------------------------"
 
Use :: instead of . in variables
{variable.%player's uuid%} -> {variable::%player's uuid%}

For the offline message thing, start by checking if the target is offline when you use the warn command. If they are offline, save the warn message in some other variable. When they join, check if that variable is set and send the messages to them.
 
Use :: instead of . in variables
{variable.%player's uuid%} -> {variable::%player's uuid%}

For the offline message thing, start by checking if the target is offline when you use the warn command. If they are offline, save the warn message in some other variable. When they join, check if that variable is set and send the messages to them.

Thank you but i'm really new to Skript, i don't know how to code the offline message thing based on your tutorial.
And please, what is the difference between :: and . in variables ?
 
Can someone tell me if this one is good ?

Code:
options:
  use-permission-permissions: true

command /warn <player> <text>:
    permission: warn.sk
    trigger:
        set {_reason} to arg-2
        if arg-1 is not online:
            set {_offlinePlayer} to arg-1
            set {_offlineWarnsFile} to file("plugins/Skript/warns.yml")
            set {_offlinePlayerData} to {_offlineWarnsFile's value of {_offlinePlayer's name}}
            set {_offlineWarns} to {_offlinePlayerData's warns} + 1
            set {_offlinePlayerData's warns} to {_offlineWarns}
            set {_offlinePlayerData's lastReason} to {_reason}
            set {_offlineWarnsFile's value of {_offlinePlayer's name}} to {_offlinePlayerData}
            send "{@prefix} &cYou have been warned for {_reason}! Total warns: {_offlineWarns}"
            if {_offlineWarns} is greater than or equal to 3:
                ban {_offlinePlayer} for 2 days
                set {_offlinePlayerData's warns} to 0
                set {_offlineWarnsFile's value of {_offlinePlayer's name}} to {_offlinePlayerData}
        else:
            set {_player} to arg-1
            set {_warnsFile} to file("plugins/Skript/warns.yml")
            set {_playerData} to {_warnsFile's value of {_player's name}}
            set {_warns} to {_playerData's warns} + 1
            set {_playerData's warns} to {_warns}
            set {_playerData's lastReason} to {_reason}
            set {_warnsFile's value of {_player's name}} to {_playerData}
            send "{@prefix} &cYou have been warned for {_reason}! Total warns: {_warns}"
            if {_warns} is greater than or equal to 3:
                ban {_player} for 2 days
                set {_playerData's warns} to 0
                set {_warnsFile's value of {_player's name}} to {_playerData}

on join:
    set {_player} to player
    set {_warnsFile} to file("plugins/Skript/warns.yml")
    if {_warnsFile's value of {_player's name}} is set:
        send "{@prefix} &cYou have {_warnsFile's value of {_player's name}.warns} warns. Last reason: {_warnsFile's value of {_player's name}.lastReason}. Behave well!"
 
Can someone tell me if this one is good ?

Code:
options:
  use-permission-permissions: true

command /warn <player> <text>:
    permission: warn.sk
    trigger:
        set {_reason} to arg-2
        if arg-1 is not online:
            set {_offlinePlayer} to arg-1
            set {_offlineWarnsFile} to file("plugins/Skript/warns.yml")
            set {_offlinePlayerData} to {_offlineWarnsFile's value of {_offlinePlayer's name}}
            set {_offlineWarns} to {_offlinePlayerData's warns} + 1
            set {_offlinePlayerData's warns} to {_offlineWarns}
            set {_offlinePlayerData's lastReason} to {_reason}
            set {_offlineWarnsFile's value of {_offlinePlayer's name}} to {_offlinePlayerData}
            send "{@prefix} &cYou have been warned for {_reason}! Total warns: {_offlineWarns}"
            if {_offlineWarns} is greater than or equal to 3:
                ban {_offlinePlayer} for 2 days
                set {_offlinePlayerData's warns} to 0
                set {_offlineWarnsFile's value of {_offlinePlayer's name}} to {_offlinePlayerData}
        else:
            set {_player} to arg-1
            set {_warnsFile} to file("plugins/Skript/warns.yml")
            set {_playerData} to {_warnsFile's value of {_player's name}}
            set {_warns} to {_playerData's warns} + 1
            set {_playerData's warns} to {_warns}
            set {_playerData's lastReason} to {_reason}
            set {_warnsFile's value of {_player's name}} to {_playerData}
            send "{@prefix} &cYou have been warned for {_reason}! Total warns: {_warns}"
            if {_warns} is greater than or equal to 3:
                ban {_player} for 2 days
                set {_playerData's warns} to 0
                set {_warnsFile's value of {_player's name}} to {_playerData}

on join:
    set {_player} to player
    set {_warnsFile} to file("plugins/Skript/warns.yml")
    if {_warnsFile's value of {_player's name}} is set:
        send "{@prefix} &cYou have {_warnsFile's value of {_player's name}.warns} warns. Last reason: {_warnsFile's value of {_player's name}.lastReason}. Behave well!"
Try it but it looks like there are gonna be some issues with it. Plus, you dont need to make your own file storage, you can use variables and let skript handle the file stuff for you
 
  • Like
Reactions: Hysean
Thank you but i'm really new to Skript, i don't know how to code the offline message thing based on your tutorial.
And please, what is the difference between :: and . in variables ?
When you use :: in a variable it becomes a list variable. This means you can manage the data better because you can loop a list variable (unlike a normal variable). For example:
AppleScript:
command /addplayer <player>:
  trigger:
    add arg-1 to {players::*}
    send "added %arg-1% to list"

command /removeplayer <player>:
  trigger:
    if {players::*} contains arg-1:
      remove arg-1 from {players::*}
      send "removed %arg-1% from list"
    else:
      send "%arg-1% is already not in list"

command /loop:
  trigger:
    loop {players::*}:
      send "%loop-value% was added as ##%loop-index%"
It is also easier to delete all playerdata as you only have to do delete {players::*} rather than looping all offline players and deleting their variable. I recommend checking out this tutorial, both for variables and judt normal skript knowledge. https://sovdee.gitbook.io/skript-tutorials/
 
  • Like
Reactions: Hysean