Loop items in inventory looking for specific lore

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

ExpertGang

Member
Nov 8, 2023
4
1
1
I've been trying to get this to work for multiple hours now but i just dont understand how i can make it work

This is the Skript :

on damage of player:
if attacker is a player:
if attacker's tool is a stick:
if name of attacker's tool is "&4&lContraband Checker":
loop all items in the inventory of victim:
if lore of loop-item contains "&4&lCONTRABAND":
apply glowing to victim for 10 seconds


and this is the part that doesn't work :

loop all items in the inventory of victim:
if lore of loop-item contains "&4&lCONTRABAND":
 
are you sure that the lore check is the issue? this code works for me:
Code:
command /test:
    trigger:
        give stone with lore "", "&4&lCONTRABAND", and "" to player
        loop all items in inventory of player:
            if lore of loop-item contains "&4&lCONTRABAND":
                send "contraband"

i had to make it a command since i don't have another account for testing, but the check is the same. do you have any errors? can you post your code using the 'inline code' button so i can see your indents?
 
Im not getting any errors and the skript works without the

loop all items in the inventory of victim:
if lore of loop-item contains "&4&lCONTRABAND":

part so i find it strange that it does work for you

Code:
on damage of player:
    if attacker is a player:
        if attacker's tool is a stick:
            if name of attacker's tool is "&4&lContraband Checker":
                loop all items in the inventory of victim:
                    if lore of loop-item contains "&4&lCONTRABAND":
                        apply glowing to victim for 10 seconds
 
Im not getting any errors and the skript works without the

loop all items in the inventory of victim:
if lore of loop-item contains "&4&lCONTRABAND":

part so i find it strange that it does work for you

Code:
on damage of player:
    if attacker is a player:
        if attacker's tool is a stick:
            if name of attacker's tool is "&4&lContraband Checker":
                loop all items in the inventory of victim:
                    if lore of loop-item contains "&4&lCONTRABAND":
                        apply glowing to victim for 10 seconds
ah! i just realised that attacker is an entity not a player so it has no inventory, you should be able to fix it by doing

Code:
set {_victim} to "%victim%" parsed as player
loop all items in the inventory of {_victim}:
 
Like this??
Code:
on damage of player:
    if attacker is a player:
    set {_victim} to "%victim%" parsed as player
        if attacker's tool is a stick:
            if name of attacker's tool is "&4&lContraband Checker":
                loop all items in the inventory of {_victim}:
                    if lore of loop-item contains "&4&lCONTRABAND":
                        apply glowing to victim for 10 seconds