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

Feature Useful changes

Rafael Hamdan

OT Developer
Joined
Dec 12, 2007
Messages
98
Reaction score
1
Location
Brasil - Minas Gerais
Hello!

These are cool features made for TFS or OpenTibia (if you know how to adapt it :p)

I won't explain EXACTLY where you should put codes, so if you don't know anything about c++, leave :thumbup:


1. Death System (small change)


Remove deaths as Tibia: they're stored in database for X days, then they're removed. (in tibia, x value is 30)

In configmanager.cpp, add:

Code:
m_confInteger[CLEAR_DEATHS_FREQUENCE] = getGlobalNumber(L, "clearDeathsFrequence", 30);

in configmanager.h, in number_config_t enum, add:

Code:
CLEAR_DEATHS_FREQUENCE,

in iologindata.cpp, add this function:

Code:
bool IOLoginData::clearDeaths()
{
    Database* db = Database::getInstance();
	DBQuery query;
    
    uint32_t time = (time(NULL) - (g_config.getNumber(ConfigManager::CLEAR_DEATHS_FREQUENCE) * 86400));
	query << "DELETE FROM `player_deaths` WHERE `time` <= " << time;
    return db->executeQuery(query.str());
}

in iologindata.h add this:

Code:
bool clearDeaths();

and, in the end of Game::saveGameState() execute the function clearDeaths():

Code:
IOLoginData::getInstance()->clearDeaths();

Then add in config.lua the "clearDeathsFrequence = 30"


2. House Paying System


We could make the system smarter, instead of puting "rentAsPrice", "priceAsRent", and all those things, we could just keep using houseSqmPrice (dunnow if it's the right name) and use + 1 string:

houseRentTilePrice

We would just remove the old system (keeping houseSqmPrice) and then:

PS: if player wants to use rent price set in map editor, he should set as 0 in config.lua

Replace this:

Code:
				if(readXMLInteger(houseNode, "rent", intValue))
					house->setRent(intValue);

for this:

Code:
                uint32_t rentPrice = house->getHouseTileSize() * g_config.getNumber(ConfigManager::HOUSE_RENT_TILE);
				if(rentPrice > 0)
                    house->setRent(rentPrice);
                else if(readXMLInteger(houseNode, "rent", intValue))
				    house->setRent(intValue);

in configmanager.cpp:

Code:
m_confInteger[HOUSE_RENT_TILE] = getGlobalNumber(L, "houseRentTilePrice", 0);

and in configmanager.h (enum of integers):

Code:
HOUSE_RENT_TILE,

Now you add "houseRentTilePrice = X" in config.lua

BE SURE YOU REMOVED THE OLD SYSTEM BUT KEPT THE houseSqmPrice

This is not the finish, still editing the topic :D
 
@Rafael Hamdan
Time function in Ban code it is really strange. Did you have tested?

@off
Btw, i want to contact you (if possible, of course), i am in irc (irc.highway.net -> #otnet) or (irc.quakenet.org -> #otserv).
 
Hello. In first functions is somes wrong line:

Change:
Code:
m_confInteger[CLEAR_DEATHS_FREQUENCE] = getGlobalNumber(L, "clearDeathsFrequence", 30);
To:
Code:
m_confNumber[CLEAR_DEATHS_FREQUENCE] = getGlobalNumber(L, "clearDeathsFrequence", 30);

Also replace:
Code:
query << "DELETE FROM `player_deaths` WHERE `time` <= " << time;
To:
Code:
query << "DELETE FROM `player_deaths` WHERE `time` <= " << (g_config.getNumber(ConfigManager::CLEAR_DEATHS_FREQUENCE) * 86400);
And delete this line:
Code:
uint32_t time = (time(NULL) - (g_config.getNumber(ConfigManager::CLEAR_DEATHS_FREQUENCE) * 86400));
That all...and all works ; )
 
Last edited:
Back
Top