zexus
Member
- Joined
- Oct 1, 2016
- Messages
- 133
- Reaction score
- 18
i have this amazing quest system, where players can do quests more then one time, i mean
you can do katana quest on rookgaard each 10 hours, it is working for every quest
quests.lua
I tried this, but its not working
/talkactions/scripts/quests.lua
Is anyone could help me to make it work?
you can do katana quest on rookgaard each 10 hours, it is working for every quest
quests.lua
Code:
local mins = 60
local hours = 60 * 60
local days = 24 * 60 * 60
local quests = {
-- /data/creaturescripts/quests.lua
-- rook
[8000] = { name = "Sabre Rook", item = 2385, lvl = 1, time = 15 * mins},
[8001] = { name = "Doublet Rook", item = 2485, lvl = 2, time = 30 * mins},
[8002] = { name = "Studded Shield Rook", item = 2526, lvl = 3, time = 50 * mins},
[8003] = { name = "Copper Shield Rook", item = 2530, lvl = 5, time = 3 * hours},
[8004] = { name = "Legion Helmet Rook", item = 2480, lvl = 5, time = 5 * hours},
[8005] = { name = "Katana Rook", item = 2412, lvl = 5, time = 10 * hours},
}
function isLevelRequired(value)
return type(value) == "table" and true, value.item, value.lvl or false, value
end
function onUse(cid, item, fromPos, item2, toPos)
local levelRequired, quest, level = isLevelRequired(quests[item.actionid])
if levelRequired then
if getPlayerLevel(cid) < level then
doPlayerSendCancel(cid, "Sorry, level: " .. level .. " or higher to complete this quest.")
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
return true
end
end
if quest then
local storage = 200000 + item.actionid
local quest = quests[item.actionid]
if quest then
local timeNow = os.time()
if timeNow - getPlayerStorageValue(cid, item.actionid) >= 0 then
if getPlayerFreeCap(cid) >= getItemWeightById(quest.item, 1) then
doPlayerAddItem(cid, quest.item, 1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a '..getItemNameById(quest.item)..'.')
setPlayerStorageValue(cid, item.actionid, timeNow + quest.time)
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a '..getItemNameById(quest.item)..'. It weighs '..getItemWeightById(quest.item, 1)..'.00 and it is too heavy.')
end
elseif getPlayerStorageValue(cid, item.actionid) < 0 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
elseif getPlayerStorageValue(cid, item.actionid)-timeNow > days then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil(((getPlayerStorageValue(cid, item.actionid)) - timeNow)/days) ..' days to do it again.')
elseif getPlayerStorageValue(cid, item.actionid)-timeNow > hours then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil(((getPlayerStorageValue(cid, item.actionid)) - timeNow)/hours) ..' hours to do it again.')
else
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty, you must wait '.. math.ceil(((getPlayerStorageValue(cid, item.actionid)) - timeNow)/mins) ..' minutes to do it again.')
end
end
end
return true
end
I tried this, but its not working
/talkactions/scripts/quests.lua
Code:
dofile(getDataDir() .. "actions/scripts/actions.lua")
function onSay(cid, words, param, channel)
local finalStr = ""
for q=8000,8200,+1 do
if quest then
if getPlayerStorageValue(cid, item.actionid) < 0 then
local timeToWait
elseif getPlayerStorageValue(cid, item.actionid)-timeNow > days then
timeToWait = 'is in exausted, wait '.. math.ceil(((getPlayerStorageValue(cid, item.actionid)) - timeNow)/days) ..' days to do it again.')
elseif getPlayerStorageValue(cid, item.actionid)-timeNow > hours then
timeToWait = 'is in exausted, wait '.. math.ceil(((getPlayerStorageValue(cid, item.actionid)) - timeNow)/hours) ..' hours to do it again.')
else
timeToWait = 'is in exausted, wait '.. math.ceil(((getPlayerStorageValue(cid, item.actionid)) - timeNow)/mins) ..' minutes to do it again.')
end
finalStr = finalStr .. "[" .. quest.name .. "]: " .. timeToWait .. + "\n"
end
end
end
doShowTextDialog(cid, 2175, finalStr)
return true
end
Is anyone could help me to make it work?