• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[C++] Help to this script

perdigs

New Member
Joined
Aug 22, 2010
Messages
114
Reaction score
1
monsters.h
find
Code:
class Monster : public Creature
then add this under public:
Code:
std::string name, nameDescription;
find
Code:
virtual const std::string& getName() const {return mType->name;}
virtual const std::string& getNameDescription() const {return mType->nameDescription;}
virtual std::string getDescription(int32_t) const {return mType->nameDescription + ".";}
replace with
Code:
virtual const std::string& getName() const {return name;}
virtual const std::string& getNameDescription() const {return nameDescription;}
virtual std::string getDescription(int32_t) const {return nameDescription + ".";}

monsters.cpp
find
Code:
Monster::Monster(MonsterType* _mType): Creature()
add below
Code:
    name = _mType->name;
    nameDescription = _mType->nameDescription;

luascript.h
add near the similar lines
Code:
static int32_t luaSetCreatureName(lua_State* L);

luascript.cpp
add near similar lines
Code:
//setCreatureName(cid, name, description)
lua_register(m_luaState, "setCreatureName", LuaInterface::luaSetCreatureName);
add near similar lines
Code:
int32_t LuaInterface::luaSetCreatureName(lua_State* L)
{
	//setCreatureName(cid, newName, newDescription)
	std::string newDesc = popString(L);
	std::string newName = popString(L);
	ScriptEnviroment* env = getEnv();
	Creature* creature;
	if(creature = env->getCreatureByUID(popNumber(L))){
        Monster* monster = (Monster*)creature;
        monster->name = newName;
        monster->nameDescription = newDesc;
		lua_pushboolean(L, true);
    }
	else{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	return 1;
}

This script is for TFS 0.4 i need to transform to TFS 0.3.6
please help.
 
should be
lua_register(m_luaState, "setCreatureName", LuaScriptInterface::luaSetCreatureName);
and
int32_t LuaScriptInterface::luaSetCreatureName(lua_State* L)
 
Back
Top