Hello, I'm trying to create some parcel npcs that will give you a discount if you have done postman quest. So basicly
If storagevalue==X then
Showtradewindow 1
elseif storagevalue ~=X then
Showtradewindow2
end
Its working but only once, for example
If i say trade the npc opens the correct window with the correct price then if I say Bye,Hi and Trade he will answear that he dont have any items to offer?
I can figure out why this happends...
Here is the script (I modified it some so 95% of the credits goes to the original Author(Cant remember who posted it =/))
I know it's a mess
Thanks for any help!
//Massen
If storagevalue==X then
Showtradewindow 1
elseif storagevalue ~=X then
Showtradewindow2
end
Its working but only once, for example
If i say trade the npc opens the correct window with the correct price then if I say Bye,Hi and Trade he will answear that he dont have any items to offer?
I can figure out why this happends...
Here is the script (I modified it some so 95% of the credits goes to the original Author(Cant remember who posted it =/))
Lua:
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return FALSE
end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
local quest = getPlayerStorageValue(cid, 2000)
local no = {
{id=2421, buy=50, sell=0, name="thunder hammer"},
}
local items = {}
for _, item in ipairs(no) do
items[item.id] = {storage = item.storage, item_id = item.id, buyPrice = item.buy, sellPrice = item.sell, subType = 0, realName = item.name}
end
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if items[item].buyPrice ~= 0 then
doPlayerRemoveMoney(cid, amount * items[item].buyPrice)
for i = 1, amount do
doPlayerAddItem(cid, items[item].item_id, amount)
end
selfSay('You bought '..amount..' '..items[item].realName..' for '..items[item].buyPrice * amount..' gold coins.')
end
end
local yes = {
{id=2421, buy=5, sell=0, name="thunder hammer"},
}
local items2 = {}
for _, item in ipairs(yes) do
items2[item.id] = {storage = item.storage, item_id = item.id, buyPrice = item.buy, sellPrice = item.sell, subType = 0, realName = item.name}
end
local onBuy2 = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if items2[item].buyPrice ~= 0 then
doPlayerRemoveMoney(cid, amount * items2[item].buyPrice)
for i = 1, amount do
doPlayerAddItem(cid, items2[item].item_id, amount)
end
selfSay('You bought '..amount..' '..items2[item].realName..' for '..items2[item].buyPrice * amount..' gold coins.')
end
end
if (msgcontains(msg, 'trade')) and quest~=1 then
openShopWindow(cid, no, onBuy, onSell)
selfSay('Sure, take a look.')
elseif (msgcontains(msg, 'trade')) and quest==1 then
openShopWindow(cid, yes, onBuy2, onSell)
selfSay('Oh a post officer! here\s some special prices just for you.')
end
end
I know it's a mess
Thanks for any help!
//Massen