• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Rare name item in Broadcast Message

Allan Silva

Member
Joined
May 30, 2018
Messages
39
Solutions
1
Reaction score
7
Script: Roulette System by Xikini

Hello everyone!

I'm using Xikini roulette system and I made a small change, the roulette generates items with rarities (rare, epic, legendary). The rarity is assigned to item normally, but rarity prefix does not appear in message, only name of item, as shown below.

Message when winning item and the item that was received.
1702059933899.png
Note: I put script to return null value if the item name is not rare, epic or legendary, as shown below.


Function to check the rarity of the item.
Lua:
    -- Function to check the rarity of the item
    function checkRarity(item)
        local itemName = item:getName()

        if itemName:find("rare") then
            return "rare"
        elseif itemName:find("epic") then
            return "epic"
        elseif itemName:find("legendary") then
            return "legendary"
        else
            return "nul"
        end
    end

    local playerName = player:getName()
    local itemName = item:getName()
    local itemRarity = checkRarity(item)
    print("Item Rarity: " .. itemRarity)
    print("Item name: " .. itemName)

    broadcastMessage("The player " .. playerName .. " won a " .. itemRarity .. " " .. itemName .. " from the roulette!", MESSAGE_EVENT_ADVANCE)


I see in terminal (with print in scripts) that name of item searches not come with a prefix and it's returning null.
1702060039059.png

I don't know any other way to search for the name assigned to item (rare, epic or legendary), to put the attribution in the message.
Would anyone have a solution to this problem?

Any help is welcome.
Thank you!
 

Attachments

Back
Top