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

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,858
Reaction score
96
Location
Brazil
This is not saving house items, can someone help?
dev0.4,3777

Lua:
		local playerHouseId = getHouseByPlayerGUID(getPlayerGUID(cid))
		doSaveHouse(playerHouseId)
 
Last edited:
Do not work to 0.4
Doesn't work at 0.4 (btw, i had premium)



iomapserialize.cpp:257: error: no 'bool IOMapSerialize::saveHouseItems(Database*, House*)' member function declared in class 'IOMapSerialize'
make[1]: *** [iomapserialize.o] Error 1
make[1]: Leaving directory `/home/ots2/silnik'
make: *** [all] Error 2
root@vm157:/home/ots2/silnik# make
make all-am
make[1]: Entering directory `/home/ots2/silnik'
make[1]: Warning: File `iomapserialize.h' has modification time 19 s in the future


I know i refreshed the topic, but this is very important for me.
 
try:

Code:
for _, v in pairs(getPlayersOnline()) do
	local k = getPlayerGUIDByName(v)
	local x = getHouseByPlayerGUID(k)
	doSaveHouse(x)
end

or

Code:
local g = getPlayerGUID(cid)
local id= getHouseByPlayerGUID(g)
doSaveHouse(id)

Posso fazer a função funcionar na rev3777, me manda seu msn por PM...
 
Do not work, I've tested boths
try:

Code:
for _, v in pairs(getPlayersOnline()) do
	local k = getPlayerGUIDByName(v)
	local x = getHouseByPlayerGUID(k)
	doSaveHouse(x)
end

or

Code:
local g = getPlayerGUID(cid)
local id= getHouseByPlayerGUID(g)
doSaveHouse(id)

Posso fazer a função funcionar na rev3777, me manda seu msn por PM...
 
I found a function.. credits to mock:

Code:
		static int32_t luaDoSaveHouse(lua_State* L);

Code:
	//doSaveHouse(houseId)
	lua_register(m_luaState, "doSaveHouse", LuaInterface::luaDoSaveHouse);

Code:
int32_t LuaInterface::luaDoSaveHouse(lua_State* L)
{
	//doSaveHouse(houseId)
	bool displayError = true;
	if(lua_gettop(L) > 1)
		displayError = popNumber(L);

	House* house = Houses::getInstance()->getHouse(popNumber(L));
	if(!house)
	{
		if(displayError)
		errorEx(getError(LUA_ERROR_HOUSE_NOT_FOUND));
		lua_pushboolean(L, false);
		return 1;
	}

	Database* db = Database::getInstance();
	DBTransaction trans(db);
	if(!trans.begin())
		return false;

	IOMapSerialize::getInstance()->saveHouse(db,house);
	lua_pushboolean(L, trans.commit());

	return 1;
}
 
yeah..

vo fala em br mesmo q.q

1º code: luascript.h -> adiciona ele antes de

Code:
static int32_t luaSetCreatureMaxHealth(lua_State* L);

2º code: luascript.cpp -> adiciona ele antes de:
Code:
	//getCreatureHealth(cid)
	lua_register(m_luaState, "getCreatureHealth", LuaInterface::luaGetCreatureHealth);

3º code: luascript.cpp -> adiciona antes de:
Code:
int32_t LuaInterface::luaGetCreatureHealth(lua_State* L)
{
	//getCreatureHealth(cid)
	ScriptEnviroment* env = getEnv();
	if(Creature* creature = env->getCreatureByUID(popNumber(L)))
		lua_pushnumber(L, creature->getHealth());
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}
 
Before:

Code:
		static int32_t luaSetCreatureMaxHealth(lua_State* L);

Add:

Code:
		static int32_t luaDoSaveHouse(lua_State* L);

Before:
Code:
	//getCreatureHealth(cid)
	lua_register(m_luaState, "getCreatureHealth", LuaInterface::luaGetCreatureHealth);

Add:
Code:
	//doSaveHouse(houseId)
	lua_register(m_luaState, "doSaveHouse", LuaInterface::luaDoSaveHouse);

Before:
Code:
int32_t LuaInterface::luaGetCreatureHealth(lua_State* L)
{
	//getCreatureHealth(cid)
	ScriptEnviroment* env = getEnv();
	if(Creature* creature = env->getCreatureByUID(popNumber(L)))
		lua_pushnumber(L, creature->getHealth());
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}

Add:
Code:
int32_t LuaInterface::luaDoSaveHouse(lua_State* L)
{
	//doSaveHouse(houseId)
	bool displayError = true;
	if(lua_gettop(L) > 1)
		displayError = popNumber(L);

	House* house = Houses::getInstance()->getHouse(popNumber(L));
	if(!house)
	{
		if(displayError)
		errorEx(getError(LUA_ERROR_HOUSE_NOT_FOUND));
		lua_pushboolean(L, false);
		return 1;
	}

	Database* db = Database::getInstance();
	DBTransaction trans(db);
	if(!trans.begin())
		return false;

	IOMapSerialize::getInstance()->saveHouse(db,house);
	lua_pushboolean(L, trans.commit());

	return 1;
}
 
Before:

Code:
		static int32_t luaSetCreatureMaxHealth(lua_State* L);

Add:

Code:
		static int32_t luaDoSaveHouse(lua_State* L);

Before:
Code:
	//getCreatureHealth(cid)
	lua_register(m_luaState, "getCreatureHealth", LuaInterface::luaGetCreatureHealth);

Add:
Code:
	//doSaveHouse(houseId)
	lua_register(m_luaState, "doSaveHouse", LuaInterface::luaDoSaveHouse);

Before:
Code:
int32_t LuaInterface::luaGetCreatureHealth(lua_State* L)
{
	//getCreatureHealth(cid)
	ScriptEnviroment* env = getEnv();
	if(Creature* creature = env->getCreatureByUID(popNumber(L)))
		lua_pushnumber(L, creature->getHealth());
	else
	{
		errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}

Add:
Code:
int32_t LuaInterface::luaDoSaveHouse(lua_State* L)
{
	//doSaveHouse(houseId)
	bool displayError = true;
	if(lua_gettop(L) > 1)
		displayError = popNumber(L);

	House* house = Houses::getInstance()->getHouse(popNumber(L));
	if(!house)
	{
		if(displayError)
		errorEx(getError(LUA_ERROR_HOUSE_NOT_FOUND));
		lua_pushboolean(L, false);
		return 1;
	}

	Database* db = Database::getInstance();
	DBTransaction trans(db);
	if(!trans.begin())
		return false;

	IOMapSerialize::getInstance()->saveHouse(db,house);
	lua_pushboolean(L, trans.commit());

	return 1;
}


I will test

- - - Updated - - -

It's not saving itens inside house.
 
Back
Top