• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Trade if storage is X else trade normal Semi complete!

Massen

Masserv RPG
Joined
Jul 23, 2007
Messages
324
Reaction score
1
Location
Sweden
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 =/))

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 :p


Thanks for any help!

//Massen
 
Back
Top