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

How to get creatureID in tfs 1.0

kimokimo

Kimo
Joined
Jan 25, 2011
Messages
821
Solutions
6
Reaction score
156
GitHub
karimadnan
As the title says i was working on something in player.lua in moveitem function and i found no cid in the parameters i tried playing around like this :
PHP:
local sellableitem = pricetable[item.itemid]
local tile = toPosition:getTile()
local targetTile = {x= 970, y= 992, z= 6}
local uids = item
local bp = self:addItem(uids.itemid, 1)   
local cid = self:getId()

if item:getActionId() == 4000 then
    self:sendTextMessage(MESSAGE_EVENT_DEFAULT, "You can't steal this item!.")
    return false
elseif toPosition.x == targetTile.x and toPosition.y == targetTile.y and toPosition.z == targetTile.z then
        if isContainer(item.uid) then
            doSellContainer(item, cid, position, true, false)
            doAddCopiedContainer(uids, bp)
            return doRemoveItem(item.uid)
        else
                if sellableitem then
                    doSellItem(item, cid, position, true, true)
                else
                      self:addItem(item.itemid, item.type)
                    doRemoveItem(item.uid)
                    self:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Your "..getItemNameById(item.itemid).." is not sellable, so it was returned to you.")
                end
            end
    end
    return true
end
but then this local cid = self:getId() return nill
 
Last edited:
But just try write:
print(self:getId()) instead of making local cid = self:getId()
 
268435456 -- print(self:getId())

Lua Script Error: [MoveEvents Interface]
data/movements/scripts/mysticflame.lua:eek:nAddItem
data/movements/scripts/mysticflame.lua:107: attempt to index global 'self' (a nil value)
stack traceback:
[C]: in function '__index'
data/movements/scripts/mysticflame.lua:107: in function <data/movements/scripts/mysticflame.lua:1>
 
kimokimo, self is undefined. No where in that script shows self being defined.
It looks like you're trying to use onAddItem in moveevents, which doesn't contain a cid parameter anyways.

Like I've sent you in PM, you need to use the onMoveItem method for Player in the Events folder.
 
Oh probably forgot to remove the old script :p

No error now but i only get this
the item is not removed or given back to the player.
18:56 Your is not sellable, so it was returned to you.
 
To get the itemid, use item:getId() instead of item.itemid.
The item parameter is an Item userdata.
 

Similar threads

Back
Top