• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua saveHouseItens

LucasFerraz

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

Lua:
		local playerHouseId = getHouseByPlayerGUID(getPlayerGUID(cid))
		doSaveHouse(playerHouseId)
 
Last edited:
OP
OP
LucasFerraz

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,855
Reaction score
93
Location
Brazil
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
[email protected]:/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.
 

Fire Element

Member
Joined
Sep 10, 2010
Messages
194
Reaction score
22
Location
Brazil
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...
 
OP
OP
LucasFerraz

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,855
Reaction score
93
Location
Brazil
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...
 

Fire Element

Member
Joined
Sep 10, 2010
Messages
194
Reaction score
22
Location
Brazil
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;
}
 

Fire Element

Member
Joined
Sep 10, 2010
Messages
194
Reaction score
22
Location
Brazil
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;
}
 

Fire Element

Member
Joined
Sep 10, 2010
Messages
194
Reaction score
22
Location
Brazil
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;
}
 
OP
OP
LucasFerraz

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,855
Reaction score
93
Location
Brazil
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.
 
Top