hello when my players wants to sell 1x item the npc takes them bouth and gives back the right ammount.. hmm lets say it like this: you have 2 mastermind shields on you, you are using one in your hand and one is in you bag, you want to sell one becuse you need the money, but you still want to keep the other one that you use for defending your self. but when you says hi, trade and the select mastermind shield and drags the meter down to 1 mastermind shield and presses the sell button, the npc takes bouth of you shields.. i have alsy tried with this i had 2 mastermind shield in my backpack and then i tryed to sell 1 but the npc still took both of you shields, But if i have 3 or more masterminds shields in my backpack and tryes to sell them he only takes 2....
here is my script:
please why is he taking 2 instead of one? =(
here is my script:
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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:addSellableItem({'beholder shield'},2518, 1200,'beholder shield')
shopModule:addSellableItem({'guardian shield'},2515, 2000,'guardian shield')
shopModule:addSellableItem({'dragon shield'},2516, 4000,'dragon shield')
shopModule:addSellableItem({'castle shield'},2535, 5000,'castle shield')
shopModule:addSellableItem({'tower shield'},2528, 8000,'tower shield')
shopModule:addSellableItem({'crown shield'},2519, 8000,'crown shield')
shopModule:addSellableItem({'medusa shield'},2536, 9000,'medusa shield')
shopModule:addSellableItem({'phoenix shield'},2539, 16000,'phoenix shield')
shopModule:addSellableItem({'vampire shield'},2534, 15000,'vampire shield')
shopModule:addSellableItem({'demon shield'},2520, 30000,'demon shield')
shopModule:addSellableItem({'mastermind shield'},2514, 45000,'mastermind shield')
shopModule:addSellableItem({'noble armor'},2486, 900,'noble armor')
shopModule:addSellableItem({'hibiscus dress'},8873, 3000,'hibiscus dress')
shopModule:addSellableItem({'knight armor'},2476, 5000,'knight armor')
shopModule:addSellableItem({'focus cape'},8871, 6000,'focus cape')
shopModule:addSellableItem({'mammoth fur cape'},7463, 6000,'mammoth fur cape')
shopModule:addSellableItem({'blue robe'},2656, 10000,'blue robe')
shopModule:addSellableItem({'glacier robe'},7897, 11000,'glacier robe')
shopModule:addSellableItem({'lightning robe'},7898, 11000,'lightning robe')
shopModule:addSellableItem({'magma coat'},7899, 11000,'magma coat')
shopModule:addSellableItem({'terra mantle'},7884, 11000,'terra mantle')
shopModule:addSellableItem({'Spellweavers Robe'},11349, 12000,'Spellweavers Robe')
shopModule:addSellableItem({'crown armor'},2487, 12000,'crown armor')
shopModule:addSellableItem({'zaoan robe'},11350, 12000,'zaoan robe')
shopModule:addSellableItem({'zaoan armor'},11295, 14000,'zaoan armor')
shopModule:addSellableItem({'paladin armor'},8891, 15000,'paladin armor')
shopModule:addSellableItem({'swamplair armor'},8880, 16000,'swamplair armor')
shopModule:addSellableItem({'skullcracker armor'},8889, 18000,'skullcracker armor')
shopModule:addSellableItem({'golden armor'},2466, 20000,'golden armor')
shopModule:addSellableItem({'dragon scale mail'},2492, 40000,'dragon scale mail')
shopModule:addSellableItem({'magic plate armor'},2472, 90000,'magic plate armor')
shopModule:addSellableItem({'knight legs'},2477, 5000,'knight legs')
shopModule:addSellableItem({'crown legs'},2488, 12000,'crown legs')
shopModule:addSellableItem({'glacier kilt'},7896, 11000,'glacier kilt')
shopModule:addSellableItem({'terra legs'},7885, 11000,'terra legs')
shopModule:addSellableItem({'magma legs'},7894, 11000,'magma legs')
shopModule:addSellableItem({'lightning legs'},7895, 11000,'lightning legs')
shopModule:addSellableItem({'zaoan legs'},11298, 14000,'zaoan legs')
shopModule:addSellableItem({'golden legs'},2470, 30000,'golden legs')
shopModule:addSellableItem({'glacier mask'},7902, 2500,'glacier mask')
shopModule:addSellableItem({'magma monocle'},7900, 2500,'magma monocle')
shopModule:addSellableItem({'lightning headband'},7901, 2500,'lightning headband')
shopModule:addSellableItem({'terra hood'},7903, 2500,'terra hood')
shopModule:addSellableItem({'crown helmet'},2491, 2500,'crown helmet')
shopModule:addSellableItem({'devil helmet'},2462, 1000,'devil helmet')
shopModule:addSellableItem({'crusader helmet'},2497, 6000,'crusader helmet')
shopModule:addSellableItem({'warrior helmet'},2475, 5000,'warrior helmet')
shopModule:addSellableItem({'royal helmet'},2498, 30000,'royal helmet')
shopModule:addSellableItem({'skull helmet'},5741, 40000,'skull helmet')
shopModule:addSellableItem({'zaoan helmet'},11296, 45000,'zaoan helmet')
shopModule:addSellableItem({'boots of haste'},2195, 30000,'boots of haste')
shopModule:addSellableItem({'steel boots'},2645, 30000,'steel boots')
shopModule:addSellableItem({'terra boots'},7886, 2500,'terra boots')
shopModule:addSellableItem({'magma boots'},7891, 2500,'magma boots')
shopModule:addSellableItem({'glacier shoes'},7892, 2500,'glacier shoes')
shopModule:addSellableItem({'lightning boots'},7893, 2500,'lightning boots')
shopModule:addSellableItem({'fur boots'},7457, 2500,'fur boots')
shopModule:addSellableItem({'zaoan shoes'},11297, 5000,'zaoan shoes')
shopModule:addSellableItem({'broad sword'},2413, 500,'broad sword')
shopModule:addSellableItem({'serpent sword'},2409, 900,'serpent sword')
shopModule:addSellableItem({'spike sword'},2383, 1000,'spike sword')
shopModule:addSellableItem({'ice rapier'},2396, 1000,'ice rapier')
shopModule:addSellableItem({'fire sword'},2392, 4000,'fire sword')
shopModule:addSellableItem({'epee'},2438, 8000,'epee')
shopModule:addSellableItem({'blacksteel sword'},7857, 6000,'blacksteel sword')
shopModule:addSellableItem({'haunted blade'},7407, 8000,'haunted blade')
shopModule:addSellableItem({'dragon slayer'},7402, 15000,'dragon slayer')
shopModule:addSellableItem({'mercenary sword'},7386, 12000,'mercenary sword')
shopModule:addSellableItem({'thaian sword'},7391, 16000,'thaian sword')
shopModule:addSellableItem({'Sais'},11300, 16500,'Sais')
shopModule:addSellableItem({'giant sword'},2393, 17000,'giant sword')
shopModule:addSellableItem({'relic sword'},7383, 25000,'relic sword')
shopModule:addSellableItem({'assassin dagger'},7404, 30000,'assassin dagger')
shopModule:addSellableItem({'nightmare blade'},7418, 30000,'nightmare blade')
shopModule:addSellableItem({'zaoan sword'},11301, 30000,'zaoan sword')
shopModule:addSellableItem({'twiceslicer'},12574, 28000,'twiceslicer')
shopModule:addSellableItem({'demonrage sword'},7382, 36000,'demonrage sword')
shopModule:addSellableItem({'obsidian lance'},2425, 500,'obsidian lance')
shopModule:addSellableItem({'knight axe'},2430, 2000,'knight axe')
shopModule:addSellableItem({'glorious axe'},7454, 3000,'glorious axe')
shopModule:addSellableItem({'titan axe'},7413, 4000,'titan axe')
shopModule:addSellableItem({'angelic axe'},7436, 5000,'angelic axe')
shopModule:addSellableItem({'fire axe'},2432, 8000,'fire axe')
shopModule:addSellableItem({'dragon lance'},2414, 9000,'dragon lance')
shopModule:addSellableItem({'drakinata'},11299, 10000,'drakinata')
shopModule:addSellableItem({'noble axe'},7456, 11000,'noble axe')
shopModule:addSellableItem({'war axe'},7878, 12000,'war axe')
shopModule:addSellableItem({'dreaded cleaver'},7419, 15000,'dreaded cleaver')
shopModule:addSellableItem({'butcher\'s axe'},7412, 18000,'butcher\'s axe')
shopModule:addSellableItem({'ornamented axe'},7411, 20000,'ornamented axe')
shopModule:addSellableItem({'vile axe'},7388, 30000,'vile axe')
shopModule:addSellableItem({'war hammer'},2391, 1200,'war hammer')
shopModule:addSellableItem({'brutetamers Staff'},7379, 1500,'brutetamer\'s Staff')
shopModule:addSellableItem({'dragon hammer'},2434, 2000,'dragon hammer')
shopModule:addSellableItem({'dragonbone staff'},7430, 3000,'dragonbone staff')
shopModule:addSellableItem({'diamond sceptre'},7387, 3000,'diamond sceptre')
shopModule:addSellableItem({'Spiked Squelcher'},7452, 5000,'Spiked Squelcher')
shopModule:addSellableItem({'lunar staff'},7424, 5000,'lunar staff')
shopModule:addSellableItem({'skull staff'},2436, 6000,'skull staff')
shopModule:addSellableItem({'sapphire hammer'},7437, 7000,'sapphire hammer')
shopModule:addSellableItem({'amber staff'},7426, 8000,'amber staff')
shopModule:addSellableItem({'chaos mace'},7427, 9000,'chaos mace')
shopModule:addSellableItem({'shadow sceptre'},7451, 10000,'shadow sceptre')
shopModule:addSellableItem({'drachaku'},11302, 10000,'drachaku')
shopModule:addSellableItem({'bonebreaker'},7428, 10000,'bonebreaker')
shopModule:addSellableItem({'crystal mace'},2445, 12000,'crystal mace')
shopModule:addSellableItem({'queen\'s sceptre'},7410, 20000,'queen\'s sceptre')
shopModule:addSellableItem({'onyx flail'},7421, 22000,'onyx flail')
shopModule:addSellableItem({'jade hammer'},7422, 25000,'jade hammer')
shopModule:addSellableItem({'hammer of wrath'},2444, 30000,'hammer of wrath')
shopModule:addSellableItem({'abyss hammer'},7414, 50000,'abyss hammer')
shopModule:addSellableItem({'wand of cosmic energy'},2189, 2000,'wand of cosmic energy')
shopModule:addSellableItem({'wand of decay'},2188, 1000,'wand of decay')
shopModule:addSellableItem({'wand of draconia'},8921, 1500,'wand of draconia')
shopModule:addSellableItem({'wand of dragonbreath'},2191, 200,'wand of dragonbreath')
shopModule:addSellableItem({'wand of inferno'},2187, 3000,'wand of inferno')
shopModule:addSellableItem({'wand of starstorm'},8920, 3600,'wand of starstorm')
shopModule:addSellableItem({'wand of voodoo'},8922, 4400,'wand of voodoo')
shopModule:addSellableItem({'wand of vortex'},2190, 100,'wand of vortex')
shopModule:addSellableItem({'hailstorm rod'},2183, 3000,'hailstorm rod')
shopModule:addSellableItem({'moonlight rod'},2186, 200,'moonlight rod')
shopModule:addSellableItem({'necrotic rod'},2185, 1000,'necrotic rod')
shopModule:addSellableItem({'northwind rod'},8911, 1500,'northwind rod')
shopModule:addSellableItem({'snakebite rod'},2182, 100,'snakebite rod')
shopModule:addSellableItem({'springsprout rod'},8912, 3600,'springsprout rod')
shopModule:addSellableItem({'terra rod'},2181, 2000,'terra rod')
shopModule:addSellableItem({'underworld rod'},8910, 4400,'underworld rod')
-------BUYABLE
function creatureSayCallback(cid, type, msg)
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
if (not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'magic sulphur') then
npcHandler:say('Do you want to change 3 fire swords for magic sulphur?', cid)
talk_state = 1
elseif msgcontains(msg, 'yes') and talk_state == 1 then
if getPlayerItemCount(cid, 2392) >= 3 then
if doPlayerRemoveMoney(cid, price) == true then
npcHandler:say('Here you are.', cid)
doPlayerRemoveItem(cid, 2392, 3)
doPlayerAddItem(cid, 5904, 1)
talk_state = 0
end
else
npcHandler:say('You need to have 3 fire swords with you.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'warrior\'s sweat') then
npcHandler:say('Do you want to change 4 warrior helmets for warrior\'s sweat?', cid)
talk_state = 2
elseif msgcontains(msg, 'yes') and talk_state == 2 then
if getPlayerItemCount(cid, 2475) >= 4 then
if doPlayerRemoveMoney(cid, price) == true then
npcHandler:say('Here you are.', cid)
doPlayerRemoveItem(cid, 2475, 4)
doPlayerAddItem(cid, 5885, 1)
talk_state = 0
end
else
npcHandler:say('You need to have 4 warrior helmets with you.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'fighting spirit') then
npcHandler:say('Do you want to change 2 royal helmets for fighting spirit?', cid)
talk_state = 3
elseif msgcontains(msg, 'yes') and talk_state == 3 then
if getPlayerItemCount(cid, 2498) >= 2 then
if doPlayerRemoveMoney(cid, price) == true then
npcHandler:say('Here you are.', cid)
doPlayerRemoveItem(cid, 2498, 2)
doPlayerAddItem(cid, 5884, 1)
talk_state = 0
end
else
npcHandler:say('You need to have 2 royal helmets with you.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'enchanted chicken wing') then
npcHandler:say('Do you want to change boots of haste for enchanted chicken wing?', cid)
talk_state = 4
elseif msgcontains(msg, 'yes') and talk_state == 4 then
if getPlayerItemCount(cid, 2195) >= 1 then
if doPlayerRemoveMoney(cid, price) == true then
npcHandler:say('Here you are.', cid)
doPlayerRemoveItem(cid, 2195, 1)
doPlayerAddItem(cid, 5891, 1)
talk_state = 0
end
else
npcHandler:say('You need to have boots of haste with you.', cid)
talk_state = 0
end
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 4) then
npcHandler:say('Ok thanks.', cid)
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
please why is he taking 2 instead of one? =(