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

Solved addOutfit in quest system?

Alvanea

;__;
Joined
Jul 1, 2012
Messages
128
Reaction score
34
Location
Poland
Hello. I was trying to modify quest system to add outfit reward to normal reward, but I don't even know If it's possible.

I'm using TFS 1.0.

It doesn't work of course. I just copied it from experience. ;3 /btw, I forgot about gender

Is there any way to do it in this system? I'm trying few hours to add this, but I can't do that.

I was trying to do it just based on storage in outfits.xml by adding 'storage="2215"', 'quest="2215"', 'storageId="2215" storageValue="2215"' but still NOTHING. I was looking in other threads on otland too. ;v

Code:
local specialQuests = {
   [2215] = 2215, -- anni
}

local questsExperience = {
   [2215] = 100000, -- anni
}

local questOutfits = {
   [2215] = 542, --anni demon outfit
}

local tutorialIds = {
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   local storage = specialQuests[item.actionid]
   if not storage then
     storage = item.uid
     if storage > 65535 then
       return false
     end
   end

   local player = Player(cid)
   if player:getStorageValue(storage) > 0 then
     player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'The ' .. ItemType(item.itemid):getName() .. ' is empty.')
     return true
   end

   local targetItem = Item(item.uid)
   local items = {}
   local reward = nil

   local size = targetItem:isContainer() and Container(item.uid):getSize() or 0
   if size == 0 then
     reward = targetItem:clone()
   else
     local container = Container(item.uid)
     for i = 0, container:getSize() - 1 do
       table.insert(items, container:getItem(i):clone())
     end
   end

   size = #items
   if size == 1 then
     reward = items[1]:clone()
   end

   local result = ''
   local weight = 0
   if reward then
     local ret = ItemType(reward:getId())
     if ret:isRune() then
       result = ret:getArticle() .. ' ' ..  ret:getName() .. ' (' .. reward:getSubType() .. ' charges)'
     elseif ret:isStackable() and reward:getCount() > 1 then
       result = reward:getCount() .. ' ' .. ret:getPluralName()
     else
       result = ret:getArticle() .. ' ' .. ret:getName()
     end
     weight = weight + ret:getWeight(reward:getCount())
   else
     if size > 20 then
       reward = Game.createItem(item.itemid, 1)
     elseif size > 8 then
       reward = Game.createItem(1988, 1)
     else
       reward = Game.createItem(1987, 1)
     end

     for i = 1, size do
       local tmp = items[i]
       if reward:addItemEx(tmp) ~= RETURNVALUE_NOERROR then
         print('[Warning] QuestSystem:', 'Could not add quest reward to container')
       else
         local ret = ', '
         if i == size then
           ret = ' and '
         elseif i == 1 then
           ret = ''
         end
         result = result .. ret

         local ret = ItemType(tmp:getId())
         if ret:isRune() then
           result = result .. ret:getArticle() .. ' ' .. ret:getName() .. ' (' .. tmp:getSubType() .. ' charges)'
         elseif ret:isStackable() and tmp:getCount() > 1 then
           result = result .. tmp:getCount() .. ' ' .. ret:getPluralName()
         else
           result = result .. ret:getArticle() .. ' ' .. ret:getName()
         end
         weight = weight + ret:getWeight(tmp:getCount())
       end
     end
     weight = weight + ItemType(reward:getId()):getWeight()
   end

   if player:addItemEx(reward) ~= RETURNVALUE_NOERROR then
     if player:getFreeCapacity() < weight then
       player:sendCancelMessage('You have found ' .. result .. ' weighing ' .. string.format('%.2f', weight) .. ' oz. You have no capacity.')
     else
       player:sendCancelMessage('You have found ' .. result .. ', but you have no room to take it.')
     end
     return true
   end

   if questsExperience[storage] then
     player:addExperience(questsExperience[storage], true)
   end

   if questOutfits[storage] then
     player:addOutfit(questOutfits[storage], true)
   end

   if tutorialIds[storage] then
     player:sendTutorial(tutorialIds[storage])
     if item.uid == 50080 then
       player:setStorageValue(Storage.RookgaardTutorialIsland.SantiagoNpcGreetStorage, 3)
     end
   end

   player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found ' .. result .. '.')
   player:setStorageValue(storage, 1)
   return true
end

And libs.

Code:
function doPlayerAddExperience(cid, xp)
Player(cid):addExperience(xp, true, true)
return true
end

function doPlayerAddOutfit(cid, outfit)
Player(cid):addOutfit(outfit, true, true)
return true
end
 
Code:
local questOutfits = {
    [2215] = {female = 542, male = 541}, --anni demon outfit
}

if questOutfits[storage] then
    player:addOutfit(questOutfits[storage].female)
    player:addOutfit(questOutfits[storage].male)
end
 
Back
Top