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

C++ Toggle mount again if player was mounted befor loged off?

Marko999x

999x HIGHExP
Premium User
Joined
Dec 14, 2017
Messages
3,547
Solutions
95
Reaction score
2,698
Location
Germany
Hey im trying to toggle mount on login if player was mounted befor he loged off.
I got player:toggleMount() but it will always toggle the mount even if player wasn't mounted befor.
If you got any idea or the best solution for that case I will really appreciate it
King regards

( I could add a storage onMount and onDisMount and check that on login as example
if player:getStorageValue(349) == 1 then
player:toggleMount()
end
but not sure if that's the best solution )

TFS 1.5
 
You could save/load the lookmount field on iologindata.cpp, the engine will handle the rest

Worked perfect thanks!
Here the fix:

in iologindata.cpp

after:
C++:
query << "`lookaddons` = " << static_cast<uint32_t>(player->defaultOutfit.lookAddons) << ',';
add:
C++:
query << "`lookmount` = " << static_cast<uint32_t>(player->defaultOutfit.lookMount) << ',';

after:
C++:
player->defaultOutfit.lookAddons = result->getNumber<uint16_t>("lookaddons");
add:
C++:
player->defaultOutfit.lookMount = result->getNumber<uint16_t>("lookmount");

in function
bool IOLoginData::loadPlayerById(Player* player, uint32_t id)
and
bool IOLoginData::loadPlayerByName(Player* player, const std::string& name)

after:
C++:
 `lookaddons`
add
C++:
`lookmount`
like this:
1728159159194.webp

in database execute this:
PHP:
ALTER TABLE players ADD lookmount INT NOT NULL DEFAULT 0 AFTER lookaddons


Have fun and thanks to @Roddet
To a mod:
Make sure to add the solution for Roddet.
 
Last edited:
No problem! There is something I forgot though, we must enable the attributes (or speed) somehow.

C++:
const Mount* mount = g_game.mounts.getMountByClientID(defaultOutfit.lookMount);
if (mount && mount->speed > 0 && mount->id == getCurrentMount()) {
    g_game.changeSpeed(this, mount->speed);
}

You can add it here
 
Back
Top