• 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!

TFS 1.0 - 10:41 Addshop

vingo

Active Member
Joined
Oct 27, 2012
Messages
464
Reaction score
43
How can I add a item to the shop when I can't equip any item in the right hand slot?

[C]: in function 'getPlayerSlotItem'
data/talkactions/scripts/addshop.lua:7: in function <data/talkactions/sc
ripts/addshop.lua:1>

PHP:
function onSay(cid, words, param, channel)
    local params = param:split(",")
    local price = params[1]
    table.remove(params, 1)
    local desc = table.concat(params, ",")
    local name = ''
    local item1 = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    local itemid1 = item1.itemid
    local count1 = item1.type
    local itemid2 = 0
    local count2 = 0

    if(itemid1 == 0) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Put item in right hand.")
        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 = ItemType(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 = ItemType(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:getName()
    else
        name = count1_desc .. 'x ' .. count2_desc .. 'x ' .. itemInfo:getName()
    end
   
    db.query('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 false
end
 
Does not work


Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/addshop.lua:eek:nSay
data/talkactions/scripts/addshop.lua:7: attempt to call global 'getPlayerSlotIte
m' (a nil value)
stack traceback:
[C]: in function 'getPlayerSlotItem'
data/talkactions/scripts/addshop.lua:7: in function <data/talkactions/sc
ripts/addshop.lua:1>
 
You must give us some information about the server. Such as server distro version and what you are actually trying to do.

Using TFS 1.0+, this should be:
Code:
local item1 = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
changed to
Code:
local item1 = Player(cid):getSlotItem(CONST_SLOT_RIGHT)
 
PHP:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/addshop.lua:onSay
data/talkactions/scripts/addshop.lua:7: attempt to call global 'getPlayerSlotItem' (a nil va
lue)
stack traceback:
        [C]: in function 'getPlayerSlotItem'
        data/talkactions/scripts/addshop.lua:7: in function <data/talkactions/scripts/addsho
p.lua:1>

Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/addshop.lua:onSay
data/talkactions/scripts/addshop.lua:19: attempt to call global 'doPlayerSendTextMessage' (a
 nil value)
stack traceback:
        [C]: in function 'doPlayerSendTextMessage'
        data/talkactions/scripts/addshop.lua:19: in function <data/talkactions/scripts/addsh
op.lua:1>

Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/addshop.lua:onSay
data/talkactions/scripts/addshop.lua:26: attempt to call global 'isContainer' (a nil value)
stack traceback:
        [C]: in function 'isContainer'
        data/talkactions/scripts/addshop.lua:26: in function <data/talkactions/scripts/addsh
op.lua:1>

[php]


this is what I get when i changed what u told me to change
 
You didn't change what I said...
On line 7, change:
Code:
local item1 = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
to:
Code:
local item1 = Player(cid):getSlotItem(CONST_SLOT_RIGHT)

On line 19, change:
Code:
 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Put item in right hand.")
to:
Code:
Player(cid):sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Put item in right hand.")

On line 26, change:
Code:
if(isContainer(item1.uid)) then
to:
Code:
if(itemInfo:isContainer() then
 
Thanks mate, really appreciate it.

Another questions though. In 10.41 I cant equip any item in my right hand, any way to fix that?

Thanks again!
 
When adding everything you said and using the /addshop xx,xx gives me this


PHP:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/addshop.lua:onSay
data/talkactions/scripts/addshop.lua:8: attempt to index local 'item1' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/talkactions/scripts/addshop.lua:8: in function <data/talkactions/scripts/addsho
p.lua:1>
[php]
 
Does this mean there is a missing function or some function in the script that is outdated I would assume?


Im trying to learn as I go :)
 
Nevermind I fixed it

Player(cid):sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,

Had to add this on the bottom of the script apparently
 

Similar threads

Back
Top