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

[7.6] NPC that buys empty vials

Erevius

It Was A Good Day
Joined
Feb 12, 2010
Messages
157
Reaction score
7
Location
Poland/Olsztyn
Hello! I need a npc that pays 5 gp for every empty vials (ID: 2006, 7) that player has in backpack. - You dont have to make all script. Just tell me how to make him count all empty vials (I mean, only with count = 0) and gives 5 gp for every vial. Is it possible to do it with Avesta?
 
#Cykotitan
Only for several functions, but unfortunately not for getPlayerItemCount function.

luascript.cpp
Code:
//getPlayerItemCount(cid, itemid)
	lua_register(m_luaState, "getPlayerItemCount", LuaScriptInterface::luaGetPlayerItemCount);

Code:
int LuaScriptInterface::luaGetPlayerItemCount(lua_State *L)
{
	//getPlayerItemCount(cid, itemid)
	uint32_t itemId = (uint32_t)popNumber(L);
	uint32_t cid = popNumber(L);

	ScriptEnviroment* env = getScriptEnv();

	const Player* player = env->getPlayerByUID(cid);
	if(player){
		uint32_t n = player->__getItemTypeCount(itemId);
		lua_pushnumber(L, n);
	}
	else{
		reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushnumber(L, LUA_ERROR);
	}
	return 1;
}

in luascript.h
Code:
	static int luaGetPlayerItemCount(lua_State *L);

Is it possible to edit this function (f.e. to getPlayerItemCount(cid, itemid, subType))?
 
might not compile out of the box, edit if necessary
[cpp]int32_t LuaScriptInterface::luaGetPlayerItemCount(lua_State* L)
{
//getPlayerItemCount(cid, itemid[, subType = -1])
int32_t subType = -1;
if(lua_gettop(L) > 2)
subType = popNumber(L);

uint32_t itemId = popNumber(L);
ScriptEnviroment* env = getEnv();
if(const Player* player = env->getPlayerByUID(popNumber(L)))
lua_pushnumber(L, player->__getItemTypeCount(itemId, subType));
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}[/cpp]source
 
nice errors you got there, mind sharing?

In static member function `static int32_t LuaScriptInterface::luaGetPlayerItemCount(lua_State*)':
3898 xxx\luascript.cpp `getEnv' was not declared in this scope
3903 xxx\luascript.cpp `getError' was not declared in this scope
3903 xxx\luascript.cpp `errorEx' was not declared in this scope
3903 xxx\luascript.cpp *** [obj/luascript.o] Error 1
sorry :p
 
Back
Top