Dangnoob
Member
- Joined
- Jun 8, 2008
- Messages
- 105
- Solutions
- 2
- Reaction score
- 12
So im stuck right now on how to make it so a price equals a storage value. I really dont understand much about how these npcs work at all. I tried one form,
Didn't work, i dont understand how to make the npc take the money.... and then i tried the other lua style that i saw with all the shopModule:addBuyableItem in it, but it appears i cant add an item into the shop except in the beginning..? tried throwing it into here, when you start talking. It didn't work.
Anybody have any idea as to how i could do this? Thx in advance if you can help.
Code:
function onCreatureSay(cid, type, msg)
if((msg == "hi") and not (isFocused(cid))) then
local lvlupprice = ((getPlayerStorageValue(cid, 8080) - 79 ) * 50)
selfSay("Hello, ".. getCreatureName(cid) .." welcome to the mage shop!", cid, true)
selfSay("Would you like to see my {offers}?", cid)
addFocus(cid)
elseif((isFocused(cid)) and (msg == "wares" or msg == "trade")) then
local lvlupprice = ((getPlayerStorageValue(cid, 8080) - 79 ) * 50)
selfSay("You can buy a level up stone here! Buy a level stone up for " .. lvlupprice .. " gold?", cid)
if (msg == "yes") then
doPlayerRemoveMoney(cid, lvlupprice)
end
elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
selfSay("Goodbye!", cid, true)
closeShopWindow(cid)
removeFocus(cid)
end
end
Didn't work, i dont understand how to make the npc take the money.... and then i tried the other lua style that i saw with all the shopModule:addBuyableItem in it, but it appears i cant add an item into the shop except in the beginning..? tried throwing it into here, when you start talking. It didn't work.
Code:
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local lvlupprice = ((getPlayerStorageValue(cid, 8080) - 79 ) * 50)
shopModule:addBuyableItem({'spellbook'}, 2175, 200, 'spellbook')
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
Anybody have any idea as to how i could do this? Thx in advance if you can help.