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

TFS 1.X+ Help with script show quests completed

snuckles

Banned User
Joined
Apr 4, 2009
Messages
74
Reaction score
3
Location
Hong Kong
You have probably already seen it this stopped working after tfs 1.X, I have tfs 1.2 but probably even if you transform it to 1.3 it will surely work for me many things work for me but you are an expert so I think you could solve it? I can't get it to work because the "onlook" no longer exists in "creatureevents" so maybe I should create one for "events" but I'm not sure, when you have time help me! Thank you!

Lua:
function onLook(cid, thing, position, lookDistance)
    local quests = {20001, 20003, 20009}
    local completed = {}
    if isPlayer(thing.uid) then
        for i = 1, #quests do
            if getPlayerStorageValue(thing.uid, quests) > 0 then
                table.insert(completed, 1)
            end
        end
        doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .. " has completed ".. #completed .. "/" .. #quests .. " quests")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerName(thing.uid) .. " has completed " .. #completed .. "/" .. #quests .. " quests.")
    end
    return true
end
 
@snuckles

Whenever you use setStorageValue on some storage to change it to a non-default value (so, not -1), the server checks if that storage is used in some quest configuration in quests.xml for a quest.
If yes, it sends the "quest log updated" message.

Check this function in the sources for more info - it happens on this line (657).

More specifically, it uses this function to achieve that check.
 
You have probably already seen it this stopped working after tfs 1.X, I have tfs 1.2 but probably even if you transform it to 1.3 it will surely work for me many things work for me but you are an expert so I think you could solve it? I can't get it to work because the "onlook" no longer exists in "creatureevents" so maybe I should create one for "events" but I'm not sure, when you have time help me! Thank you!

Lua:
function onLook(cid, thing, position, lookDistance)
    local quests = {20001, 20003, 20009}
    local completed = {}
    if isPlayer(thing.uid) then
        for i = 1, #quests do
            if getPlayerStorageValue(thing.uid, quests) > 0 then
                table.insert(completed, 1)
            end
        end
        doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .. " has completed ".. #completed .. "/" .. #quests .. " quests")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, getPlayerName(thing.uid) .. " has completed " .. #completed .. "/" .. #quests .. " quests.")
    end
    return true
end
if you use TFS 1.3+

data/scripts/snuckles.lua
Lua:
local quests = {20001, 20003, 20009}
local ec = EventCallback
function ec.onLook(player, thing, position, distance, description)
    if not thing:isPlayer() then
        return description
    end
    local completed = 0
    for _, storage in pairs(quests) do
        if thing:getStorageValue(storage) > 0 then
            completed = completed +1
        end
    end
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("%s has completed %d / %d quests.", thing:getName(), completed, #quests))
    return string.format("%s\n%s has completed %d / %d quests.", description, (thing:getSex() == 0 and "She" or "He"), completed, #quests)
end
ec:register(6)
 
if you use TFS 1.3+

data/scripts/snuckles.lua
Lua:
local quests = {20001, 20003, 20009}
local ec = EventCallback
function ec.onLook(player, thing, position, distance, description)
    if not thing:isPlayer() then
        return description
    end
    local completed = 0
    for _, storage in pairs(quests) do
        if thing:getStorageValue(storage) > 0 then
            completed = completed +1
        end
    end
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, string.format("%s has completed %d / %d quests.", thing:getName(), completed, #quests))
    return string.format("%s\n%s has completed %d / %d quests.", description, (thing:getSex() == 0 and "She" or "He"), completed, #quests)
end
ec:register(6)

I think it works fine, yes, but I can't test it because I don't know exactly what to add in Creaturescripts.xml, I don't know what kind of "event type" should I add for this script: /

Or unless this goes in player.lua of "Events"?
 
I think it works fine, yes, but I can't test it because I don't know exactly what to add in Creaturescripts.xml, I don't know what kind of "event type" should I add for this script: /

Or unless this goes in player.lua of "Events"?
If you are using TFS 1.3+ there is no need to register anything, just create a new file .lua in the /scripts/ folder in your /data/ and paste the code into that file, save it and do /reload scripts on your server
 
Back
Top