Player dont get removed from Variable list

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

krainser

Member
Jan 27, 2017
60
3
3
35
Argentina
I have a issue trying to remove a player from a variable list named {Chest.Cap::*}
its supose to get removed in a "on damage" event:
I already read everything in the docs and this should work..
code_language.skript:
                add nick name of player to {Chest.Cap::*}
                broadcast "{@BroadcastCapturando}"
                loop {@TiempoDeCap} times:
                    delete {_anvil}
                    if {Chest.Cap::*} does not contain nick name of player:
                        set {_loss} to true
                        exit loop
                    loop blocks in radius 5 around the player:
                        if loop-block is anvil:
                            set {_anvil} to true
                    if {_anvil} is not set:
                        set {_loss} to true
                        exit loop
on damage:
    if {ChestConquer.Game} is true:
        if {Chest.Cap::*} contains nick name of victim:
            remove nick name of victim from {Chest.Cap::*}

I already put some "send" effects between conditions and effect to check if the conditions works, and the condition at line 16 dont works. Any idea what is happening.
The skript loads without errors, any issue.

Thanks for reading
*edit: Fixed bad written code*
 
Last edited:
Try this:

code_language.skript:
on damage:
    if {ChestConquer.Game} is true:
        if "%{Chest.Cap::*}%" contains "%name of victim%":
            remove "%name of victim%" from {Chest.Cap::*}
 
@krainser Alright. Here is you issue. So there is a bug within Skript that has been present for years now. This bug is involving the contains condition of strings in variable lists. Basically if you have two of the same strings or similar strings in a list variables, the contains condition will return an incorrect value. Keep in mind this only happens with strings and list variables (Like what you're doing)

code_language.skript:
add "test1", "test2" and "test3" to {_list::*}
if {_list::*} contains "test":
    #This sometimes gets triggered.
if {_list::*} contains "test4":
    #This sometimes gets triggered
People say it's a simple fix in the coding but it has never been fixed. I might make a pull request after I check it out sometime.

Here is a nice work around for this, using a loop for the variable list

code_language.skript:
loop {Chest.Cap::*}:
    if loop-value is "Your testing object":
        set {_found} to true
        exit loop #For faster response (Optional)
if {_found} is true:
    #this is the same as a contains condition
or
code_language.skript:
loop {Chest.Cap::*}:
    if loop-value is "Your testing object":
        #this is the same as a contains condition
        exit loop #For faster response (Optional)
 
Last edited by a moderator:
@krainser Alright. Here is you issue....

code_language.skript:
add "test1", "test2" and "test3" to {_list::*}
if {_list::*} contains "test":
    #This sometimes gets triggered.
if {_list::*} contains "test4":
    #This sometimes gets triggered
People say it's a simple fix in the coding but it has never been fixed. I might make a pull request after I check it out sometime.

Here is a nice work around for this, using a loop for the variable list

code_language.skript:
loop {Chest.Cap::*}:
    if loop-value is "Your testing object":
        set {_found} to true
        exit loop #For faster response (Optional)
if {_found} is true:
    #this is the same as a contains condition
or
code_language.skript:
loop {Chest.Cap::*}:
    if loop-value is "Your testing object":
        #this is the same as a contains condition
        exit loop #For faster response (Optional)

Wow, thanks for notice me about that error.. i just checked with your code, and it still without working!
My code:
code_language.skript:
on right click on anvil:
    if {ChestConquer.Game} is true:
        set {_loc} to location at event-block
        set {_slot} to 0
        loop 30 times:
            if {ChestConquer.%{_slot}%::*} is {_loc}:
                set {_positivo} to true
                exit loop
            add 1 to {_slot}
        if {_positivo} is true:
            cancel event
            if player does not have permission "cq.cap":
                send "{@CQNoPerm}"
                stop
            if {ChestTamed::%{_slot}%} is not set:
                set {ChestTamed::%{_slot}%} to true
                add player to {Chest.Cap::*}
                broadcast "{@BroadcastCapturando}"
                loop {@TiempoDeCap} times:
                    delete {_found}
                    delete {_anvil}
                    loop {Chest.Cap::*}:
                        if loop-value-2 is player:
                            set {_found} to true
                            exit loop
                    loop blocks in radius 5 around the player:
                        if loop-block is anvil:
                            set {_anvil} to true
                    if {_found} is not true:
                        set {_loss} to true
                        exit loop
                    if {_anvil} is not set:
                        set {_loss} to true
                        exit loop
                    send "{@Capturandose}"
                    wait 1 second
                if {_loss} is true:
                    remove player from {Chest.Cap::*}
                    send "{@CapturandoseLoss}"
                    delete {ChestTamed::%{_slot}%}
                    stop
                if {_loss} is not set:
                    broadcast "{@Capturado}"
                    set {ChestTamed::%{_slot}%} to true
                    remove player from {Chest.Cap::*}
                    strike lightning at {_loc}
                    exit
            if {ChestTamed::%{_slot}%} is true:
                send "{@PuestoOcupado}"
on damage:
    if {ChestConquer.Game} is true:
        loop {Chest.Cap::*}:
            if loop-value is victim:
                set {_found} to true
            if {_found} is true:
                remove player from {Chest.Cap::*}
Thanks for your time, I really appreciate it !
 
Wow, thanks for notice me about that error.. i just checked with your code, and it still without working!
My code:
code_language.skript:
on right click on anvil:
    if {ChestConquer.Game} is true:
        set {_loc} to location at event-block
        set {_slot} to 0
        loop 30 times:
            if {ChestConquer.%{_slot}%::*} is {_loc}:
                set {_positivo} to true
                exit loop
            add 1 to {_slot}
        if {_positivo} is true:
            cancel event
            if player does not have permission "cq.cap":
                send "{@CQNoPerm}"
                stop
            if {ChestTamed::%{_slot}%} is not set:
                set {ChestTamed::%{_slot}%} to true
                add player to {Chest.Cap::*}
                broadcast "{@BroadcastCapturando}"
                loop {@TiempoDeCap} times:
                    delete {_found}
                    delete {_anvil}
                    loop {Chest.Cap::*}:
                        if loop-value-2 is player:
                            set {_found} to true
                            exit loop
                    loop blocks in radius 5 around the player:
                        if loop-block is anvil:
                            set {_anvil} to true
                    if {_found} is not true:
                        set {_loss} to true
                        exit loop
                    if {_anvil} is not set:
                        set {_loss} to true
                        exit loop
                    send "{@Capturandose}"
                    wait 1 second
                if {_loss} is true:
                    remove player from {Chest.Cap::*}
                    send "{@CapturandoseLoss}"
                    delete {ChestTamed::%{_slot}%}
                    stop
                if {_loss} is not set:
                    broadcast "{@Capturado}"
                    set {ChestTamed::%{_slot}%} to true
                    remove player from {Chest.Cap::*}
                    strike lightning at {_loc}
                    exit
            if {ChestTamed::%{_slot}%} is true:
                send "{@PuestoOcupado}"
on damage:
    if {ChestConquer.Game} is true:
        loop {Chest.Cap::*}:
            if loop-value is victim:
                set {_found} to true
            if {_found} is true:
                remove player from {Chest.Cap::*}
Thanks for your time, I really appreciate it !
You need to use victim or attacker not player in the damage event.

code_language.skript:
on damage:
    if {ChestConquer.Game} is true:
        loop {Chest.Cap::*}:
            if loop-value is victim:
                remove victim from {Chest.Cap::*}
                exit loop
 
Status
Not open for further replies.