ok so im trying to add the /addshop, command but it doesnt seem to work :/ im currently using tfs 0.2.15 for my 9.86 server wich im currently working on, and i need this command to add items to my server shop but whenever i type /addshop i get an error, mostly because the script is for 4.0 or something but if anyone know the fix for the error, or got another script for it then please help me
btw there was 2 scripts and diffirent errors in both
In this the error is like this =
[20/05/2013 16:27:51] Lua Script Error: [TalkAction Interface]
[20/05/2013 16:27:51] data/talkactions/scripts/add_shop_talkaction.lua
nSay
[20/05/2013 16:27:51] data/talkactions/scripts/add_shop_talkaction.lua:2: attempt to call global 'getCreatureLookPosition' (a nil value)
[20/05/2013 16:27:51] stack traceback:
[20/05/2013 16:27:51] [C]: in function 'getCreatureLookPosition'
[20/05/2013 16:27:51] data/talkactions/scripts/add_shop_talkaction.lua:2: in function <data/talkactions/scripts/add_shop_talkaction.lua:1>
and second script,
Error for this one = [20/05/2013 16:27:39] Lua Script Error: [TalkAction Interface]
[20/05/2013 16:27:39] data/talkactions/scripts/add_shop_talkaction.lua
nSay
[20/05/2013 16:27:39] data/talkactions/scripts/add_shop_talkaction.lua:3: attempt to index local 'params' (a nil value)
[20/05/2013 16:27:39] stack traceback:
[20/05/2013 16:27:39] [C]: in function '__index'
[20/05/2013 16:27:39] data/talkactions/scripts/add_shop_talkaction.lua:3: in function <data/talkactions/scripts/add_shop_talkaction.lua:1>
- - - Updated - - -
didnt know what code to use the errors in but the ":O" smiley is pretty much ":" + "o" .. but u probably know that already
LUA:
function onSay(cid, words, param, channel)
local toPos = getCreatureLookPosition(cid) -- this function may not exists in old TFSes :/
toPos.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
local params = string.explode(param, ",")
local price = params[1]
table.remove(params, 1)
local desc = table.concat(params,",")
local name = ''
local item1 = getThingFromPos(toPos)
local itemid1 = item1.itemid
local count1 = item1.type
local itemid2 = 0
local count2 = 0
if(itemid1 == 0 or isCreature(item1.uid)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There is no moveable item in front of you or there is creature.")
return true
end
if(not price) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must set price.")
return true
end
price = tonumber(price)
local itemInfo = getItemInfo(itemid1)
local offer_type = 'item'
if(isContainer(item1.uid)) then
local item2 = getContainerItem(item1.uid, 0)
if(item2.itemid > 0) then
count1 = getContainerCap(item1.uid)
itemid2 = item2.itemid
count2 = item2.type
offer_type = 'container'
itemInfo = getItemInfo(itemid2)
end
end
local count1_desc = (count1 > 0) and count1 or 1
local count2_desc = (count2 > 0) and count2 or 1
if(itemid2 == 0) then
name = count1_desc .. 'x ' .. itemInfo.name
else
name = count1_desc .. 'x ' .. count2_desc .. 'x ' .. itemInfo.name
end
db.executeQuery('INSERT INTO `z_shop_offer` (`id` ,`points` ,`itemid1` ,`count1` ,`itemid2` ,`count2` ,`offer_type` ,`offer_description` ,`offer_name`) VALUES (NULL , ' .. price .. ', ' .. itemid1 .. ', ' .. count1 .. ', ' .. itemid2 .. ', ' .. count2 .. ', \'' .. offer_type .. '\', ' .. db.escapeString(desc) .. ', ' .. db.escapeString(name) .. ');')
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item >> " .. name .. " << added to SMS shop. Price is " .. price .. " premium points.")
return true
end
[20/05/2013 16:27:51] Lua Script Error: [TalkAction Interface]
[20/05/2013 16:27:51] data/talkactions/scripts/add_shop_talkaction.lua
[20/05/2013 16:27:51] data/talkactions/scripts/add_shop_talkaction.lua:2: attempt to call global 'getCreatureLookPosition' (a nil value)
[20/05/2013 16:27:51] stack traceback:
[20/05/2013 16:27:51] [C]: in function 'getCreatureLookPosition'
[20/05/2013 16:27:51] data/talkactions/scripts/add_shop_talkaction.lua:2: in function <data/talkactions/scripts/add_shop_talkaction.lua:1>
and second script,
LUA:
function onSay(cid, words, param, channel)
local toPos = getCreatureLookPosition(cid) -- this function may not exists in old TFSes :/
toPos.stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE
local params = string.explode(param, ",")
local price = params[1]
table.remove(params, 1)
local desc = table.concat(params,",")
local name = ''
local item1 = getThingFromPos(toPos)
local itemid1 = item1.itemid
local count1 = item1.type
local itemid2 = 0
local count2 = 0
if(itemid1 == 0 or isCreature(item1.uid)) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There is no moveable item in front of you or there is creature.")
return true
end
if(not price) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must set price.")
return true
end
price = tonumber(price)
local itemInfo = getItemInfo(itemid1)
local offer_type = 'item'
if(isContainer(item1.uid)) then
local item2 = getContainerItem(item1.uid, 0)
if(item2.itemid > 0) then
count1 = getContainerCap(item1.uid)
itemid2 = item2.itemid
count2 = item2.type
offer_type = 'container'
itemInfo = getItemInfo(itemid2)
end
end
local count1_desc = (count1 > 0) and count1 or 1
local count2_desc = (count2 > 0) and count2 or 1
if(itemid2 == 0) then
name = count1_desc .. 'x ' .. itemInfo.name
else
name = count1_desc .. 'x ' .. count2_desc .. 'x ' .. itemInfo.name
end
db.executeQuery('INSERT INTO `z_shop_offer` (`id` ,`points` ,`itemid1` ,`count1` ,`itemid2` ,`count2` ,`offer_type` ,`offer_description` ,`offer_name`) VALUES (NULL , ' .. price .. ', ' .. itemid1 .. ', ' .. count1 .. ', ' .. itemid2 .. ', ' .. count2 .. ', \'' .. offer_type .. '\', ' .. db.escapeString(desc) .. ', ' .. db.escapeString(name) .. ');')
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Item >> " .. name .. " << added to SMS shop. Price is " .. price .. " premium points.")
return true
end
[20/05/2013 16:27:39] data/talkactions/scripts/add_shop_talkaction.lua
[20/05/2013 16:27:39] data/talkactions/scripts/add_shop_talkaction.lua:3: attempt to index local 'params' (a nil value)
[20/05/2013 16:27:39] stack traceback:
[20/05/2013 16:27:39] [C]: in function '__index'
[20/05/2013 16:27:39] data/talkactions/scripts/add_shop_talkaction.lua:3: in function <data/talkactions/scripts/add_shop_talkaction.lua:1>
- - - Updated - - -
didnt know what code to use the errors in but the ":O" smiley is pretty much ":" + "o" .. but u probably know that already
Last edited: