zajacmp3
New Member
Hello,
I am running a pokemond server based on TFS 3.6.pl1
My problem is with npc system. I wish to add a quest to it that will check item ID (that is already implemented) and action ID of a quest item.
For bringing the right object NPC will give a item with specified ID and Action ID
I need help with one little thing here:
doSetItemActionId is as I suppose not the best solution to this problem... But the solution is to be found in this line. I just need to remake it a bit cause in this form it is not working correctly.
FULL SCRIPTS:
npc quest system:
NPC FOR THE QUEST
I am running a pokemond server based on TFS 3.6.pl1
My problem is with npc system. I wish to add a quest to it that will check item ID (that is already implemented) and action ID of a quest item.
For bringing the right object NPC will give a item with specified ID and Action ID
I need help with one little thing here:
PHP:
if quest['prize_items'][1] then
for (i, v in ipairs(quest['prize_items']) and i, v in ipairs(quest['prize_actionid'])) do
(doPlayerAddItem(cid, v, quest['prize_items_value'][i]) and doSetItemActionId(uid, quest['prize_actionid'][i]))
end
end
FULL SCRIPTS:
npc quest system:
PHP:
function quest_system(cid, type, msg, quest, quest_npc_talk, talkUser, talkState)
storage = quest['storage'][1]
st_start = quest['storage'][2]
st_request = quest['storage'][3]
st_done = quest['storage'][4]
questid = getStorage(cid, storage)
if(msg == "hi") then
if getNpcDistanceToCreature(cid) > 3 then
return true
else
selfSay(quest_npc_talk[0], cid, false)
talkState[talkUser] = 1
end
end
if(msg == "quest") and talkState[talkUser] == 1 then
if questid == st_start then
--------need-start-------
if getPlayerLevel(cid) < quest['options'].level then
quest_low_level(cid, quest)
return true
end
if getPlayerSkill(cid, 0) < quest['options'].pokedex then
quest_low_unlocked(cid, quest)
return true
end
--------need-start-------
selfSay(quest_npc_talk[1], cid, false)
setPlayerStorageValue(cid, storage, st_request)
talkState[talkUser] = 2
elseif questid == st_request then
selfSay(quest_npc_talk[2], cid, false)
talkState[talkUser] = 2
elseif questid == st_done then
selfSay(quest_npc_talk[3], cid, false)
talkState[talkUser] = 0
end
elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
--------need-finish-------
quest_status = 0
item_status = 0
if getPlayerMoney(cid) < quest['money'] then
quest_low_money(cid, quest)
quest_status = 1
end
if quest['items'][1] then
for i, v in ipairs(quest['items']) do
if getPlayerItemCount(cid, v) < quest['items_value'][i] then
item_status = 1
end
end
end
if item_status == 1 then
quest_low_items(cid, quest)
talkState[talkUser] = 0
return true
end
if quest_status == 1 then
talkState[talkUser] = 0
return true
end
--------need-finish-------
selfSay(quest_npc_talk[4], cid, false)
setPlayerStorageValue(cid, storage, st_done)
--------remove--------
doPlayerRemoveMoney(cid, quest['money'])
if quest['items'][1] then
for i, v in ipairs(quest['items']) do
doPlayerRemoveItem(cid, v, quest['items_value'][i])
end
end
--------remove--------
--------for-finish-------
if quest['prize_exp'] ~= 0 then
doPlayerAddExperience(cid, quest['prize_exp'])
quest_gain_exp(cid, quest)
end
if quest['prize_money'] ~= 0 then
doPlayerAddMoney(cid, quest['prize_money'])
quest_gain_money(cid, quest)
end
if quest['prize_items'][1] then
for (i, v in ipairs(quest['prize_items']) and i, v in ipairs(quest['prize_actionid'])) do
(doPlayerAddItem(cid, v, quest['prize_items_value'][i]) and doSetItemActionId(uid, quest['prize_actionid'][i]))
end
end
--------for-finish-------
end
end
NPC FOR THE QUEST
PHP:
local talkState = {}
function onCreatureSay(cid, type, msg)
talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
quest = {
['options'] = {level = 1, pokedex = 1},
['storage'] = {10101, -1, 1, 2},
['items'] = {2299, 5462},
['items_value'] = {2, 1},
['money'] = 0,
['prize_items'] = {5462},
['prize_actionid'] = {10019},
['prize_items_value'] = {1},
['prize_exp'] = 2000,
['prize_money'] = 0
}
quest_npc_talk = {
[0] = "Witaj nieznajomy...",
[1] = "Potrzebuje 2 thunderstone aby ewoluowac Twojego pikachu",
[2] = "Dziekuje bardzo! Oto Twoj nowy-stary pokemon!",
[3] = "Niestety juz raz ewoluowales u mnie pikachu!",
[4] = "Dziekuje! Do widzenia!",
}
storage_before = getStorage(cid, quest['storage'][1])
quest_system(cid, type, msg, quest, quest_npc_talk, talkUser, talkState)
storage_after = getStorage(cid, quest['storage'][1])
if storage_before == quest['storage'][3] and storage_after == quest['storage'][4] then
end
end