• 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 make your server client 8.61 Tutorial

mmm...

Initial AutoStacking Items (find functions and replace)

Tested only in 0.4

in container.cpp:

[cpp]
Cylinder* Container::__queryDestination(int32_t& index, const Thing* thing, Item** destItem,
uint32_t&)
{
if(index == 254 /*move up*/)
{
index = INDEX_WHEREEVER;
*destItem = NULL;

Container* parentContainer = dynamic_cast<Container*>(getParent());
if(parentContainer)
return parentContainer;

return this;
}
else if(index == 255 /*add wherever*/){
index = INDEX_WHEREEVER;
*destItem = NULL;
}
else if(index >= (int32_t)capacity()){
/*
if you have a container, maximize it to show all 20 slots
then you open a bag that is inside the container you will have a bag with 8 slots
and a "grey" area where the other 12 slots where from the container
if you drop the item on that grey area
the client calculates the slot position as if the bag has 20 slots
*/
index = INDEX_WHEREEVER;
*destItem = NULL;
}

const Item* item = thing->getItem();
if(item == NULL){
return this;
}

if(item->isStackable()){
if(item->getParent() != this){
//try find a suitable item to stack with
uint32_t n = 0;
for(ItemList::iterator cit = itemlist.begin(); cit != itemlist.end(); ++cit){
if((*cit) != item && (*cit)->getID() == item->getID() && (*cit)->getItemCount() < 100){
*destItem = (*cit);
index = n;
return this;
}

++n;
}
}
}

if(index != INDEX_WHEREEVER){
Thing* destThing = __getThing(index);
if(destThing)
*destItem = destThing->getItem();

Cylinder* subCylinder = dynamic_cast<Cylinder*>(*destItem);

if(subCylinder){
index = INDEX_WHEREEVER;
*destItem = NULL;
return subCylinder;
}
}

return this;
}
[/cpp]

item.cpp

[cpp]
void Item::setDefaultSubtype()
{
setItemCount(1);
const ItemType& it = items[id];
if(it.charges)
setCharges(it.charges);
}
[/cpp]

in player.cpp

[cpp]
Cylinder* Player::__queryDestination(int32_t& index, const Thing* thing, Item** destItem,
uint32_t& flags)
{
if(index == 0 /*drop to capacity window*/ || index == INDEX_WHEREEVER){
*destItem = NULL;

const Item* item = thing->getItem();
if(item == NULL){
return this;
}

//find an appropiate slot
std::list<Container*> containerList;
for(int i = SLOT_FIRST; i < SLOT_LAST; ++i){
Item* inventoryItem = inventory;

if(inventoryItem == tradeItem){
continue;
}

if(inventoryItem == tradeItem){
continue;
}

if(inventoryItem){
//try find an already existing item to stack with
if(inventoryItem != item && item->isStackable() && inventoryItem->getID() == item->getID() && inventoryItem->getItemCount() < 100){
*destItem = inventoryItem;
index = i;
return this;
}
//check sub-containers
else if(Container* subContainer = inventoryItem->getContainer()){
Cylinder* tmpCylinder = NULL;
int32_t tmpIndex = INDEX_WHEREEVER;
Item* tmpDestItem = NULL;

tmpCylinder = subContainer->__queryDestination(tmpIndex, item, &tmpDestItem, flags);
if(tmpCylinder && tmpCylinder->__queryAdd(tmpIndex, item, item->getItemCount(), flags) == RET_NOERROR){
index = tmpIndex;
*destItem = tmpDestItem;
return tmpCylinder;
}

containerList.push_back(subContainer);
}
}
//empty slot
else if(__queryAdd(i, item, item->getItemCount(), flags) == RET_NOERROR){
index = i;
*destItem = NULL;
return this;
}
}

//check deeper in the containers
for(std::list<Container*>::iterator it = containerList.begin(); it != containerList.end(); ++it){
for(ContainerIterator iit = (*it)->begin(); iit != (*it)->end(); ++iit){
if(Container* subContainer = (*iit)->getContainer()){

if(subContainer == tradeItem){
continue;
}

Cylinder* tmpCylinder = NULL;
int32_t tmpIndex = INDEX_WHEREEVER;
Item* tmpDestItem = NULL;

tmpCylinder = subContainer->__queryDestination(tmpIndex, item, &tmpDestItem, flags);
if(tmpCylinder && tmpCylinder->__queryAdd(tmpIndex, item, item->getItemCount(), flags) == RET_NOERROR){
index = tmpIndex;
*destItem = tmpDestItem;
return tmpCylinder;
}
}
}
}
return this;
}

Thing* destThing = __getThing(index);
if(destThing)
*destItem = destThing->getItem();

Cylinder* subCylinder = dynamic_cast<Cylinder*>(destThing);

if(subCylinder){
index = INDEX_WHEREEVER;
*destItem = NULL;
return subCylinder;
}
else
return this;
}
[/cpp]

Enjoy!

(i need help to make conjure runes in inventory instead the hands and apply another svn patch)

ADD REP++ PLEASE!
 
Last edited:
nice

---

your script bug my firstitems, when player create acc, firstitems is dropped o.o

i'm using tfs 0.3.6pl1
 
Last edited:
How to fix bug of npc don't buy items with charges (ex: potions)

In npc.cpp search:

Lua:
li.itemId = intValue;

After add:

Lua:
const ItemType& it = Item::items[li.itemId];

Search:

Lua:
if(readXMLInteger(tmpNode, "subtype", intValue))
li.subType = intValue;

After add:

Lua:
else
{
if(it.stackable)
li.subType = 1;
else if(it.isFluidContainer() || it.isSplash())
li.subType = 0;
}
 
How to fix bug of npc don't buy items with charges (ex: potions)

In npc.cpp search:

Lua:
li.itemId = intValue;

After add:

Lua:
const ItemType& it = Item::items[li.itemId];

Search:

Lua:
if(readXMLInteger(tmpNode, "subtype", intValue))
li.subType = intValue;

After add:

Lua:
else
{
if(it.stackable)
li.subType = 1;
else if(it.isFluidContainer() || it.isSplash())
li.subType = 0;
}

thanks for this, i'll need this to my 8.54 version xD
 
Im new here, im real friend of cykotitan "one member here maybe someone know him.
I want to make own ot server, But allways there is a problem for me.
What is problem "My ip addres are not ok.
I got msg when instaling XAMPP.
That 80. port number 3306 432 think are using " how to change "Local are is that??"
My conection is Hmm, i dont have router it is like signal box whic sending and reciveing packets.

I have use this link to help me "http://tibiahelp.com/index.php?page=download&op=getFile&id=1017&title=Tibia-Client-8-54-Windows"

I want create 8.57 or 8.54 "i dont know where can found rl map server with clien 8.57 and also i dont know whic ip i log on my home "is that 127.0.0.1"
Or ... Hmm how server restarting im new how i say, can anyyone make tutorial fulll :( for me please or give me a link.
I hope you will help me"Bosnian" <!
Thanks alot god blass you.


stefan < rl !
 
Why don't you ask Cykotitan if he's your rl friend? He should know, give him a call ;)
 
:p Cykotitan is your best key to getting everything you need buddy. He'll tell you everything about it.
 
Back
Top