• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

doUseItem(cid, item) ^^

Dominik ms

Member
Joined
Jan 20, 2010
Messages
424
Reaction score
6
in luascript.cpp
before:
PHP:
extern Game g_game;
add:
PHP:
extern Actions* g_actions;

before:
PHP:
int32_t LuaScriptInterface::luaGetItemWeight(lua_State* L)
add:
PHP:
int32_t LuaScriptInterface::luaInternalUseItem(lua_State* L)
{
	//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);

in luascript.h
before
PHP:
static int32_t luaDoCreateItem(lua_State* L);
add this
PHP:
static int32_t luaInternalUseItem(lua_State* L);


example:
PHP:
function onUse(cid, item, pos, itemEx, topos)
	doUseItem(cid, getPlayerSlotItem(cid, CONST_SLOT_FEET).uid)
	return true
end
 
error on compiling
errorcompilando.png
 
Ahh Sorry, i forgott about this.
You must this code cut from private and paste to public.
 
Dont work correctly, always the GUI shows:
GUI said:
[22/05/2011 15:20:17] [Error - TalkAction Interface]
[22/05/2011 15:20:17] data/talkactions/scripts/script.lua:eek:nSay
[22/05/2011 15:20:17] Description:
[22/05/2011 15:20:17] (luaInternalUseItem) Item not found


I use the function like this: doUseItem(cid, 55555)

And '55555' it is a valid UID on the server....
 
@KylerXX, you must have this item in bp and you can't use id/UID item, you should give position item ex.
PHP:
getPlayerSlotItem(cid, CONST_SLOT_FEET).uid
 
Yes, you can use uid of item.
example:
doItemSetAttribute(item.uid, "uid", 5555)
then
doUseItem(cid, 5555)
 
Ahh Sorry, i forgott about this.
You must this code cut from private and paste to public.

Man i follow every steps and i saw a error like the Strack's error, and you sad to fix it i need do it:
You must this code cut from private and paste to public
I dont understand how i can do it because im newbie in C++ programation, please show me how.
 
Man i follow every steps and i saw a error like the Strack's error, and you sad to fix it i need do it:
You must this code cut from private and paste to public
I dont understand how i can do it because im newbie in C++ programation, please show me how.

If you scroll down in that source file, you will see public functions instead of protected ones; paste it there instead.
 
Back
Top