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

Lua Function Change Existing Monster Name In-Game

Does it work for TFS[1.2]?
If not (can't confirm myself, because I never compiled anything) then can someone update it?
 
Does it work for TFS[1.2]?
If not (can't confirm myself, because I never compiled anything) then can someone update it?
Printer said some time ago that it is possible you just need to update the spectators list, however he did not go into much more detail than that.
 
From what I remember, the client saves the creature name when the creature first appears.

This means, the only way to update the creature's name is to have it teleport off screen, and back on screen (Or maybe just teleport at all). Unless you want to edit the client source parse, and tfs protocol, so it can send updated names each time it updates the character.
 
From what I remember, the client saves the creature name when the creature first appears.

This means, the only way to update the creature's name is to have it teleport off screen, and back on screen (Or maybe just teleport at all). Unless you want to edit the client source parse, and tfs protocol, so it can send updated names each time it updates the character.
I've got errors while compiling.. tried 3 times and everytime errors :/
 
For this to work on TFS 1.2

Monster.h

find
Code:
const std::string& getName() const final {

replace the 3 codes with this:
Code:
const std::string& getName() const final {
            return name;
        }
        const std::string& getNameDescription() const final {
            return nameDescription;
        }
        std::string getDescription(int32_t) const final {
            return nameDescription + '.';
        }

Luascript.h

find
Code:
static int luaSetItemOutfit(lua_State* L);

add this under it:
Code:
static int luaSetCreatureName(lua_State* L);

luascript.cpp

find:
Code:
int LuaScriptInterface::luaSetCreatureOutfit(lua_State* L)
{
    //doSetCreatureOutfit(cid, outfit, time)
    Creature* creature = getCreature(L, 1);
    if (!creature) {
        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        pushBoolean(L, false);
        return 1;
    }

    Outfit_t outfit = getOutfit(L, 2);
    int32_t time = getNumber<int32_t>(L, 3);
    pushBoolean(L, Spell::CreateIllusion(creature, outfit, time) == RETURNVALUE_NOERROR);
    return 1;
}

Under that paste this:

Code:
int LuaScriptInterface::luaSetCreatureName(lua_State* L)
{
    //setCreatureName(cid, newName, newDescription)
    Creature* creature = getCreature(L, 1);
    if (creature) {
        Monster* monster = (Monster*)creature;
        std::string newName = getString(L, 2);
        std::string newDesc = getString(L, 3);
        monster->name = newName;
        monster->nameDescription = newDesc;
        pushBoolean(L, false);
    }
    else {
        reportErrorFunc(getErrorDesc(LUA_ERROR_CREATURE_NOT_FOUND));
        pushBoolean(L, false);
    }
    return 1;
}


find
Code:
//doSetCreatureOutfit(cid, outfit, time)
    lua_register(luaState, "doSetCreatureOutfit", LuaScriptInterface::luaSetCreatureOutfit);

Under add this:
Code:
//setCreatureName(cid, name, description)
    lua_register(luaState, "setCreatureName", LuaScriptInterface::luaSetCreatureName);


Enjoy... Works the same.
 
Make sure you still add

Code:
std::string name, nameDescription;

In the same spot.
 
could you help me please?
where should i put this?

thanks in advice!!

Look on the thread owners tutorial and look for where its placed. Put it in the same spot as he did.
 
Back
Top