Joe Rod
Discord: joerod1
Hi, with this functions you will get a list of all available mounts/outfits that you have added to xml file
Tested on OTX3, this works on TFS 1.X
luascript.h
after this:
paste this:
luascript.cpp
after
paste this:
after this method:
paste this:
enjoy it, if you like it you can leave feedback ¬¬
Tested on OTX3, this works on TFS 1.X
luascript.h
after this:
Code:
static int luaGameGetHouses(lua_State* L);
paste this:
Code:
static int luaGameGetMounts(lua_State* L);
static int luaGameGetOutfits(lua_State* L);
luascript.cpp
after
Code:
registerMethod("Game", "getHouses", LuaScriptInterface::luaGameGetHouses);
paste this:
Code:
registerMethod("Game", "getMounts", LuaScriptInterface::luaGameGetMounts);
registerMethod("Game", "getOutfits", LuaScriptInterface::luaGameGetOutfits);
after this method:
Code:
int LuaScriptInterface::luaGameGetHouses(lua_State* L)
paste this:
Code:
int LuaScriptInterface::luaGameGetMounts(lua_State* L)
{
const std::vector<Mount>& mountList = g_game.mounts.getMounts();
// Game.getMounts()
lua_createtable(L, mountList.size(), 0);
int index = 0;
for (const Mount& mount : mountList) {
lua_createtable(L, 0, 3);
setField(L, "id", mount.id);
setField(L, "clientId", mount.clientId);
setField(L, "name", mount.name);
lua_rawseti(L, -2, ++index);
}
return 1;
}
int LuaScriptInterface::luaGameGetOutfits(lua_State* L)
{
// Game.getOutfits(sex)
PlayerSex_t sex = getNumber<PlayerSex_t>(L, 1);
const auto& outfits = Outfits::getInstance()->getOutfits(sex);
lua_createtable(L, outfits.size(), 0);
int index = 0;
for (const Outfit& outfit : outfits)
{
lua_createtable(L, 0, 2);
setField(L, "name", outfit.name);
setField(L, "lookType", outfit.lookType);
lua_rawseti(L, -2, ++index);
}
return 1;
}
enjoy it, if you like it you can leave feedback ¬¬