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

Convert client to serverid

TibiCAM

Advanced OT User
Joined
Feb 3, 2020
Messages
156
Reaction score
204
Hello,

How can I convert between client / server id on items?
Using old client. Not 1.x

Example:

Gold coin should change from ID:
3031 -> 2148

Anyone did it with some Lua or C# script?
Like import text file with item id like "3031" and output "2148"

Bump! I see a lot of people post this same question but nobody seems to have resolved it... since like 2010! Anyone has any idea?
 
Bump! I see a lot of people post this same question but nobody seems to have resolved it... since like 2010! Anyone has any idea?
We should already get rid off these server item ids tbh, these are pointless - seen that someone is developing it already for TFS 1.x
 
Easiest and best way would be to add to NetworkMessage::addItem new int with serverId and then just read it on the client. That way you are sure that every item will have serverId.

Why do you need it if I may ask? Maybe there is a different solution that won't require serverId.
 
The main point is to first convert items.xml to client id, then item.otb to clientid and the map as well. The rest is easy.
Ah, you also have to change RME ids to client id, which is not too difficult either.

I could do a PR on tfs by making the changes I mentioned above. But, I don't know if it would be approved. You would only do PR if you are sure that merge would be given.
 
The main point is to first convert items.xml to client id, then item.otb to clientid and the map as well. The rest is easy.
Ah, you also have to change RME ids to client id, which is not too difficult either.

I could do a PR on tfs by making the changes I mentioned above. But, I don't know if it would be approved. You would only do PR if you are sure that merge would be given.

I suggesting doing the PR.
 
So how can I make my server use the id like "3031 = gold coin"? I don't know what C++ files to edit.
I'm using Avesta 7.4 at the moment.
 
I suggesting doing the PR.

I wouldn't open a PR of this magnitude to stay open, so I talked about the merge.
Post automatically merged:

So how can I make my server use the id like "3031 = gold coin"? I don't know what C++ files to edit.
I'm using Avesta 7.4 at the moment.

In fact, just change the items.xml and items.otb for client id
The problem is that this change will require changing all server ids to client id, and map conversion as well.
 
I wouldn't open a PR of this magnitude to stay open, so I talked about the merge.
Post automatically merged:



In fact, just change the items.xml and items.otb for client id
The problem is that this change will require changing all server ids to client id, and map conversion as well.

Yeah and then back to why I started this topic:
How do I change the items.xml to match the ids? It's basically what I try to do.
You make it seem like it's so easy but it's exactly what I try do here....
And I don't know how to change the items.otb to it either. So I am stuck at this point.
I either try convert CipSoft item ids to OT ids, and put them in items.xml.
Or I must somehow change the items.xml and items.otb to CipSoft id, also my map editor.
How can I edit the items.otb?

I have my default Avesta 7.4 items.xml and it is so incorrect on so many things.
That's why I extracted the items from 7.72 leaked files and made some changes.
But now I have a list of the (correct) item names, descriptions, etc. But it's using id like 3031 for gold.
I need to convert these to 2148 for gold, etc.

I found 1 function in the C++ code but I have no idea how to make a new function for it.

Code:
const ItemType& Items::getItemIdByClientId(int32_t spriteId) const
{
    uint32_t i = 100;
    ItemType* iType;
    do{
        iType = items.getElement(i);
        if(iType && iType->clientId == spriteId){
            return *iType;
        }
        i++;
    }while(iType);

    static ItemType dummyItemType; // use this for invalid ids
    return dummyItemType;
}

And it's used here:

Code:
else if(pos.y == 0 && pos.z == 0){
            const ItemType& it = Item::items.getItemIdByClientId(spriteId);
            if(it.id == 0){
                return NULL;
            }

            int32_t subType = -1;
            if(it.isFluidContainer()){
                int32_t maxFluidType = sizeof(reverseFluidMap) / sizeof(uint32_t);
                if(index < maxFluidType){
                    subType = reverseFluidMap[index];
                }
            }

            return findItemOfType(player, it.id, true, subType);
        }

But how can I make it like a command in-game to help me convert my id 3031 to 2148?
I wanna make it available in the Lua commands.
So I can write like:

/convert 3031

and in my console it will print 2148.
This way I can convert all my items to the ot id.

So there is this function in C++:
Item::items.getItemIdByClientId(spriteId);

How can I make a custom command in C++ that would call this function?

Anyone is good at it?
This is using Avesta 7.4 sources.

For example in the game there is that "getThing(uid)" command.
Any way to copy it and modify it a bit, to make it call the "getItemIdByClientId(spriteId)" function?

I'm sure someone has done it. I googled a lot and I found maaaany topics about this stuff. But nobody posted a solution yet.
But some people said they had fixed it. So if anyone knows how to make a custom command in the C++ files, tell me what files to edit and where to put the code, then I recompile and try it.

I wanna make in-game command:

