Landera
Veteran OT User
- Joined
- Nov 24, 2011
- Messages
- 909
- Solutions
- 1
- Reaction score
- 319
Hello all,
Hope somebody could help me with this one.
I've been editing an npc script that basically make you collect 1500 berries in total.
1st time collecting 500 berries you get base outfit
2nd time you collect 500 berries gets you addon 1
3rd time cou collect 500 berries you get the last addon.
but i have no idea how i could make this happen at this point, beware the script can look messy after I did edit it
It is an edit of an addon npc
PS im using TFS1.3
Hope somebody could help me with this one.
I've been editing an npc script that basically make you collect 1500 berries in total.
1st time collecting 500 berries you get base outfit
2nd time you collect 500 berries gets you addon 1
3rd time cou collect 500 berries you get the last addon.
but i have no idea how i could make this happen at this point, beware the script can look messy after I did edit it
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local rtnt = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
npcHandler:setMessage(MESSAGE_GREET, "Greetings, |PLAYERNAME| like to help me with some{ farming}?")
addoninfo = {
['help'] = {cost = 0, items = {{2677,500}}, outfit_female = 1246, outfit_male = 1245, addon = 0, storageID = 10042},
['help'] = {cost = 0, items = {{2677,500}}, outfit_female = 1246, outfit_male = 1245, addon = 1, storageID = 10043},
['help'] = {cost = 0, items = {{2677,500}}, outfit_female = 1246, outfit_male = 1245, addon = 2, storageID = 10044}
-- next storage 10045
}
function creatureSayCallback(cid, type, msg)
local talkUser = cid
if(not npcHandler:isFocused(cid)) then
return false
end
if addoninfo[msg] ~= nil then
if (getPlayerStorageValue(cid, addoninfo[msg].storageID) ~= -1) then
npcHandler:say('You already have helped me enough, thank you.', cid)
npcHandler:resetNpc()
else
local itemsTable = addoninfo[msg].items
local items_list = ''
if table.maxn(itemsTable) > 0 then
for i = 1, table.maxn(itemsTable) do
local item = itemsTable[i]
items_list = items_list .. item[2] .. ' ' .. ItemType(item[1]):getName()
if i ~= table.maxn(itemsTable) then
items_list = items_list .. ', '
end
end
end
local text = ''
if (addoninfo[msg].cost > 0) then
text = addoninfo[msg].cost .. ' gp'
elseif table.maxn(addoninfo[msg].items) then
text = items_list
elseif (addoninfo[msg].cost > 0) and table.maxn(addoninfo[msg].items) then
text = items_list .. ' and ' .. addoninfo[msg].cost .. ' gp'
end
npcHandler:say('Thank you for helping me please bring me ' .. text .. '. Did you farm enough blueberry?', cid)
rtnt[talkUser] = msg
talkState[talkUser] = addoninfo[msg].storageID
return true
end
elseif msgcontains(msg, "yes") then
if (talkState[talkUser] > 10010 and talkState[talkUser] < 10100) then
local items_number = 0
if table.maxn(addoninfo[rtnt[talkUser]].items) > 0 then
for i = 1, table.maxn(addoninfo[rtnt[talkUser]].items) do
local item = addoninfo[rtnt[talkUser]].items[i]
if (getPlayerItemCount(cid,item[1]) >= item[2]) then
items_number = items_number + 1
end
end
end
if(getPlayerMoney(cid) >= addoninfo[rtnt[talkUser]].cost) and (items_number == table.maxn(addoninfo[rtnt[talkUser]].items)) then
doPlayerRemoveMoney(cid, addoninfo[rtnt[talkUser]].cost)
if table.maxn(addoninfo[rtnt[talkUser]].items) > 0 then
for i = 1, table.maxn(addoninfo[rtnt[talkUser]].items) do
local item = addoninfo[rtnt[talkUser]].items[i]
doPlayerRemoveItem(cid,item[1],item[2])
end
end
doPlayerAddOutfit(cid, addoninfo[rtnt[talkUser]].outfit_male, addoninfo[rtnt[talkUser]].addon)
doPlayerAddOutfit(cid, addoninfo[rtnt[talkUser]].outfit_female, addoninfo[rtnt[talkUser]].addon)
setPlayerStorageValue(cid,addoninfo[rtnt[talkUser]].storageID,1)
npcHandler:say('Here, a little present for helping me.', cid)
else
npcHandler:say('You do not farmed enough yet.', cid)
end
rtnt[talkUser] = nil
talkState[talkUser] = 0
npcHandler:resetNpc()
return true
end
elseif msgcontains(msg, "farming") then
npcHandler:say('Ah yea, Id could use some {help}', cid)
rtnt[talkUser] = nil
talkState[talkUser] = 0
npcHandler:resetNpc()
return true
else
if talkState[talkUser] ~= nil then
if talkState[talkUser] > 0 then
npcHandler:say('Please come back if you have enough.', cid)
rtnt[talkUser] = nil
talkState[talkUser] = 0
npcHandler:resetNpc()
return true
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
It is an edit of an addon npc
PS im using TFS1.3