Solved Not saving kills

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

Status
Not open for further replies.

zainmz

Member
Apr 29, 2017
22
1
0
25
Skript Version (do not put latest): Skript bensku-2.5-alpha3
Skript Author: Bensku
Minecraft Version: 1.15.2
---
Full Code:
Code:
on death:
    if world is "world":
        message "&0[&aNOTICE&0]&b You have killed &e%player% &b" to the attacker
        attacker is a player
        add player to {records::%attacker%}
command /track [<player>]:
     if arg 1 is set:
         message " &b%arg-1% has killed &f%{records::%arg-1%}%"

There are no errors, however the problem im facing is that the kills are not getting saved to the list.

The aim of what I am trying to achieve is:
- list of all players killed by a player
 
Skript Version (do not put latest): Skript bensku-2.5-alpha3
Skript Author: Bensku
Minecraft Version: 1.15.2
---
Full Code:
Code:
on death:
    if world is "world":
        message "&0[&aNOTICE&0]&b You have killed &e%player% &b" to the attacker
        attacker is a player
        add player to {records::%attacker%}
command /track [<player>]:
     if arg 1 is set:
         message " &b%arg-1% has killed &f%{records::%arg-1%}%"

There are no errors, however the problem im facing is that the kills are not getting saved to the list.

The aim of what I am trying to achieve is:
- list of all players killed by a player
Everything's wrong in your code

Try this
Code:
#    Victim's combat-tag
on damage of a player:
    if attacker is a player:
        if victim is a player:
            set {lastAttacker.%victim%} to attacker
            wait 30 seconds
            delete {lastAttacker.%victim%}

#    Player death event
on death of a player:
    if {lastAttacker.%victim%} is set:
        if world is "world":
            send "&0[&aNOTICE&0]&b You have killed &e%victim%&b." to {lastAttacker.%victim%}
            add victim to {records::%{lastAttacker.%victim%}%}
            delete {lastAttacker.%victim%}

#   This prevents player from quitting while has combat-tag
on quit:
    if {lastAttacker.%player%} is set:
        message "&0[&aNOTICE&0]&b You have killed &e%player%&b because the player logged out in combat." to {lastAttacker.%victim%}
        add player to {records::%{lastAttacker.%player%}%}
        delete {lastAttacker.%player%}

command /track [<offline player>]:
    usage: /track <player>
    trigger:
        if arg 1 is set:
            if (size of {records::%arg-1%}) > 0:
                set {kills-on-record.%arg-1%} to "%{records::%arg-1%}%"

                replace every " and " with "&b, &f" in {kills-on-record.%arg-1%}
                replace every ", " with "&b, " in {kills-on-record.%arg-1%}
                replace every "<none>" with "" in {kills-on-record.%arg-1%}

                send "&b%arg-1% has killed &f%{kills-on-record.%arg-1%}%&b."
                delete {kills-on-record.%arg-1%}
            else:
                send "&cThis player has no kills on record."
        else:
            send "&cUsage: /track <player>"
Please, mark this as best answer if it works
 
Last edited:
@Dave
Code:
Line 6: An entity cannot be saved, i.e. the contents of the variable {lastAttacker.%the attacked entity%} will be lost when the server stops. (script.sk, line 6: set {lastAttacker.%victim%} to attacker')

Line 21: The expression 'victim' can only be used in a damage or death event (script.sk, line 21: message "&0[&aNOTICE&0]&b You have killed &e%player%&b because the player logged out in combat." to {lastAttacker.%victim%}')

Line 29: '{records::%the 1st argument%}' can only ever have one value at most, thus the 'amount of ...' expression is useless. Use '... exists' instead to find out whether the expression has a value. (script.sk, line 29: if (size of {records::%arg-1%}) > 0:')

Line 38: 'else' has to be placed just after an 'if' or 'else if' section (line 38: else:') (Double check the "if"/"else if" section above the "else" as if it's wrong, then it causes this error. )
 
@Dave
Code:
Line 6: An entity cannot be saved, i.e. the contents of the variable {lastAttacker.%the attacked entity%} will be lost when the server stops. (script.sk, line 6: set {lastAttacker.%victim%} to attacker')

Line 21: The expression 'victim' can only be used in a damage or death event (script.sk, line 21: message "&0[&aNOTICE&0]&b You have killed &e%player%&b because the player logged out in combat." to {lastAttacker.%victim%}')

Line 29: '{records::%the 1st argument%}' can only ever have one value at most, thus the 'amount of ...' expression is useless. Use '... exists' instead to find out whether the expression has a value. (script.sk, line 29: if (size of {records::%arg-1%}) > 0:')

Line 38: 'else' has to be placed just after an 'if' or 'else if' section (line 38: else:') (Double check the "if"/"else if" section above the "else" as if it's wrong, then it causes this error. )
I fixed it. Code: https://pastebin.com/raw/ZMcmds15
Code:
#    Victim's combat-tag
on damage of a player:
    if attacker is a player:
        if victim is a player:
            set {_lastAttacker.%victim%} to attacker
            wait 30 seconds
            delete {_lastAttacker.%victim%}

#    Player death event
on death of a player:
    loop all players:
        if victim is player:
            if {_lastAttacker.%player%} is loop-player:
                send "&0[&aNOTICE&0]&b You have killed &e%player%&b." to {_lastAttacker.%player%}
                add player to {records.%{_lastAttacker.%player%}%::*}
                delete {_lastAttacker.%player%}

#   This prevents player from quitting while has combat-tag
on quit:
    if {_lastAttacker.%player%} is set:
        message "&0[&aNOTICE&0]&b You have killed &e%player%&b because the player logged out in combat." to {_lastAttacker.%player%}
        add player to {records.%{_lastAttacker.%player%}%::*}
        delete {_lastAttacker.%player%}

#    Get the kills on record
command /track [<offline player>]:
    usage: /track <player>
    trigger:
        if arg-1 is set:
            if (size of {records.%arg-1%::*}) > 0:
                set {kills-on-record.%arg-1%} to "%{records.%arg-1%::*}%"

                replace every " and " with "&b, &f" in {kills-on-record.%arg-1%}
                replace every ", " with "&b, " in {kills-on-record.%arg-1%}
                replace every "<none>" with "" in {kills-on-record.%arg-1%}

                send "&b%arg-1% has killed &f%{kills-on-record.%arg-1%}%&b."
                delete {kills-on-record.%arg-1%}
            else:
                send "&cThis player has no kills on record."
        else:
            send "&cUsage: /track <player>"
 
Sadly it does not work, the list does not save players to it, the tracking always return no kills on record.
 
Status
Not open for further replies.