I need help again. It seems I failed in editing NPC script sent to me in my other thread by Sonical. Base script worked with 1 item but I want the NPC to sell many different items for 'niebieski krysztal' - id 10584 as cash.
The thing is that when I am buying the first offer from this npc (winged helmet) everything is working properly:
Sorry for my nubishness and halp plz. I give rep fo sho.
The thing is that when I am buying the first offer from this npc (winged helmet) everything is working properly:
Here he deletes 25 niebieski krysztal from my bp and adds winged helmet to my bp. All is OK. The problems start when I want to buy second, third and etc offered items:14:49 Handlarz: Welcome, GOD Leviathan! I have been expecting you.
14:49 GOD Leviathan [396]: winged helmet
14:49 Handlarz: Czy chcesz kupic winged helmet za 25 niebieskich krysztalow?
14:49 GOD Leviathan [396]: yes
14:49 Handlarz: Prosze, oto Twoj przedmiot.
As you can see it is everything OK in the chat window, he asks me for correct value (35 niebieski krysztal) and he says "yalahari mask" but he deletes my 25 niebieski krysztal instead of 35 and he gives me winged helmet instead of yalahari mask. Same with yalahari armor and leg piece.14:53 Handlarz: Welcome, GOD Leviathan! I have been expecting you.
14:53 GOD Leviathan [396]: yalahari mask
14:53 Handlarz: Czy chcesz kupic yalahari mask za 35 niebieskich krysztalow?
14:53 GOD Leviathan [396]: yes
14:53 Handlarz: Prosze, oto Twoj przedmiot.
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
--CONFIG
local itemi = 2474 --winged helmet
local cash = 10584 --item id of "cash"
local count = 25
local itemi2 = 9778 --yalahari mask
local count2 = 35
local itemi3 = 9776 --yalahari armor
local count3 = 35
local itemi4 = 9777 --yalahari leg piece
local count4 = 35
local itemi5 = 8710
local count5 = 5
local itemi6 = 8710
local count6 = 5
local itemi7 = 8710
local count7 = 5
local itemi8 = 8710
local count8 = 5
--CONFIG END
if(msgcontains(msg, 'winged helmet')) then
npcHandler:say("Czy chcesz kupic "..getItemNameById(itemi).." za "..count.." niebieskich krysztalow?", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if doPlayerRemoveItem(cid, cash, count) == true then
npcHandler:say("Prosze, oto Twoj przedmiot.", cid)
doPlayerAddItem(cid, itemi, 1)
talkState[talkUser] = 0
else
npcHandler:say("Nie masz przy sobie odpowiedniej ilosci niebieskich krysztalow.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
npcHandler:say("Nie to nie.", cid)
talkState[talkUser] = 0
end
if(msgcontains(msg, 'yalahari mask')) then
npcHandler:say("Czy chcesz kupic "..getItemNameById(itemi2).." za "..count2.." niebieskich krysztalow?", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if doPlayerRemoveItem(cid, cash, count2) == true then
npcHandler:say("Prosze, oto Twoj przedmiot.", cid)
doPlayerAddItem(cid, itemi2, 1)
talkState[talkUser] = 0
else
npcHandler:say("Nie masz przy sobie odpowiedniej ilosci niebieskich krysztalow.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
npcHandler:say("Nie to nie.", cid)
talkState[talkUser] = 0
end
if(msgcontains(msg, 'yalahari armor')) then
npcHandler:say("Czy chcesz kupic "..getItemNameById(itemi3).." za "..count3.." niebieskich krysztalow?", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if doPlayerRemoveItem(cid, cash, count3) == true then
npcHandler:say("Prosze, oto Twoj przedmiot.", cid)
doPlayerAddItem(cid, itemi3, 1)
talkState[talkUser] = 0
else
npcHandler:say("Nie masz przy sobie odpowiedniej ilosci niebieskich krysztalow.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
npcHandler:say("Nie to nie.", cid)
talkState[talkUser] = 0
end
if(msgcontains(msg, 'yalahari leg piece')) then
npcHandler:say("Czy chcesz kupic "..getItemNameById(itemi4).." za "..count4.." niebieskich krysztalow?", cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if doPlayerRemoveItem(cid, cash, count4) == true then
npcHandler:say("Prosze, oto Twoj przedmiot.", cid)
doPlayerAddItem(cid, itemi4, 1)
talkState[talkUser] = 0
else
npcHandler:say("Nie masz przy sobie odpowiedniej ilosci niebieskich krysztalow.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
npcHandler:say("Nie to nie.", cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Sorry for my nubishness and halp plz. I give rep fo sho.
Last edited: