• 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!

Lua purchasing double items

WSouls

New Member
Joined
Aug 5, 2010
Messages
51
Reaction score
1
when people buy items they also get 1 more then what they bought for example. if you buy 1 AOL then u get 2 AOL's in your BP. if you buy 5 Aol's then you get 6 in your BP. i dont get any errors in my console window. any idea what the problem could be?

this is what one of my NPC files look like
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

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'spellbook'}, 2175, 150)
shopModule:addBuyableItem({'magic lightwand'}, 2163, 400)

shopModule:addBuyableItem({'health potion'}, 7618, 45, 1)
shopModule:addBuyableItem({'mana potion'}, 7620, 50, 1)
shopModule:addBuyableItem({'strong health'}, 7588, 100, 1)
shopModule:addBuyableItem({'strong mana'}, 7589, 80, 1)
shopModule:addBuyableItem({'great health'}, 7591, 190, 1)
shopModule:addBuyableItem({'great mana'}, 7590, 120, 1)
shopModule:addBuyableItem({'great spirit'}, 8472, 190, 1)
shopModule:addBuyableItem({'ultimate health'}, 8473, 310, 1)

shopModule:addBuyableItem({'100x hmm'}, 2311, 1200, 100)--
shopModule:addBuyableItem({'100x gfb'}, 2304, 4500, 100)--
shopModule:addBuyableItem({'100x expl'}, 2313, 3040, 100)--
shopModule:addBuyableItem({'100x uh'}, 2273, 10000, 100)--
shopModule:addBuyableItem({'100x sd'}, 2268, 12000, 100)--

shopModule:addSellableItem({'normal potion flask'}, 7636, 5)
shopModule:addSellableItem({'strong potion flask'}, 7634, 10)
shopModule:addSellableItem({'great potion flask'}, 7635, 15)

shopModule:addBuyableItem({'instense healing'}, 2265, 95, 1)
shopModule:addBuyableItem({'ultimate healing'}, 2273, 175, 1)
shopModule:addBuyableItem({'magic wall'}, 2293, 350, 3)
shopModule:addBuyableItem({'destroy field'}, 2261, 45, 3)
shopModule:addBuyableItem({'light magic missile'}, 2287, 40, 10)
shopModule:addBuyableItem({'heavy magic missile'}, 2311, 120, 10)
shopModule:addBuyableItem({'great fireball'}, 2304, 180, 4)
shopModule:addBuyableItem({'explosion'}, 2313, 250, 6)
shopModule:addBuyableItem({'sudden death'}, 2268, 350, 3)
shopModule:addBuyableItem({'death arrow'}, 2263, 300, 3)
shopModule:addBuyableItem({'paralyze'}, 2278, 700, 1)
shopModule:addBuyableItem({'animate dead'}, 2316, 375, 1)
shopModule:addBuyableItem({'convince creature'}, 2290, 80, 1)
shopModule:addBuyableItem({'chameleon'}, 2291, 210, 1)
shopModule:addBuyableItem({'desintegrate'}, 2310, 80,  3)

shopModule:addBuyableItem({'wand of vortex'}, 2190, 500)
shopModule:addBuyableItem({'wand of dragonbreath'}, 2191, 1000)
shopModule:addBuyableItem({'wand of decay'}, 2188, 5000)
shopModule:addBuyableItem({'wand of draconia'}, 8921, 7500)
shopModule:addBuyableItem({'wand of cosmic energy'}, 2189, 10000)
shopModule:addBuyableItem({'wand of inferno'}, 2187, 15000)
shopModule:addBuyableItem({'wand of starstorm'}, 8920, 18000)
shopModule:addBuyableItem({'wand of voodoo'}, 8922, 22000)

shopModule:addBuyableItem({'snakebite rod'}, 2182, 500)
shopModule:addBuyableItem({'moonlight rod'}, 2186, 1000)
shopModule:addBuyableItem({'necrotic rod'}, 2185, 5000)
shopModule:addBuyableItem({'northwind rod'}, 8911, 7500)
shopModule:addBuyableItem({'terra rod'}, 2181, 10000)
shopModule:addBuyableItem({'hailstorm rod'}, 2183, 15000)
shopModule:addBuyableItem({'springsprout rod'}, 8912, 18000)
shopModule:addBuyableItem({'underworld rod'}, 8910, 22000)

shopModule:addSellableItem({'wand of vortex'}, 2190, 250)
shopModule:addSellableItem({'wand of dragonbreath'}, 2191, 500)
shopModule:addSellableItem({'wand of decay'}, 2188, 2500)
shopModule:addSellableItem({'wand of draconia'}, 8921, 3750)
shopModule:addSellableItem({'wand of cosmic energy'}, 2189, 5000)
shopModule:addSellableItem({'wand of inferno'},2187, 7500)
shopModule:addSellableItem({'wand of starstorm'}, 8920, 9000)
shopModule:addSellableItem({'wand of voodoo'}, 8922, 11000)

shopModule:addSellableItem({'snakebite rod'}, 2182, 250)
shopModule:addSellableItem({'moonlight rod'}, 2186, 500)
shopModule:addSellableItem({'necrotic rod'}, 2185, 2500)
shopModule:addSellableItem({'northwind rod'}, 8911, 3750)
shopModule:addSellableItem({'terra rod'}, 2181, 5000)
shopModule:addSellableItem({'hailstorm rod'}, 2183, 7500)
shopModule:addSellableItem({'springsprout rod'}, 8912, 9000)
shopModule:addSellableItem({'underworld rod'}, 8910, 11000)

local items = {[1] = 2190, [2] = 2182, [5] = 2190, [6] = 2182}
function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	if(msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand')) then
		if(isSorcerer(cid) or isDruid(cid)) then
			if(getPlayerStorageValue(cid, 30002) <= 0) then
				selfSay('So you ask me for a {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '} to begin your advanture?', cid)
				talkState[talkUser] = 1
			else
				selfSay('What? I have already gave you one {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '}!', cid)
			end
		else
			selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
		end
	elseif(msgcontains(msg, 'yes')) then
		if(talkState[talkUser] == 1) then
			doPlayerAddItem(cid, items[getPlayerVocation(cid)], 1)
			selfSay('Here you are young adept, take care yourself.', cid)
			setPlayerStorageValue(cid, 30002, 1)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
		selfSay('Ok then.', cid)
		talkState[talkUser] = 0
	end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
it's a very old bug from 0.2
i don't remember where i have the fix but I saw once cykotitan posting it for someone
 
oh thanks for the info. do u think u guys could help me find the solution? i tried like a ton of different searches and none of them had a fix... i only found other people that have the same problem.

and oh i forgot sometimes this error shows up
[15/08/2010 02:46:56] [Error - Npc interface]
[15/08/2010 02:46:56] (Unknown script file)
[15/08/2010 02:46:56] Description:
[15/08/2010 02:46:56] data/npc/lib/npcsystem/modules.lua:1151: bad argument #2 to 'error' (number expected, got string)
[15/08/2010 02:46:56] stack traceback:
[15/08/2010 02:46:56] [C]: in function 'error'
[15/08/2010 02:46:56] data/npc/lib/npcsystem/modules.lua:1151: in function 'callbackOnBuy'
[15/08/2010 02:46:56] data/npc/lib/npcsystem/npchandler.lua:263: in function 'processModuleCallback'
[15/08/2010 02:46:56] data/npc/lib/npcsystem/npchandler.lua:440: in function 'onBuy'
[15/08/2010 02:46:56] data/npc/lib/npcsystem/modules.lua:1292: in function <data/npc/lib/npcsystem/modules.lua:1291>
but im not even sure why or when.... it doesnt happen every time people buy items. i just see it in my console randomly.
 
The problem could be this too, your npc file contains 2 shop scripts, that one which you posted is first and the npc got shop module in his .xml file too, remove other and it should work. I got some problems like that and I fixed them by that way.
Rep++
 
and oh i forgot sometimes this error shows up

but im not even sure why or when.... it doesnt happen every time people buy items. i just see it in my console randomly.
Code:
shopModule:addBuyableItem({'wand of vortex'}, 2190, 500[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'wand of dragonbreath'}, 2191, 1000[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'wand of decay'}, 2188, 5000[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'wand of draconia'}, 8921, 7500[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'wand of cosmic energy'}, 2189, 10000[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'wand of inferno'}, 2187, 15000[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'wand of starstorm'}, 8920, 18000[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'wand of voodoo'}, 8922, 22000[B][COLOR="red"], 1[/COLOR][/B])

shopModule:addBuyableItem({'snakebite rod'}, 2182, 500[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'moonlight rod'}, 2186, 1000[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'necrotic rod'}, 2185, 5000[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'northwind rod'}, 8911, 7500[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'terra rod'}, 2181, 10000[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'hailstorm rod'}, 2183, 15000[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'springsprout rod'}, 8912, 18000[B][COLOR="red"], 1[/COLOR][/B])
shopModule:addBuyableItem({'underworld rod'}, 8910, 22000[B][COLOR="red"], 1[/COLOR][/B])
 
it only happens with stack-able items now that i get 2x of them.
12:19 Bought 34x salmon for 238 gold.
12:19 Bought 34x salmon for 238 gold.

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)



-- OTServ event handling functions start
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
-- OTServ event handling functions end

-- Start shop
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addSellableItem({'Juice Squeezer'}, 5865, 100) 
shopModule:addSellableItem({'Meat'}, 2666, 2, 'Meat')
shopModule:addSellableItem({'Ham'}, 2671, 15)
shopModule:addSellableItem({'Green Perch'}, 7159, 10000) 
shopModule:addSellableItem({'Northern Pike'}, 2669, 5000) 
shopModule:addSellableItem({'Rainbow Trout'}, 7158, 15000) 
shopModule:addSellableItem({'Cheese'}, 2696, 2)
shopModule:addSellableItem({'Carrot'}, 2684, 1) 
shopModule:addSellableItem({'Salmon'}, 2668, 2) 
shopModule:addSellableItem({'Blueberry'}, 2677, 1, 5)
shopModule:addSellableItem({'Cherry'}, 2679, 1) 
shopModule:addSellableItem({'Cookie'}, 2687, 1) 
shopModule:addSellableItem({'Cocktail Glass'}, 10150, 50)
shopModule:addSellableItem({'Golden Mug'}, 2033, 250) 

-------------------player buys
--food
shopModule:addBuyableItem({'Meat'}, 2666, 10, 1)
shopModule:addBuyableItem({'Pumpkin'}, 2683, 10, 1) 
shopModule:addBuyableItem({'Ham'}, 2671, 15, 1) 
shopModule:addBuyableItem({'Bread'}, 2689, 8, 1) 
shopModule:addBuyableItem({'Brown Bread'}, 2691, 4, 1) 
shopModule:addBuyableItem({'Cake'}, 6278, 50, 1) 
shopModule:addBuyableItem({'Dragon Ham'}, 2672, 25, 1) 
shopModule:addBuyableItem({'Ice Cream Cone'}, 8208, 10, 1) 
shopModule:addBuyableItem({'Melon'}, 2682, 13, 1) 
shopModule:addBuyableItem({'Cheese'}, 2696, 12, 1) 
shopModule:addBuyableItem({'Mango'}, 5097, 10, 1) 
shopModule:addBuyableItem({'Scarab Cheese'}, 8112, 100, 1) 
shopModule:addBuyableItem({'Fish'}, 2667, 6, 1) 
shopModule:addBuyableItem({'Valentine\'s Cake'}, 6393, 100, 1) 
shopModule:addBuyableItem({'Corncob'}, 2686, 3, 1) 
shopModule:addBuyableItem({'Roll'}, 2690, 2, 1) 
shopModule:addBuyableItem({'Carrot'}, 2684, 8, 1) 
shopModule:addBuyableItem({'Salmon'}, 2668, 7, 1) 
shopModule:addBuyableItem({'Jalapeño Pepper'}, 8844, 2, 1) 
shopModule:addBuyableItem({'Cucumber'}, 8842, 5, 1) 
shopModule:addBuyableItem({'Grapes'}, 2681, 8, 1) 
--shopModule:addBuyableItem({'Bulb of Garlic'}, xxxx, 4) 
shopModule:addBuyableItem({'Onion'}, 8843, 2, 1) 
shopModule:addBuyableItem({'Pear'}, 2673, 5, 1) 
shopModule:addBuyableItem({'Beetroot'}, 8845, 2, 1) 
shopModule:addBuyableItem({'Plum'}, 8839, 3, 1) 
shopModule:addBuyableItem({'Red Apple'}, 2674, 5, 1) 
shopModule:addBuyableItem({'Banana'}, 2676, 5, 1) 
shopModule:addBuyableItem({'Blueberry'}, 2677, 1, 1) 
shopModule:addBuyableItem({'Cherry'}, 2679, 1, 1) 
shopModule:addBuyableItem({'Lemon'}, 8841, 3, 1) 
shopModule:addBuyableItem({'Raspberry'}, 8840, 1, 1) 
shopModule:addBuyableItem({'Potato'}, 8838, 5, 1) 
shopModule:addBuyableItem({'Tomato'}, 2685, 10, 1) 
shopModule:addBuyableItem({'Red Mushroom'}, 2788, 12, 1) 
shopModule:addBuyableItem({'Strawberry'}, 2680, 2, 1) 
shopModule:addBuyableItem({'Orange'}, 2675, 10, 1) 
shopModule:addBuyableItem({'Cookie'}, 2687, 5, 1) 
shopModule:addBuyableItem({'White Mushroom'}, 2787, 10, 1)  
shopModule:addBuyableItem({'Brown Mushroom'}, 2789, 10, 1) 
--liquid containers
shopModule:addBuyableItem({'Amphora'}, 2023, 4, 1) 
shopModule:addBuyableItem({'Bottle'}, 2007, 3, 1) 
shopModule:addBuyableItem({'Bucket'}, 2005, 4, 1)  
shopModule:addBuyableItem({'Cup'}, 2013, 3, 1) 
shopModule:addBuyableItem({'Jug'}, 2014, 10, 1) 
shopModule:addBuyableItem({'Mug'}, 2012, 4, 1) 
shopModule:addBuyableItem({'Pot'}, 2562, 30, 1) 
shopModule:addBuyableItem({'Rum Flask'}, 5553, 150, 1)  
shopModule:addBuyableItem({'Vase'}, 2008, 3, 1) 
shopModule:addBuyableItem({'Waterskin'}, 2031, 10, 1) 


