• 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.X+ Create item talkaction, by client ID

Decodde

New Member
Joined
Oct 8, 2018
Messages
31
Reaction score
0
ObjectBuilder_2018-10-13_15-18-26.png RME_2018-10-13_15-18-46.png

Using image as example, if i want create a dead human, i say /i 6080

Is possible a new talk action to use the client id instead server id like /i 111
 
No without modification on the server side. AFAIK server doesn't read the tibia.dat file, to which you are referring, and in which those information like Client ID is saved. That means we can't know on the server what Client ID has an specified item. On the server side we can only know Server ID. Its impossible to know Client ID on the server.

Hope that clears out the question.

Regards,
 
No without modification on the server side. AFAIK server doesn't read the tibia.dat file, to which you are referring, and in which those information like Client ID is saved. That means we can't know on the server what Client ID has an specified item. On the server side we can only know Server ID. Its impossible to know Client ID on the server.

Hope that clears out the question.

Regards,
Do you know why items have different id in client id and server id? Just a messy?
 
Do you know why items have different id in client id and server id? Just a messy?

Client ids were invented for Tibia Client, and Server ids were a way to organise items in open tibia world. This way you can have 2 different items with same Client ID but different Server ID. Advantage of this is clear.
 
Code:
function onSay(player, words, param)
    if(not player:getGroup():getAccess()) then
        return true
    end

    if(player:getAccountType() < ACCOUNT_TYPE_GOD) then
        return false
    end

    logCommand(player, words, param)

    local split = param:split(",")

    local itemType = nil
    local data = tonumber(split[1]) or split[1]
    if(type(data) == "number") then
        for id = 100, 99999 do
            local clientType = ItemType(id)
            if(clientType:getClientId() == data) then
                itemType = clientType
            end
        end
    else
        itemType = ItemType(data)
    end

    if(itemType == nil or itemType:getId() == 0) then
        player:sendCancelMessage("There is no item with that id or name.")
        return false
    end

    local count = tonumber(split[2])
    if(count ~= nil) then
        if(itemType:isStackable()) then
            count = math.min(10000, math.max(1, count))
        elseif(not itemType:isFluidContainer()) then
            count = math.min(100, math.max(1, count))
        else
            count = math.max(0, count)
        end
    else
        if(not itemType:isFluidContainer()) then
            count = 1
        else
            count = 0
        end
    end

    local result = player:addItem(itemType:getId(), count)
    if(result ~= nil) then
        if(not itemType:isStackable()) then
            if(type(result) == "table") then
                for _, item in ipairs(result) do
                    item:decay()
                end
            else
                result:decay()
            end
        end
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    end

    return false
end
The ugly way but this is the only way to get done what you need without editing source to get advantage of "Items::getItemIdByName" function.
The desynchronization between server and client ids are because the .otb file been in maintain for many years and the deprecated items has been increasing more and more which results in "desynchronization".
It's possible to synchronize the server and client ids but you will need to create converter for map and there are some multiple server items that use the same client ids.
 
Back
Top