Dominik ms
Member
- Joined
- Jan 20, 2010
- Messages
- 424
- Reaction score
- 6
in luascript.cpp
before:
add:
before:
add:
before:
add This:
in luascript.h
before
add this
example:
before:
PHP:
extern Game g_game;
PHP:
extern Actions* g_actions;
before:
PHP:
int32_t LuaScriptInterface::luaGetItemWeight(lua_State* L)
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;
}
PHP:
lua_register(m_luaState, "getPlayerSex", LuaScriptInterface::luaGetPlayerSex);
PHP:
lua_register(m_luaState, "doUseItem", LuaScriptInterface::luaInternalUseItem);
in luascript.h
before
PHP:
static int32_t luaDoCreateItem(lua_State* L);
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