strutZ
Australian OT Member {AKA Beastn}
- Joined
- Nov 16, 2014
- Messages
- 1,393
- Solutions
- 7
- Reaction score
- 552
Hey otland,
I've been working on a NPC that can sell reciepes for colors crafting system. This is what i've come up with so far.
This script does indeed sell the item with the Action ID however, being that the item is the same it just assigns the same action id to all the items.
Example: If i buy the tailoring item the action ID will still be 50501.
Is this even possible?
Regards
beastn
I've been working on a NPC that can sell reciepes for colors crafting system. This is what i've come up with so far.
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 shopWindow = {}
local keys = {
{id = 2217, buy = 5, name = "BlackSmithing", actionid = 50501},
{id = 2217, buy = 20, name = "Alchemy", actionid = 50502},
{id = 2217, buy = 50, name = "Inscription", actionid = 50503},
{id = 2217, buy = 50, name = "Tailoring", actionid = 50504},
{id = 2217, buy = 50, name = "Enchanting", actionid = 50505},
{id = 2217, buy = 50, name = "Taming", actionid = 50506},
{id = 1967, buy = 50, name = "reciepe", text = "101", actionid = 50501},
}
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if doPlayerRemoveMoney(cid, shopWindow[item].Price) then
local thing = doPlayerAddItem(cid, shopWindow[item].ID, 1)
doSetItemText(thing, shopWindow[item].Text)
doSetItemActionId(thing, shopWindow[item].Actionid)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought a "..shopWindow[item].KeyName.." for "..shopWindow[item].Price.." gold.")
else
selfSay("You don't have enough money.", cid)
end
return true
end
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
if msgcontains(msg, 'trade') then
for var, item in pairs(keys) do
shopWindow[item.id] = {ID = item.id, Price = item.buy, KeyName = item.name, Actionid = item.actionid, Text = item.text}
end
openShopWindow(cid, keys, onBuy, onSell)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
This script does indeed sell the item with the Action ID however, being that the item is the same it just assigns the same action id to all the items.
Example: If i buy the tailoring item the action ID will still be 50501.
Is this even possible?
Regards
beastn