Em luascript.h, adicione essa linha:
static int32_t luaDoStartTrade(lua_State* L);
coloca abaixo de linhas parecidas.
Em luascript.cpp, adicione isso:
//doStartTrade(cid, target, item)
lua_register(m_luaState, "doStartTrade", LuaInterface::luaDoStartTrade);
coloca perto de linhas parecidas.
e em luascript.cpp ainda. coloca isso também: (perto de algo parecido)
int32_t LuaInterface::luaDoStartTrade(lua_State* L)
{
ScriptEnviroment* env = getEnv();
Item* item = env->getItemByUID(popNumber(L));
if(!item)
{
errorEx(getError(LUA_ERROR_ITEM_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}
Player* target = env->getPlayerByUID(popNumber(L));
Player* player = env->getPlayerByUID(popNumber(L));
if(!player || !target)
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
return 1;
}
if(g_game.internalStartTrade(player, target, item))
{
lua_pushboolean(L, true);
return 1;
}
return 1;
}
todos os créditos da função para OneShot!
exemplo de uso:
local item = doPlayerAddItem(cid, 1234)
doStartTrade(cid, target, item)
dai é só criar um talkactions, usa como base esse que você comentou ai.
e cria um onTradeAccept(cid, target, item).
o talkactions para chamar a função doStartTrade, que vai simular o trade, e o tradeAccept para quando o trade for aceito.