• 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 Game.getMounts(), Game.getOutfits(sex)

Joe Rod

Discord: joerod1
Joined
Mar 16, 2011
Messages
499
Solutions
2
Reaction score
172
GitHub
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:
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 ¬¬
 
what do you get? You get a table with some fields
on Mounts
  • id
  • clientId (for lookType)
  • name
on Outfits
  • name
  • lookType
 
yes i'm 8.60
Post automatically merged:

can you tell me how plz?
Post automatically merged:

can you gave me vedio to show me or team v~
 
Last edited:
Back
Top