/convert (item id)
eg. /convert 3031

and it will call C++ function getItemIdByClientId(spriteId) and then return the id


If I can't do it via code, I will sit 12 hours and go through items.xml (Avesta 7.4) with my correct items.xml (CipSoft) and manually do the changes. But it seems like a waste of time, when you can maybe make a command for it in-game.
Then I put an array of all my CipSoft id's and run the function, it prints out the values (or saves to a .txt file) and I'm done!

tl/dr: I have a list of CipSoft item id's (correct name, description, article, etc...) and I want to put them in my items.xml (Avesta). Best way would be to maybe make an in-game lua command that calls a C++ function, that converts the item id's. Then the output of that command will be a list of all corrected id's, then I can just put them in my items.xml
 
Last edited:
Yeah and then back to why I started this topic:
How do I change the items.xml to match the ids? It's basically what I try to do.
You make it seem like it's so easy but it's exactly what I try do here....
And I don't know how to change the items.otb to it either. So I am stuck at this point.
I either try convert CipSoft item ids to OT ids, and put them in items.xml.
Or I must somehow change the items.xml and items.otb to CipSoft id, also my map editor.
How can I edit the items.otb?

I have my default Avesta 7.4 items.xml and it is so incorrect on so many things.
That's why I extracted the items from 7.72 leaked files and made some changes.
But now I have a list of the (correct) item names, descriptions, etc. But it's using id like 3031 for gold.
I need to convert these to 2148 for gold, etc.

I found 1 function in the C++ code but I have no idea how to make a new function for it.

Code:
const ItemType& Items::getItemIdByClientId(int32_t spriteId) const
{
    uint32_t i = 100;
    ItemType* iType;
    do{
        iType = items.getElement(i);
        if(iType && iType->clientId == spriteId){
            return *iType;
        }
        i++;
    }while(iType);

    static ItemType dummyItemType; // use this for invalid ids
    return dummyItemType;
}

And it's used here:

Code:
else if(pos.y == 0 && pos.z == 0){
            const ItemType& it = Item::items.getItemIdByClientId(spriteId);
            if(it.id == 0){
                return NULL;
            }

            int32_t subType = -1;
            if(it.isFluidContainer()){
                int32_t maxFluidType = sizeof(reverseFluidMap) / sizeof(uint32_t);
                if(index < maxFluidType){
                    subType = reverseFluidMap[index];
                }
            }

            return findItemOfType(player, it.id, true, subType);
        }

But how can I make it like a command in-game to help me convert my id 3031 to 2148?
I wanna make it available in the Lua commands.
So I can write like:

/convert 3031

and in my console it will print 2148.
This way I can convert all my items to the ot id.

So there is this function in C++:
Item::items.getItemIdByClientId(spriteId);

How can I make a custom command in C++ that would call this function?

Anyone is good at it?
This is using Avesta 7.4 sources.

For example in the game there is that "getThing(uid)" command.
Any way to copy it and modify it a bit, to make it call the "getItemIdByClientId(spriteId)" function?

I'm sure someone has done it. I googled a lot and I found maaaany topics about this stuff. But nobody posted a solution yet.
But some people said they had fixed it. So if anyone knows how to make a custom command in the C++ files, tell me what files to edit and where to put the code, then I recompile and try it.

I wanna make in-game command:

/convert (item id)
eg. /convert 3031

and it will call C++ function getItemIdByClientId(spriteId) and then return the id


If I can't do it via code, I will sit 12 hours and go through items.xml (Avesta 7.4) with my correct items.xml (CipSoft) and manually do the changes. But it seems like a waste of time, when you can maybe make a command for it in-game.
Then I put an array of all my CipSoft id's and run the function, it prints out the values (or saves to a .txt file) and I'm done!

tl/dr: I have a list of CipSoft item id's (correct name, description, article, etc...) and I want to put them in my items.xml (Avesta). Best way would be to maybe make an in-game lua command that calls a C++ function, that converts the item id's. Then the output of that command will be a list of all corrected id's, then I can just put them in my items.xml

Until tomorrow I'll give you a light on that. Wait.
 
Here is the 7.72 CipSoft item id's I extracted/converted from "objects.srv" (it only includes: id, name, article, description)
Other attributes and "plural" (eg. gold coin -> gold coins) will be added later on by me.

I try to convert this to OT item numbers instead - and then also exclude any item that didn't exist in 7.4.

7.72 CipSoft items.xml

And here is default Avesta 7.4 items.xml
 
Here is the 7.72 CipSoft item id's I extracted/converted from "objects.srv" (it only includes: id, name, article, description)
Other attributes and "plural" (eg. gold coin -> gold coins) will be added later on by me.

I try to convert this to OT item numbers instead - and then also exclude any item that didn't exist in 7.4.

7.72 CipSoft items.xml

And here is default Avesta 7.4 items.xml
do you stil have these? :)
 
Back
Top