Solved Help item to chat

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

bajinzin

New Member
Aug 31, 2021
5
0
1
26
2b76d4f08c3817773e6eb916d0aa838b.png

https://gyazo.com/2b76d4f08c3817773e6eb916d0aa838b



Code:
#------------------
# ChatItem
# - Version 1.7.1
# - Created by D4isDAVID
#------------------
# Dependencies:
# - Minecraft 1.9+
# - Skript 2.5.3+
# - SkBee 1.10.1+
#------------------
# Config
options:
    # itemName - how the item name will look like in chat. default: &8[&r{name}&r &7x{amount}&8]&r
    # {name} is the item name and {amount} is the amount of the item
    itemName: &f[&c@&6{name}&r]
#------------------

on chat:
    set {_slotList::hand} to index of player's hotbar slot
    set {_keywordList::hand::*} to "[hand]", "[item]" and "[i]"
    set {_slotList::offhand} to 40
    set {_keywordList::offhand::*} to "[offhand]"
    set {_slotList::helmet} to 39
    set {_keywordList::helmet::*} to "[helmet]", "[helm]", "[cap]" and "[head]"
    set {_slotList::chestplate} to 38
    set {_keywordList::chestplate::*} to "[chestplate]", "[tunic]" and "[chest]"
    set {_slotList::leggings} to 37
    set {_keywordList::leggings::*} to "[leggings]", "[pants]" and "[legs]"
    set {_slotList::boots} to 36
    set {_keywordList::boots::*} to "[boots]", "[feet]"
    loop indices of {_keywordList::*}:
        loop {_keywordList::%loop-value%::*}:
            message contains loop-value-2
            add {_slotList::%loop-value-1%} to {_items::*}
            add loop-value-2 to {_keywords::*}
            exit 1 loop
    if size of {_keywords::*} > 0:
        cancel event
        set {_message} to message
        loop {_keywords::*}:
            loop indices of {_keywordList::*}:
                {_keywordList::%loop-value-2%::*} contains loop-value-1
                loop {_keywordList::%loop-value-2%::*}:
                    loop-value-3 is not loop-value-1
                    replace all loop-value-3 with "" in {_message}
            set {_messages::*} to {_message} split at "%loop-value%"
            set {_temp} to {_messages::1}
            delete {_messages::1}
            set {_message} to "%{_temp}%%loop-value%%join {_messages::*} with """"%"
            replace all loop-value with "{CIplaceholder}:{%loop-index%}:{CIplaceholder}" in {_message}
        set {_messages::*} to {_message} split at "{CIplaceholder}"
        loop {_messages::*}:
            set {_messages::%loop-index%} to a new text component of "%loop-value%"
            "%loop-value%" is ":{1}:", ":{2}:", ":{3}:", ":{4}:", ":{5}:" or ":{6}:"
            set {_itemIndex} to subtext of "%loop-value%" from characters 3 to 3
            set {_itemIndexes::%{_itemIndex}%} to loop-index
        loop {_items::*}:
            delete {_name}
            set {_item} to loop-value
            if {_item} is a number:
                set {_item} to slot {_item} of player's inventory
            if {_item} is not set:
                set {_messages::%{_itemIndexes::%loop-index%}%} to a new text component of "%{_keywords::%loop-index%}%"
            else if {_item} is not air:
                set {_name} to name of {_item}
                if {_name} is not set:
                    set {_name} to a new translate component from {_item}
                set {_amount} to amount of {_item} in player's inventory
                set {_itemName} to "{@itemName}"
                replace "{name}" with "%{_name}%"  in {_itemName}
                replace "{amount}" with "%{_amount}%" in {_itemName}
                set {_itemName} to a new text component of "%{_itemName}%"
                set hover event of {_itemName} to a new hover event showing {_item}
                set {_messages::%{_itemIndexes::%loop-index%}%} to {_itemName}
            else:
                set {_messages::%{_itemIndexes::%loop-index%}%} to a new text component of "%{_keywords::%loop-index%}%"
        set {_messageFormat::*} to message format split at "[message]"
        replace "[player]" with player's display name in {_messageFormat::1}
        if message format contains message:
            set {_messageFormat::*} to message format split at message
        set {_temp} to a new text component of "%{_messageFormat::1}%"
        delete {_messageFormat::1}
        loop all players:
            send components {_temp}, {_messages::*} and {_messageFormat::*} to loop-player
        send components {_temp}, {_messages::*} and {_messageFormat::*} to console

Link: https://forums.skunity.com/resources/chatitem.1168/

@D4isDAVID
 
Status
Not open for further replies.