Pesquisar na Comunidade
Mostrando resultados para as tags ''getplayeritems''.
Encontrado 1 registro
-
A função getPlayerItems lista todos os itens do player essa função e muito necessaria afinal a pessoal pode procurar itens especificos. Vá em luascript.cpp e procure: int32_t LuaScriptInterface::luaSetMonsterOutfit(lua_State* L) { //doSetMonsterOutfit(cid, name, time) int32_t time = (int32_t)popNumber(L); std::string name = popString(L); ScriptEnviroment* env = getEnv(); if(Creature* creature = env->getCreatureByUID(popNumber(L))) lua_pushboolean(L, Spell::CreateIllusion(creature, name, time) == RET_NOERROR); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Coloque embaixo: int32_t LuaScriptInterface::luaGetPlayerItems(lua_State* L) { typedef std::map<int32_t, Container*> Containerlist; typedef std::list<Item*> Itemlist; Itemlist itemlist; Containerlist container; ScriptEnviroment* env = getEnv(); Player* player = env->getPlayerByUID(popNumber(L)); if (!player) { errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND)); lua_pushboolean(L, false); return 1; } lua_newtable(L); for(int32_t slotId = 1; slotId < 11; ++slotId) { if (Item* item = player->inventory[slotId]) { itemlist.push_back(item); if(Container* containeritem = item->getContainer()) { container[container.size()+1] = (containeritem); } } } int32_t x = 0; Item* item = NULL; while (x < container.size()) { x = x+1; Cylinder* cylinder = container[x]; if (cylinder) { for(int32_t i = cylinder->__getFirstIndex(); i < cylinder->__getLastIndex(); i++) { if(item = cylinder->__getThing(i)->getItem()) { itemlist.push_back(item); if(Container* subContainer = item->getContainer()) { container[container.size()+1] = subContainer; } } } } } ItemList::iterator it = itemlist.begin(); for(int32_t i = 1; it != itemlist.end(); ++it, ++i) { if (Item* item = *it) { lua_pushnumber(L, i); env->addTempItem(env, item); lua_pushnumber(L, env->addThing(item)); pushTable(L); } } return 1; } Procure continuando em luascript.cpp: //doRemoveCreature(cid[, forceLogout = true]) lua_register(m_luaState, "doRemoveCreature", LuaScriptInterface::luaDoRemoveCreature); Abaixo coloque: //getPlayersItems(cid) lua_register(m_luaState, "getPlayerItems", LuaScriptInterface::luaGetPlayerItems); Em luascript.h procure: static int32_t luaGetPlayersByAccountId(lua_State* L); Coloque abaixo: static int32_t luaGetPlayerItems(lua_State* L); Exemplo de uso: function getItemsPlayer(cid, container) local x = {} local itens = getPlayerItems(cid) for i=1, #itens do if not isContainer(itens[i]) and not container then if (itens[i]) then table.insert(x, itens[i]) end end end return x end function onSay(cid, words, param, channel) local itens = getItemsPlayer(cid, false) local str = "" for i=1, #itens do if (itens[i]) then str = getItemName(itens[i]).."\n" end doShowTextDialog(cid, 1397, str) end return true end