• 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 uid item through otclient

Rivaldo Maciel

New Member
Joined
Jan 1, 2017
Messages
9
Reaction score
2
hello guys, I'm working on a module for otclient and I need to get the uid of an item but I could only get the serverId. Is there any way to get the uid since two or more items can contain the same serverId?
ps: OTC version : 0.6.6
 
I am creating a market system for my server, there is a button that selects a certain item and adds it to the offer list. For common items it works very well, the however is when the player has two pokemons of the same species (both use the same serverId) but I want to reference only one in specific. Do you have any idea how I can do it?
Post automatically merged:

if there was some way to get the item description from the client side, that would also solve it, but I searched and didn't find anything of the kind
 
I am creating a market system for my server, there is a button that selects a certain item and adds it to the offer list. For common items it works very well, the however is when the player has two pokemons of the same species (both use the same serverId) but I want to reference only one in specific. Do you have any idea how I can do it?
Post automatically merged:

if there was some way to get the item description from the client side, that would also solve it, but I searched and didn't find anything of the kind
You can get an item by its position and sprite id. That's how using items works (send used item position with stack pos).
 
You can get an item by its position and sprite id. That's how using items works (send used item position with stack pos).
To get the item's position, I use the function: 'clickedWidget:getPosition()' on the client side, and use the function: 'getThingPos(item)' on the server side, but the positions are different. Am I using the correct functions?
 
To get the item's position, I use the function: 'clickedWidget:getPosition()' on the client side, and use the function: 'getThingPos(item)' on the server side, but the positions are different. Am I using the correct functions?
Item position != widget position.
 
Item position != widget position.
I tried this way but the positions are still different :(
Post automatically merged:

I tried this way but the positions are still different :(
when i use 'item:getPosition()' the return is always the same for any item clicked
Post automatically merged:

I found that the function: getThingPos(uid).x is taking the position of the player and not the item, even passing the uid of the item to it
 

Attachments

Last edited:
That's what I'm using and it works perfectly fine. Maybe its your server fault, I don't know. I don't support old TFS versions.
 
I tried this way but the positions are still different :(
Post automatically merged:


when i use 'item:getPosition()' the return is always the same for any item clicked
Post automatically merged:

I found that the function: getThingPos(uid).x is taking the position of the player and not the item, even passing the uid of the item to it

Item position inside container is different from the (parents) position on map.
 
I am creating a market system for my server, there is a button that selects a certain item and adds it to the offer list. For common items it works very well, the however is when the player has two pokemons of the same species (both use the same serverId) but I want to reference only one in specific. Do you have any idea how I can do it?
Post automatically merged:

if there was some way to get the item description from the client side, that would also solve it, but I searched and didn't find anything of the kind
To find given item on server side you need 3 values from client:
  • position (x,y,z)
  • stack position (stackpos) - only when use item from tile or hotkey with fluid (ex. bottle of vine - bottle is in 'item id', vine [type of fluid] is send as 'stack position')
  • item id

Item 'position' in client-server communication may have 2 different types of value:
  • - real position on map ex. 32456, 32682, 7 - for real position, it also requires 'stack position' to get given item from tile
  • - virtual position pointing to open container / player inventory (EQ) - here starts magic (x = 65535 indicates that's "it's not on map") :
    • pos: 65535, 64, 0 - open container ID 0 (pos.y - 64), slot no 0
    • pos: 65535, 64, 1 - open container ID 0 (pos.y - 64), slot no 1
    • pos: 65535, 65, 0 - open container ID 1 (pos.y - 64), slot no 0
    • pos: 65535, 0, 0 - search for item with given ID in all containers (ex. when player use hotkey)
    • pos: 65535, 1, 0 - player EQ slot 1 (helmet)
    • pos: 65535, 11, 0 - player store inbox

Check in OTClient how void Game::useWith(const ItemPtr& item, const ThingPtr& toThing) works. It sends Item - it's position, stack and item id - to server.

On server side position sent by client is processed by Thing* Game::internalGetThing(Player* player, const Position& pos, int32_t index, uint32_t spriteId, stackPosType_t type) const
  • pos is position I described above
  • index is stack position
  • spriteId is ID of item in client (as in Tibia.dat file)
 
Last edited:
Para encontrar determinado item no lado do servidor, você precisa de 3 valores do cliente:
  • posição (x,y,z)
  • posição da pilha (stackpos) - somente quando usar item do bloco ou tecla de atalho com fluido (ex. garrafa de vine - garrafa está em 'item id', vine [tipo de fluido] é enviado como 'posição de pilha')
  • ID do item

O item 'posição' na comunicação cliente-servidor pode ter 2 tipos diferentes de valor:
  • - posição real no mapa ex. 32456, 32682, 7 - para posição real, também requer 'posição de pilha' para obter determinado item do bloco
  • - posição virtual apontando para abrir o container/inventário do jogador (EQ) - aqui começa a mágica (x = 65535 indica que "não está no mapa"):
    • pos: 65535, 64, 0 - open container ID 0 (pos.y - 64), slot nº 0
    • pos: 65535, 64, 1 - open container ID 0 (pos.y - 64), slot nº 1
    • pos: 65535, 65, 0 - ID de contêiner aberto 1 (pos.y - 64), slot nº 0
    • pos: 65535, 0, 0 - busca por item com determinado ID em todos os containers (ex. quando o jogador usa hotkey)
    • pos: 65535, 1, 0 - player EQ slot 1 (capacete)
    • pos: 65535, 11, 0 - caixa de entrada da loja do jogador

Verifique no OTClient como void Game::useWith(const ItemPtr& item, const ThingPtr& toThing) funciona. Ele envia Item - sua posição, pilha e id do item - para o servidor.

No lado do servidor, a posição enviada pelo cliente é processada por Thing* Game::internalGetThing(Player* player, const Position& pos, int32_t index, uint32_t spriteId, stackPosType_t type) const
  • pos é a posição que descrevi acima
  • index é a posição da pilha
  • spriteId é o ID do item no cliente (como no arquivo Tibia.dat)
your explanation was very good! I managed to get the position on the client side and send it to the server in the style: 65535, 64, 0. My question now is how to get these values on the server side to be able to compare them. Could you tell me which function could take this slot position? I'm using 'getThingPos(uid)' but it returns the player's position

ps: I managed to form an array of items/item that were filtered by the serverId (sent by the client). This array is necessary because because it is a pokemon server with icons, there can be two pokemons of the same species. My goal now is to get their position and compare it to the position received by the client. The problem is what happens in the description above with the function 'getThingPos(uidArrayItem)'
 
your explanation was very good! I managed to get the position on the client side and send it to the server in the style: 65535, 64, 0. My question now is how to get these values on the server side to be able to compare them. Could you tell me which function could take this slot position? I'm using 'getThingPos(uid)' but it returns the player's position

ps: I managed to form an array of items/item that were filtered by the serverId (sent by the client). This array is necessary because because it is a pokemon server with icons, there can be two pokemons of the same species. My goal now is to get their position and compare it to the position received by the client. The problem is what happens in the description above with the function 'getThingPos(uidArrayItem)'
There is probably no function in Lua that you can use to get Item using client position and item id.
You probably need to add in luascripts.cpp and luascripts.h new function that allow you to call Game::internalGetThing from Lua.
 
I achieved!!! Thank you very much' I got it with the 'getPlayerSlotItem' functions and I got it' with your explanation of the item's position in the container! I reiterate my deep thanks Gesior and everyone who commented!
 
Back
Top