Hello!
This script is giving me ability to buy 100x runes. or 58x. Or whatever I like.
Problem: People can buy 500x runes. Why?
Edit: To be clear; I want the maximum rune charge to be 100x!
Thanks in advance.
This script is giving me ability to buy 100x runes. or 58x. Or whatever I like.
Problem: People can buy 500x runes. Why?
Edit: To be clear; I want the maximum rune charge to be 100x!
Thanks in advance.
Code:
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:addBuyableItem({'light wand', 'lightwand'}, 2163, 120, 'magic light wand')
shopModule:addBuyableItem({'spell book', 'spellbook'}, 2175, 150, 'spellbook')
shopModule:addBuyableItem({'mana fluid', 'manafluid'}, 2006, 55, 7, 'mana fluid')
shopModule:addBuyableItem({'life fluid', 'lifefluid'}, 2006, 50, 10, 'life fluid')
shopModule:addBuyableItem({'blank'}, 2260, 10, 'blank rune')
shopModule:addBuyableItem({'life ring'}, 2168, 900, 1, 'life ring')
shopModule:addBuyableItem({'wand of inferno', 'inferno'}, 2187, 15000, 'wand of inferno')
shopModule:addBuyableItem({'wand of plague', 'plague'}, 2188, 5000, 'wand of plague')
shopModule:addBuyableItem({'wand of cosmic energy', 'cosmic energy'}, 2189, 10000, 'wand of cosmic energy')
shopModule:addBuyableItem({'wand of vortex', 'vortex'}, 2190, 500, 'wand of vortex')
shopModule:addBuyableItem({'wand of dragonbreath', 'dragonbreath'}, 2191, 1000, 'wand of dragonbreath')
shopModule:addBuyableItem({'quagmire rod', 'quagmire'}, 2181, 10000, 'quagmire rod')
shopModule:addBuyableItem({'snakebite rod', 'snakebite'}, 2182, 500, 'snakebite rod')
shopModule:addBuyableItem({'tempest rod', 'tempest'}, 2183, 15000, 'tempest rod')
shopModule:addBuyableItem({'volcanic rod', 'volcanic'}, 2185, 5000, 'volcanic rod')
shopModule:addBuyableItem({'moonlight rod', 'moonlight'}, 2186, 1000, 'moonlight rod')
function creatureSayCallback(cid, type, msg)
if(npcHandler.focus ~= cid) then
return FALSE
end
if msgcontains(msg, 'runes') then
selfSay("I sell all kind of runes. For example, say 100 SUDDEN DEATH RUNE or 1 SD.")
talk_state = 0
elseif msgcontains(msg, 'heavy magic missile') or msgcontains(msg, 'hmm') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 12*charges
selfSay('Do you want a heavy magic missile rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2311
elseif msgcontains(msg, 'great fireball') or msgcontains(msg, 'gfb') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 90*charges
selfSay('Do you want a great fireball rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2304
elseif msgcontains(msg, 'explosion') or msgcontains(msg, 'explo') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 60*charges
selfSay('Do you want an explosion rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2313
elseif msgcontains(msg, 'ultimate healing') or msgcontains(msg, 'uh') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 175*charges
selfSay('Do you want an ultimate healing rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2274
elseif msgcontains(msg, 'sudden death') or msgcontains(msg, 'sd') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 325*charges
selfSay('Do you want a sudden death rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2263
elseif msgcontains(msg, 'light magic missile') or msgcontains(msg, 'lmm') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 4*charges
selfSay('Do you want a light magic missile rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2287
elseif msgcontains(msg, 'poison field') or msgcontains(msg, 'pf') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 20*charges
selfSay('Do you want a poison field rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2285
elseif msgcontains(msg, 'poison wall') or msgcontains(msg, 'pw') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 50*charges
selfSay('Do you want a poison wall rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2289
elseif msgcontains(msg, 'intense healing') or msgcontains(msg, 'ih') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 40*charges
selfSay('Do you want a intense healing rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2265
elseif msgcontains(msg, 'fire wall') or msgcontains(msg, 'fw') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 60*charges
selfSay('Do you want a fire wall rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2303
elseif msgcontains(msg, 'fire field') or msgcontains(msg, 'ff') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 25*charges
selfSay('Do you want a fire field rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2301
elseif msgcontains(msg, 'fire bomb') or msgcontains(msg, 'fb') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 115*charges
selfSay('Do you want a fire bomb rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2305
elseif msgcontains(msg, 'energy wall') or msgcontains(msg, 'ew') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 85*charges
selfSay('Do you want an energy wall rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2279
elseif msgcontains(msg, 'energy field') or msgcontains(msg, 'ef') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 35*charges
selfSay('Do you want an energy field rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2277
elseif msgcontains(msg, 'destroy field') or msgcontains(msg, 'df') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 15*charges
selfSay('Do you want a destroy field rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2261
elseif msgcontains(msg, 'convince creature') or msgcontains(msg, 'cc') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 80*charges
selfSay('Do you want a convince creature rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2290
elseif msgcontains(msg, 'chameleon') or msgcontains(msg, 'c') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 210*charges
selfSay('Do you want a chameleon rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2291
elseif msgcontains(msg, 'antidote') or msgcontains(msg, 'a') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 65*charges
selfSay('Do you want an antidote rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2266
elseif msgcontains(msg, 'magic wall') or msgcontains(msg, 'mw') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 80*charges
selfSay('Do you want a magic wall rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2293
elseif msgcontains(msg, 'paralyze') or msgcontains(msg, 'para') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 700*charges
selfSay('Do you want a paralyze rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2278
elseif msgcontains(msg, 'fireball') or msgcontains(msg, 'fire ball') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 50*charges
selfSay('Do you want a fireball rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2302
elseif msgcontains(msg, 'soulfire') or msgcontains(msg, 'soul fire') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 70*charges
selfSay('Do you want a soulfire rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2308
elseif msgcontains(msg, 'animate dead') or msgcontains(msg, 'ad') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 375*charges
selfSay('Do you want an animated dead rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2316
elseif msgcontains(msg, 'poison bomb') or msgcontains(msg, 'pb') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 85*charges
selfSay('Do you want a poison bomb rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2286
elseif msgcontains(msg, 'energy bomb') or msgcontains(msg, 'eb') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 80*charges
selfSay('Do you want an energy bomb rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2262
elseif msgcontains(msg, 'desintegrate') or msgcontains(msg, 'dg') and ShopModule:getCount(msg) <= 100 then
charges = ShopModule:getCount(msg)
price = 60*charges
selfSay('Do you want a desintegrate rune with '..charges..' charges for '..price..' gold coins?')
talk_state = 1
itemid = 2310
elseif msgcontains(msg, 'yes') and talk_state == 1 then
if doPlayerRemoveMoney(cid, price) == TRUE then
doPlayerGiveItem(cid, itemid, 1, charges)
selfSay("You have bought this rune.")
talk_state = 0
else
selfSay("You don't have enough money.")
talk_state = 0
end
elseif msgcontains(msg, 'no') and talk_state == 1 then
selfSay("Then not.")
talk_state = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: