roriscrave
Advanced OT User
- Joined
- Dec 7, 2011
- Messages
- 1,210
- Solutions
- 35
- Reaction score
- 206
his script works on tfs 0.4 but not 1.3 it is in error.
(npc that when talking trade, you can buy with another type of coin ID, other than gold coin)
when the player does not have the new gold coin count, he should return the message:
but does not return anything nor error in the console.
the same mistake happens when buying, clicking to buy returns nothing
both case no error in console
obs: the trade channel open correct, with the items.
(npc that when talking trade, you can buy with another type of coin ID, other than gold coin)
when the player does not have the new gold coin count, he should return the message:
LUA:
selfSay("U dont have "..t[item].price.." "..ItemType(newcoin):getId().." to buy.", cid)
the same mistake happens when buying, clicking to buy returns nothing
both case no error in console
obs: the trade channel open correct, with the items.
LUA:
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
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
local shopWindow = {}
local newcoin = 6541 -- ID certain item
local t = {
[2342] = {price = 250}, -- helmet
[2503] = {price = 250}, -- armor
}
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if t[item] and not doPlayerRemoveItem(cid, newcoin, t[item].price) then
selfSay("U dont have "..t[item].price.." "..ItemType(newcoin):getId().." to buy.", cid)
else
doPlayerAddItem(cid, item)
selfSay("Here your item!", cid)
end
return true
end
if (msgcontains(msg, 'trade'))then
for var, ret in pairs(t) do
table.insert(shopWindow, {id = var, subType = 0, buy = ret.price, sell = 0, name = getItemNameById(var)})
end
openShopWindow(cid, shopWindow, onBuy, onSell)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: