Postado Maio 21, 2015 10 anos Essa função em C++ retorna os monstros online no servidor. luascript.cpp Procure por int32_t LuaScriptInterface::luaGetPlayersOnline(lua_State* L) { //getPlayersOnline() ScriptEnviroment* env = getEnv(); AutoList<Player>::iterator it = Player::autoList.begin(); lua_newtable(L); for(int32_t i = 1; it != Player::autoList.end(); ++it, ++i) { lua_pushnumber(L, i); lua_pushnumber(L, env->addThing(it->second)); pushTable(L); } return 1; } Adicione abaixo int32_t LuaScriptInterface::luaGetMonstersOnline(lua_State* L) { //getMonstersOnline() ScriptEnviroment* env = getEnv(); AutoList<Monster>::iterator it = Monster::autoList.begin(); lua_newtable(L); for(int32_t i = 1; it != Monster::autoList.end(); ++it, ++i) { lua_pushnumber(L, i); lua_pushnumber(L, env->addThing(it->second)); pushTable(L); } return 1; } Procure por //getPlayersOnline() lua_register(m_luaState, "getPlayersOnline", LuaScriptInterface::luaGetPlayersOnline); Adicione abaixo //getMonstersOnline() lua_register(m_luaState, "getMonstersOnline", LuaScriptInterface::luaGetMonstersOnline); Agora em luascript.h Procure por static int32_t luaGetPlayersOnline(lua_State* L); Adicione abaixo static int32_t luaGetMonstersOnline(lua_State* L); Exemplo de uso: function onSay(cid, words, param, channel) local m = getMonstersOnline() if(not m) then return doPlayerSendCancel(cid, "No monsters") end for _, mid in ipairs(m) do local mpos = getThingPos(mid) doSendAnimatedText(mpos, 'WORK', 255) end return 0 end Créditos: Dalton Att, Grafit.
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.