What's new

doUseItem(cid, item.uid)

Status
Not open for further replies.

dominikms1

Senior User
Joined
Feb 6, 2010
Messages
696
Reaction score
66
w luascript.cpp
PRZED:
PHP:
extern Game g_game;
DODAJ:
PHP:
extern Actions* g_actions;

PRZED:
PHP:
int32_t LuaScriptInterface::luaGetItemWeight(lua_State* L)
DODAJ:
PHP:
int32_t LuaScriptInterface::luaInternalUseItem(lua_State* L)
{
//BY DominikMS!!
	//doUseItem(cid, item.uid)
	ScriptEnviroment* env = getEnv();

	Item* item = env->getItemByUID(popNumber(L));
	Player* player = env->getPlayerByUID(popNumber(L));
	if(!player)
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
		return 1;
	}
	if(!item)
	{
		errorEx(getError(LUA_ERROR_ITEM_NOT_FOUND));
		lua_pushboolean(L, false);
		return 1;
	}

	Position pos = item->getPosition();
	uint8_t index = 0;

	g_actions->internalUseItem(player, pos, index, item, player->getID());

	lua_pushboolean(L, true);
	return 1;
}
before:
PHP:
lua_register(m_luaState, "getPlayerSex", LuaScriptInterface::luaGetPlayerSex);
add This:
PHP:
	lua_register(m_luaState, "doUseItem", LuaScriptInterface::luaInternalUseItem);

W luascript.h
PRZED
PHP:
static int32_t luaDoCreateItem(lua_State* L);
DODAJ
PHP:
static int32_t luaInternalUseItem(lua_State* L);


NP:
PHP:
function onUse(cid, item, pos, itemEx, topos)
	doUseItem(cid, getPlayerSlotItem(cid, CONST_SLOT_FEET).uid)
	return true
end
 

sawex

Advanced User
Joined
Aug 17, 2008
Messages
421
Reaction score
23
Odp: doUseItem(cid, item.uid)

Je?eli temat na otlandzie z tym jest te? tw?j to looz a jak nie to autora podaj.

A og?lnie jest to bardzo przydatna funkcja.
 
Status
Not open for further replies.
Top