local specialQuests = {
[2001] = 30015 --Annihilator
}
local questsExperience = {
[30015] = 10000
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES)) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF, cid)
return true
end
local storage = specialQuests[item.actionid]
if(not storage) then
storage = item.uid
if(storage > 65535) then
return false
end
end
if(getPlayerStorageValue(cid, storage) > 0) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
return true
end
local items = {}
local reward = 0
local size = isContainer(item.uid) and getContainerSize(item.uid) or 0
if(size == 0) then
reward = doCopyItem(item, false)
else
for i = 0, size do
local tmp = getContainerItem(item.uid, i)
if(tmp.itemid > 0) then
table.insert(items, tmp)
end
end
end
size = table.maxn(items)
if(size == 1) then
reward = doCopyItem(items[1], true)
end
local result = ""
if(reward ~= 0) then
local ret = getItemDescriptions(reward.uid)
if(reward.type > 0 and isItemRune(reward.itemid)) then
result = reward.type .. " charges " .. ret.name
elseif(reward.type > 0 and isItemStackable(reward.itemid)) then
result = reward.type .. " " .. ret.plural
else
result = ret.article .. " " .. ret.name
end
else
if(size > 20) then
reward = doCopyItem(item, false)
elseif(size > 8) then
reward = getThing(doCreateItemEx(1988, 1))
else
reward = getThing(doCreateItemEx(1987, 1))
end
for i = 1, size do
local tmp = doCopyItem(items[i], true)
if(doAddContainerItemEx(reward.uid, tmp.uid) ~= RETURNVALUE_NOERROR) then
print("[Warning] QuestSystem:", "Could not add quest reward")
else
local ret = ", "
if(i == 2) then
ret = " and "
elseif(i == 1) then
ret = ""
end
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
end
end
if(doPlayerAddItemEx(cid, reward.uid, false) ~= RETURNVALUE_NOERROR) then
result = "You have found a reward weighing " .. getItemWeight(reward.uid) .. " oz. It is too heavy or you have not enough space."
else
result = "You have found " .. result .. "."
setPlayerStorageValue(cid, storage, 1)
if(questsExperience[storage] ~= nil) then
doPlayerAddExp(cid, questsExperience[storage])
doSendAnimatedText(getCreaturePosition(cid), questsExperience[storage], TEXTCOLOR_WHITE)
end
end
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, result)
return true
end
local config = {
daily = "no", -- allow only one enter per day? (like in global Tibia)
level = 13,
storage = 30015
entry =
{
{x = 1086, y = 585, z = 5},
{x = 1085, y = 585, z = 5},
{x = 1084, y = 585, z = 5},
{x = 1083, y = 585, z = 5}
},
destination =
{
{x = 1083, y = 573, z = 5},
{x = 1082, y = 573, z = 5},
{x = 1081, y = 573, z = 5},
{x = 1080, y = 573, z = 5}
}
}
config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(item.itemid == 1946) then
if(config.daily) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
else
doTransformItem(item.uid, item.itemid - 1)
end
return true
end
if(item.itemid ~= 1945) then
return true
end
local players = {}
for _, position in ipairs(config.entry) do
local pid = getTopCreature(position).uid
if(pid == 0 or not isPlayer(pid) or getCreatureStorage(pid, config.storage) > 0 or getPlayerLevel(pid) < config.level) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
return true
end
table.insert(players, pid)
end
for i, pid in ipairs(players) do
doSendMagicEffect(config.entry[i], CONST_ME_POFF)
doTeleportThing(pid, config.destination[i], false)
doSendMagicEffect(config.destination[i], CONST_ME_ENERGYAREA)
end
doTransformItem(item.uid, item.itemid + 1)
return true
end
if item.uid == 9501 then
queststatus = getPlayerStorageValue(cid,100)
if queststatus == -1 then
doPlayerSendTextMessage(cid,22,"You have found an demon armor.")
doPlayerAddItem(cid,2494,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9502 then
queststatus = getPlayerStorageValue(cid,100)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found an fire sword.")
doPlayerAddItem(cid,2392,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9503 then
queststatus = getPlayerStorageValue(cid,100)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found pair a boots of haste.")
doPlayerAddItem(cid,2195,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9504 then
queststatus = getPlayerStorageValue(cid,100)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found a 30 ferns.")
doPlayerAddItem(cid,2801,30)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
return 1
end
<action uniqueid="9501" script="name.lua"/>
<action uniqueid="9502" script="name.lua"/>
<action uniqueid="9503" script="name.lua"/>
<action uniqueid="9504" script="name.lua"/>
if item.uid == 9501 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus == -1 then
doPlayerSendTextMessage(cid,22,"You have found an demon armor.")
doPlayerAddItem(cid,2494,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9502 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found an fire sword.")
doPlayerAddItem(cid,2392,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9503 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found pair a boots of haste.")
doPlayerAddItem(cid,2195,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9504 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found a 30 ferns.")
doPlayerAddItem(cid,2801,30)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
return 1
end
if item.uid == 9501 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus == -1 then
doPlayerSendTextMessage(cid,22,"You have found an demon armor.")
doPlayerAddItem(cid,2494,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9502 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found an fire sword.")
doPlayerAddItem(cid,2392,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9503 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found pair a boots of haste.")
doPlayerAddItem(cid,2195,1)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
end
if item.uid == 9504 then
queststatus = getPlayerStorageValue(cid,9500)
if queststatus ~= 1 then
doPlayerSendTextMessage(cid,22,"You have found a 30 ferns.")
doPlayerAddItem(cid,2801,30)
setPlayerStorageValue(cid,9500,1)
else
doPlayerSendTextMessage(cid,22,"It is empty.")
end
return 1
end
[13/07/2010 19:42:29] [Error - Action Interface]
[13/07/2010 19:42:29] data/actions/scripts/name.lua
[13/07/2010 19:42:29] Description:
[13/07/2010 19:42:29] data/actions/scripts/name.lua:1: attempt to index global 'item' (a nil value)
[13/07/2010 19:42:29] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/name.lua)
[13/07/2010 19:42:29] cannot open data/actions/scripts/anni.lua: No such file or directory
local chests = {
[1256] = {itemid=1111,count=1},
[1257] = {itemid=2222,count=1},
[1258] = {itemid=3333,count=1},
[1259] = {itemid=4444,count=1},
[1260] = {itemid=5555,count=1}
}
function onUse(cid,item,toPosition,itemEx,fromPosition)
local r,s,v = chests.uniqueid,1525,getThingPos(cid)
if r then
if getPlayerStorageValue(cid,s) < 0 then
doPlayerGiveItem(cid,r.itemid,r.count)
doPlayerSendTextMessage(cid,27,'You\'ve gained '..getItemArticleById(r.itemid)..' '..getItemNameById(r.itemid)..'.')
setPlayerStorageValue(cid,s,1)
doSendMagicEffect(v,12)
else
doPlayerSendTextMessage(cid,27,'You\'ve already done this quest.')
doSendMagicEffect(v,2)
end
end
return true
end
You won't need a script if you do this: only put the items in chest normally (in map editor!).Use actionID 2001 on all chests, and no uniqueID.