resetting variables

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

  • LOOKING FOR A VERSION OF SKRIPT?

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

Status
Not open for further replies.

xflyer_23

Member
May 12, 2020
14
0
0
so everytime someone leaves the server their variables reset... help?
Code:
on login:
    set {kills.%player%} to 0
    set {deaths.%player%} to 0

every second in world "world":
    loop all players:
        set {kdr.%loop-player%} to {kills.%loop-player%} / {deaths.%loop-player%}

on death:
    add 1 to {kills.%attacker%}
    add 1 to {deaths.%victim%}

command /stats [<player>]:
    trigger:
        if arg-1 is not set:
            send "&7----------&bStats&7----------"
            send ""
            send "&e&lYour Stats:"
            send "&aKills: &7%{kills.%player%}%"
            send "&cDeaths: &7%{deaths.%player%}%"
            send "&3KDR: &7%{kdr.%player%}%"
            send ""
            send "&7------------------------"
        else:
            if player has permission "stats.view":
                send "&7----------&bStats&7----------"
                send ""
                send "&e&l%arg-1%'s Stats:"
                send "&aKills: &7%{kills.%arg-1%}%"
                send "&cDeaths: &7%{deaths.%arg-1%}%"
                send "&3KDR: &7%{kdr.%arg-1%}%"
                send ""
                send "&7------------------------"
                
command /edit [<player>] [<text>] [<text>]:
    permission: admin
    trigger:
        if arg-1 is set:
            if arg-2 is "kills":
                if arg-3 is set:
                    set {kills.%arg-1%} to arg-3
                    send "&aSuccessfully changed &e%arg-1%&a's kills to &e%arg-3%&a!"
                else:
                    send "&cChoose the amount of kills you want to change!"
        else:
            send "&cChoose a player to edit stats!"
        if arg-2 is "deaths":
            if arg-3 is set:
                set {deaths.%arg-1%} to arg-3
                send "&aSuccessfully changed &e%arg-1%&a's deaths to &e%arg-3%&a!"
        if arg-2 is "clear":
            if arg-3 is not set:
                clear {deaths.%arg-1%}
                clear {kills.%arg-1%}
                send "&aSuccessfully cleared &e%arg-1%&a's stats!"
 
its because of the:
Code:
on login:
  set {kills.%player%} to 0

Try:
Code:
on login:
  if {kills.%player%} is not set:
    set {kills.%player%} to 0

on login:
  if {deaths.%player%} is not set:
    set {deaths.%player%} to 0
also i used 2 spaces and not a tab
 
Status
Not open for further replies.