• 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 commands quests done

Darius93

New Member
Joined
Oct 16, 2022
Messages
3
Reaction score
0
Hello, I have a problem, among others, I would like to execute a command that after entering !quests the following text will appear for the player:
You complet quest: dhq, poi, desert

Lua:
questId = {
[1] = {name = "Annhi", text = "Ksss Ksss", storage = 97770},
[2] = {name = "DHQ", text = "Ksss Ksss", storage = 97771},
[3] = {name = "poi", text = "Ksss Ksss", storage = 97772},
[4] = {name = "desert", text = "Ksss Ksss", storage = 97773}
}
function onSay(player, words, param)
if param == "" then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,  "Wykonales: .")
end
return false
end

From the technical side, it looks like this: I have such a table and I would like it to check whether the storage is equal to 1 (what is in the table) when, for example, the player has storage with Annhi and DHQ equal to 1, it will return.
Complet quests: Annhi, DHQ.
 
I don't know what your version of TFS is. When you post, it is important to provide your engine version so that we can identify and help correct your script.

Lua:
questId = {
    [1] = {name = "Annhi", text = "Ksss Ksss", storage = 97770},
    [2] = {name = "DHQ", text = "Ksss Ksss", storage = 97771},
    [3] = {name = "poi", text = "Ksss Ksss", storage = 97772},
    [4] = {name = "desert", text = "Ksss Ksss", storage = 97773}
}

function onSay(player, words, param)
    if param == "" then
        local completedQuests = {} 

        for _, quest in pairs(questId) do
            if player:getStorageValue(quest.storage) == 1 then
                table.insert(completedQuests, quest.name) 
            end
        end

      
        if #completedQuests > 0 then
            local questList = table.concat(completedQuests, ", ") 
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have completed the missions:" .. questList)
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have not completed any missions.")
        end
    end

    return false
end
 
Back
Top