-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())
also it appears like that error is gone.
 
Code:
<npc name="Tom" script="data/npc/scripts/food.lua" walkinterval="25000" floorchange="0" access="3">
	<health now="150" max="150"/>
	<look type="128" head="20" body="100" legs="50" feet="99" corpse="2212" addons="3"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|. Welcome to my bar!" />
		
		<parameter key="module_keywords" value="1" />
		<parameter key="keywords" value="help;quest;sacrific;sweet;bar of chocolate" />
		<parameter key="keyword_reply1" value="There is not much i can help you with." />
		<parameter key="keyword_reply2" value="I only know of one quest that requires you to sacrifice something." />
		<parameter key="keyword_reply3" value="The other day I over head some men talking they said there is a sign that says you need something sweet." />
		<parameter key="keyword_reply4" value="Well i dont have anything sweet this is a pub not a candy shop." />
		<parameter key="keyword_reply5" value="Yes, yes that may work now you just need to find some chocolate. Maybe you can find some in the jungle its very easy to lose things there." />
	</parameters>
</npc>
whats the free money bug?
 
Lua:
<npc name="Tom" script="data/npc/scripts/food.lua" walkinterval="25000" floorchange="0" access="3">
	<health now="150" max="150"/>
	<look type="128" head="20" body="100" legs="50" feet="99" corpse="2212" addons="3"/>
	<parameters>
		<parameter key="message_greet" value="Hello |PLAYERNAME|. Welcome to my bar!" />
		<parameter key="keywords" value="help;quest;sacrific;sweet;bar of chocolate" />
		<parameter key="keyword_reply1" value="There is not much i can help you with." />
		<parameter key="keyword_reply2" value="I only know of one quest that requires you to sacrifice something." />
		<parameter key="keyword_reply3" value="The other day I over head some men talking they said there is a sign that says you need something sweet." />
		<parameter key="keyword_reply4" value="Well i dont have anything sweet this is a pub not a candy shop." />
		<parameter key="keyword_reply5" value="Yes, yes that may work now you just need to find some chocolate. Maybe you can find some in the jungle its very easy to lose things there." />
	</parameters>
</npc>

USE THIS /\
 
Back
Top