Ir para conteúdo

Quest System - sem alterar o mapa


Posts Recomendados

Vá em data/lib, crie um arquivo .lua com o nome de 130-newquestsystem.lua e adicione isso -

 

function addItems(thing, items)
local result = ""
for i,v in ipairs(items) do
if (type(v) == "table") then
local tmp = nil

if (v.container ~= nil) then
tmp = getThing(doCreateItemEx(v.container, 1))
result = result .. addItems(tmp, v.items)
else
tmp = getThing(doCreateItemEx(v.id, v.count))
end

if (v.actionid ~= nil) then
doSetItemActionId(tmp.uid, v.actionid)
end

if (v.description ~= nil) then
doSetItemSpecialDescription(tmp.uid, v.description)
end

if(doAddContainerItemEx(thing.uid, tmp.uid) ~= RETURNVALUE_NOERROR) then
print("[Warning] AddItems:", "Something went wrong!")
end

if (v.container == nil) then
local ret = ", "
result = result .. ret
ret = getItemDescriptions(tmp.uid)
if(tmp.type > 0 and isItemRune(tmp.itemid)) then
result = result .. tmp.type .. " charges " .. ret.name
elseif(tmp.type > 0 and isItemStackable(tmp.itemid)) then
result = result .. tmp.type .. " " .. ret.plural
else
result = result .. ret.article .. " " .. ret.name
end
end
else
print("[Warning] AddItems:", "Grr! I expected table!")
end
end
return result
end

function doPlayerAddQuest(cid, items, storage, container)
if(not storage) then
return false
end

if(getCreatureStorage(cid, storage) > 0) then
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "empty message")
return false
end

if (type(items) ~= "table") then
return false
end

local reward = nil
local result = ""
if (#items == 1) then
reward = getThing(doCreateItemEx(items[1].id, items[1].count))
else
if (not container) then
if (#items > 8) then
container = 1988 -- default container bp
else
container = 1987 -- default container bag
end
end
reward = getThing(doCreateItemEx(container, 1))
result = addItems(reward, items)
end

local ret = getItemDescriptions(reward.uid)
local tmp = result
result = "You have found " .. ret.article .. " " .. ret.name
if (tmp ~= "") then
result = result .. tmp
end

 if(doPlayerAddItemEx(cid, reward.uid, false) == RETURNVALUE_NOERROR)then
doCreatureSetStorage(cid, storage, 1)
result = result .. "."
else
result = (getPlayerFreeCap(cid) < getItemWeight(reward.uid)) and result .. ". Weighing " .. getItemWeight(reward.uid) .. " oz it is too heavy." or result .. ", but you have no room to take it."
end
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, result)
return true
end

 

 

 

Como usar?

Criar qualquer action, creatureevent ou o que você quiser para recompensas.

 

Exemplo de código:

local reward = {
{ id = 2400, count = 1, actionid = 1234, description = "holy sword" },
{ id = 2160, count = 10 },
{ container = 1988, items = {
{ id = 2400, count = 1, actionid = 1234, description = "holy sword" },
{ id = 2160, count = 10 },
{ container = 1988, items = {
{ id = 2400, count = 1, actionid = 1234, description = "holy sword" },
{ id = 2160, count = 10 }
}
}
}
}
}
local storage = 1234
local container = 1988 -- main container

function onUse(cid, item, fromPosition, itemEx, toPosition)
doPlayerAddQuest(cid, reward, storage, container)
end

 

Créditos - averatec

Editado por LuckinhaSan
Link para o comentário
Compartilhar em outros sites

como funcionaa??

 

serve pra poketibia???

 

Sim

ma u

 

ltima pergunta .. posso usar este sistema em uma chest que eu colocar no meu mapa?????

 

Creio que sim...

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...