Code:
Lua Script Error: [Npc interface]
(Unknown scriptfile)
data/npc/lib/npcsystem/modules.lua:1014: [ShopModule.onSell] items[itemid] == nil
stack traceback:
[C]: at 0x555555661da0
[C]: in function 'error'
data/npc/lib/npcsystem/modules.lua:1014: in function 'callbackOnSell'
data/npc/lib/npcsystem/npchandler.lua:265: in function 'processModuleCallback'
data/npc/lib/npcsystem/npchandler.lua:469: in function 'onSell'
data/npc/lib/npcsystem/modules.lua:1077: in function <data/npc/lib/npcsystem/modules.lua:1077>
data/npc/lib/npcsystem/modules.lua:1014: in function 'callbackOnSell'
Lua:
-- Callback onSell() function. If you wish, you can change certain Npc to use your onSell().
function ShopModule:callbackOnSell(cid, itemid, subType, amount, ignoreEquipped, _)
local shopItem = self:getShopItem(itemid, subType)
if shopItem == nil then
error("[ShopModule.onSell] items[itemid] == nil")
return false
end
if shopItem.sell == -1 then
error("[ShopModule.onSell] attempt to sell a non-sellable item")
return false
end
local parseInfo = {
[TAG_PLAYERNAME] = getPlayerName(cid),
[TAG_ITEMCOUNT] = amount,
[TAG_TOTALCOST] = amount * shopItem.sell,
[TAG_ITEMNAME] = shopItem.name
}
if not isItemFluidContainer(itemid) then
subType = -1
end
if doPlayerRemoveItem(cid, itemid, amount, subType, ignoreEquipped) then
local msg = self.npcHandler:getMessage(MESSAGE_SOLD)
msg = self.npcHandler:parseMessage(msg, parseInfo)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg)
doPlayerAddMoney(cid, amount * shopItem.sell)
self.npcHandler.talkStart[cid] = os.time()
return true
else
local msg = self.npcHandler:getMessage(MESSAGE_NEEDITEM)
msg = self.npcHandler:parseMessage(msg, parseInfo)
doPlayerSendCancel(cid, msg)
self.npcHandler.talkStart[cid] = os.time()
return false
end
end
data/npc/lib/npcsystem/npchandler.lua:265: in function 'processModuleCallback'
Code:
-- UnGreeting callback function.
function FocusModule.onFarewell(cid, message, keywords, parameters)
if parameters.module.npcHandler:isFocused(cid) then
parameters.module.npcHandler:onFarewell(cid)
return true
else
return false
end
end
data/npc/lib/npcsystem/npchandler.lua:469: in function 'onSell'
Lua:
function TravelModule.onConfirm(cid, message, keywords, parameters, node)
local module = parameters.module
if not module.npcHandler:isFocused(cid) then
return false
end
if shop_npcuid[cid] ~= Npc().uid then
return false
end
local npcHandler = module.npcHandler
local cost = shop_cost[cid]
local destination = Position(shop_destination[cid])
local player = Player(cid)
if player:isPremium() or not shop_premium[cid] then
if not player:removeMoneyNpc(cost) then
npcHandler:say("You do not have enough money!", cid)
elseif player:isPzLocked(cid) then
npcHandler:say("Get out of there with this blood.", cid)
else
npcHandler:say("It was a pleasure doing business with you.", cid)
npcHandler:releaseFocus(cid)
local position = player:getPosition()
player:teleportTo(destination)
position:sendMagicEffect(CONST_ME_TELEPORT)
destination:sendMagicEffect(CONST_ME_TELEPORT)
end
else
npcHandler:say("I can only allow premium players to travel there.", cid)
end
npcHandler:resetNpc(cid)
return true
end
data/npc/lib/npcsystem/modules.lua:1077: in function <data/npc/lib/npcsystem/modules.lua:1077>
Lua:
-- Callback for requesting a trade window with the NPC.
function ShopModule.requestTrade(cid, message, keywords, parameters, node)
local module = parameters.module
if not module.npcHandler:isFocused(cid) then
return false
end
if not module.npcHandler:onTradeRequest(cid) then
return false
end
local itemWindow = {}
for i = 1, #module.npcHandler.shopItems do
itemWindow[#itemWindow + 1] = module.npcHandler.shopItems[i]
end
if itemWindow[1] == nil then
local parseInfo = { [TAG_PLAYERNAME] = getPlayerName(cid) }
local msg = module.npcHandler:parseMessage(module.npcHandler:getMessage(MESSAGE_NOSHOP), parseInfo)
module.npcHandler:say(msg, cid)
return true
end
local parseInfo = { [TAG_PLAYERNAME] = getPlayerName(cid) }
local msg = module.npcHandler:parseMessage(module.npcHandler:getMessage(MESSAGE_SENDTRADE), parseInfo)
openShopWindow(cid, itemWindow,
function(cid, itemid, subType, amount, ignoreCap, inBackpacks) module.npcHandler:onBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks) end,
function(cid, itemid, subType, amount, ignoreCap, inBackpacks) module.npcHandler:onSell(cid, itemid, subType, amount, ignoreCap, inBackpacks) end)
module.npcHandler:say(msg, cid)
return true
end
FULL FILE
-- Advanced NPC System by Jiddofunction Player.removeMoneyNpc(self, amount) - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
pastebin.com