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

Quest look

Streks

New Member
Joined
Feb 27, 2016
Messages
62
Reaction score
2
hi Otlanders,
Code:
function onLook(cid, thing, position, lookDistance)
local quests = {9693, 12606}
local completed = {}
    if isPlayer(thing.uid) then
        for i = 1, #quests do
            if getPlayerStorageValue(thing.uid, quests[I]) > 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, 27, getPlayerName(thing.uid) .. " has completed " .. #completed .. "/" .. #quests .. " quests.")
    end
return true
end

creature script and quest.xml both are ok.


someone can tell me if this is possible ???
I should like to ask you to comment on this issue :p

thank you.
 
Would it be better to use a global table this way you aren't recreating it every time someone looks at the player.
Code:
local quests = {9693, 12606}
local completed = {}

function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) then
        if not completed[thing.uid] or #completed[thing.uid] ~= #quest then
            completed[thing.uid] = {}
            for i = 1, #quests do
                if getPlayerStorageValue(thing.uid, quests[i]) > 0 then
                    table.insert(completed[thing.uid], 1)
                end
            end
        end
        doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .. " has completed ".. #completed .. "/" .. #quests .. " quests")
        doPlayerSendTextMessage(cid, 27, getPlayerName(thing.uid) .. " has completed " .. #completed .. "/" .. #quests .. " quests.")
    end
    return true
end
 
Would it be better to use a global table this way you aren't recreating it every time someone looks at the player.
Code:
local quests = {9693, 12606}
local completed = {}

function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) then
        if not completed[thing.uid] or #completed[thing.uid] ~= #quest then
            completed[thing.uid] = {}
            for i = 1, #quests do
                if getPlayerStorageValue(thing.uid, quests[i]) > 0 then
                    table.insert(completed[thing.uid], 1)
                end
            end
        end
        doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .. " has completed ".. #completed .. "/" .. #quests .. " quests")
        doPlayerSendTextMessage(cid, 27, getPlayerName(thing.uid) .. " has completed " .. #completed .. "/" .. #quests .. " quests.")
    end
    return true
end

thank you @Omni Cloud

mmmmm... How could I be doing this? so can you teach me some tricks? :D
 
Back
Top