• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

i need help, elfbot bug

Valakinhas

New Member
Joined
May 21, 2014
Messages
12
Reaction score
0

TFS 0.3.6
error
[10/06/2014 11:33:23] [Error - Npc interface]
[10/06/2014 11:33:23] (Unknown script file)
[10/06/2014 11:33:23] Description:
[10/06/2014 11:33:23] data/npc/lib/npcsystem/modules.lua:1151: bad argument #2 to 'error' (number expected, got string)
[10/06/2014 11:33:23] stack traceback:
[10/06/2014 11:33:23] [C]: in function 'error'
[10/06/2014 11:33:23] data/npc/lib/npcsystem/modules.lua:1151: in function 'callbackOnBuy'
[10/06/2014 11:33:23] data/npc/lib/npcsystem/npchandler.lua:263: in function 'processModuleCallback'
[10/06/2014 11:33:23] data/npc/lib/npcsystem/npchandler.lua:440: in function 'onBuy'
[10/06/2014 11:33:23] data/npc/lib/npcsystem/modules.lua:1292: in function <data/npc/lib/npcsystem/modules.lua:1291>
 
So what are you asking for?
see

-- Callback onBuy() function. If you wish, you can change certain Npc to use your onBuy().
function ShopModule:callbackOnBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks)
local shopItem = nil
for _, item in ipairs(self.npcHandler.shopItems) do
if(item.id == itemid and item.subType == subType) then
shopItem = item
break
end
end

if(shopItem == nil) then
error("[ShopModule.onBuy]", "Item not found on shopItems list")
return false
end

if(shopItem.buy == -1) then
error("[ShopModule.onSell]", "Attempt to purchase an item which only sellable")
return false
end

local backpack, totalCost = 1988, amount * shopItem.buy
if(inBackpacks) then
totalCost = totalCost + (math.max(1, math.floor(amount / getContainerCapById(backpack))) * 20)
end

local parseInfo = {
[TAG_PLAYERNAME] = getPlayerName(cid),
[TAG_ITEMCOUNT] = amount,
[TAG_TOTALCOST] = totalCost,
[TAG_ITEMNAME] = shopItem.name
}

if(getPlayerMoney(cid) < totalCost) then
local msg = self.npcHandler:getMessage(MESSAGE_NEEDMONEY)
doPlayerSendCancel(cid, self.npcHandler:parseMessage(msg, parseInfo))
return false
end

local subType = shopItem.subType or 1
local a, b = doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
if(a < amount) then
local msgId = MESSAGE_NEEDMORESPACE
if(a == 0) then
msgId = MESSAGE_NEEDSPACE
end

local msg = self.npcHandler:getMessage(msgId)
parseInfo[TAG_ITEMCOUNT] = a

doPlayerSendCancel(cid, self.npcHandler:parseMessage(msg, parseInfo))
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self.npcHandler.talkStart[cid] = os.time()
else
self.npcHandler.talkStart = os.time()
end

if(a > 0) then
doPlayerRemoveMoney(cid, ((a * shopItem.buy) + (b * 20)))
return true
end

return false
end

local msg = self.npcHandler:getMessage(MESSAGE_BOUGHT)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, self.npcHandler:parseMessage(msg, parseInfo))

doPlayerRemoveMoney(cid, totalCost)
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self.npcHandler.talkStart[cid] = os.time()
else
self.npcHandler.talkStart = os.time()
end

return true
end

-- Callback onSell() function. If you wish, you can change certain Npc to use your onSell().
function ShopModule:callbackOnSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
local shopItem = nil
for _, item in ipairs(self.npcHandler.shopItems) do
if(item.id == itemid and item.subType == subType) then
shopItem = item
break
end
end

if(shopItem == nil) then
error("[ShopModule.onBuy]", "Item not found on shopItems list")
return false
end

if(shopItem.sell == -1) then
error("[ShopModule.onSell]", "Attempt to sell an item which is only buyable")
return false
end

local parseInfo = {
[TAG_PLAYERNAME] = getPlayerName(cid),
[TAG_ITEMCOUNT] = amount,
[TAG_TOTALCOST] = amount * shopItem.sell,
[TAG_ITEMNAME] = shopItem.name
}

if(subType < 1 or getItemInfo(itemid).stackable) then
subType = -1
end

if(doPlayerRemoveItem(cid, itemid, amount, subType)) then
local msg = self.npcHandler:getMessage(MESSAGE_SOLD)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, self.npcHandler:parseMessage(msg, parseInfo))

doPlayerAddMoney(cid, amount * shopItem.sell)
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self.npcHandler.talkStart[cid] = os.time()
else
self.npcHandler.talkStart = os.time()
end

return true
end

local msg = self.npcHandler:getMessage(MESSAGE_NEEDITEM)
doPlayerSendCancel(cid, self.npcHandler:parseMessage(msg, parseInfo))
if(NPCHANDLER_CONVBEHAVIOR ~= CONVERSATION_DEFAULT) then
self.npcHandler.talkStart[cid] = os.time()
else
self.npcHandler.talkStart = os.time()
end

return false
end

-- 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(table.maxn(module.npcHandler.shopItems) == 0) 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, module.npcHandler.shopItems,
function(cid, itemid, subType, amount, ignoreCap, inBackpacks)
module.npcHandler:eek:nBuy(cid, itemid, subType, amount, ignoreCap, inBackpacks)
end,
function(cid, itemid, subType, amount, ignoreCap, inBackpacks)
module.npcHandler:eek:nSell(cid, itemid, subType, amount, ignoreCap, inBackpacks)
end
)

module.npcHandler:say(msg, cid)
return true
end

-- onConfirm keyword callback function. Sells/buys the actual item.
function ShopModule.onConfirm(cid, message, keywords, parameters, node)
local module = parameters.module
if(not module.npcHandler:isFocused(cid)) then
return false
end
 
For the npc error, use this modules (data/npc/lib/npcsystem/modules.lua).
http://www.speedy*****malware.localhost/MVKT9/modules.lua
http://pastebin.com/TmNtEFqE
released cloning now

@edit
nice
go patch
npc.cpp and recompile TFS

npc.cpp
search

if(NpcState* npcState = getState(player,true)){
npcState->amount = amount;
npcState->subType = count;
npcState->itemId = itemId;
npcState->buyPrice = getListItemPrice(itemId, SHOPEVENT_BUY);
npcState->ignoreCap = ignoreCap;
npcState->inBackpacks = inBackpacks;

constNpcResponse* response = getResponse(player, npcState, EVENT_PLAYER_SHOPBUY);
executeResponse(player, npcState, response);}

replace with

if(NpcState* npcState = getState(player,true)){if(amount <=0){
amount =1;}
npcState->amount = amount;
npcState->subType = count;
npcState->itemId = itemId;
npcState->buyPrice = getListItemPrice(itemId, SHOPEVENT_BUY);
npcState->ignoreCap = ignoreCap;
npcState->inBackpacks = inBackpacks;

constNpcResponse* response = getResponse(player, npcState, EVENT_PLAYER_SHOPBUY);
executeResponse(player, npcState, response);}
 
Last edited:
Back
Top