Pesquisar na Comunidade
Mostrando resultados para as tags ''creatureevents''.
Encontrado 4 registros
-
GALERA PRECISSO DE UM SCRIPT QUE AO PUXAR A A ALANCA ADICIONA NA FRENTE Do nome [TRAIDOR] eu tinha visto um topico porem nao acho mais ............ u´p
-
Eae galera xtibiana! Creatureevents são eventos muitos ultilizados em otserv mais não existe uma forma de chamar um evento por ID em lua. Então desenvolvi um codigo que chama um evento especifico. Vá em luascript.cpp e procure: #include "baseevents.h" Coloque embaixo: #include "creatureevent.h" Procure: extern Spells* g_spells; Coloque embaixo: extern CreatureEvents* g_creatureEvents; Cotinuando em luascript.cpp e procure: int32_t LuaScriptInterface::luaGetIpByName(lua_State* L) { //getIpByName(name) std::string name = popString(L); if(Player* player = g_game.getPlayerByName(name)) lua_pushnumber(L, player->getIP()); else lua_pushnumber(L, IOLoginData::getInstance()->getLastIPByName(name)); return 1; } Coloque embaixo: int32_t LuaScriptInterface::luaStartEvent(lua_State* L) { ScriptEnviroment* env = getEnv(); std::string buffer = popString(L); int32_t event = popNumber(L); if(Creature* creature = env->getCreatureByUID(popNumber(L))) { lua_pushboolean(L, g_creatureEvents->startEvent(creature, event, buffer)); } } Continuando em luascript.cpp procure: //loadmodlib(lib) lua_register(m_luaState, "loadmodlib", LuaScriptInterface::luaL_loadmodlib); Coloque embaixo: //startEvent(cid, event, buffer) lua_register(m_luaState, "startEvent", LuaScriptInterface::luaStartEvent); Vá em luascript.h e procure: static int32_t luaGetContainerSize(lua_State* L); Procure embaixo: static int32_t luaStartEvent(lua_State* L); Vá em creatureevents.cpp e procure: bool CreatureEvents::playerLogin(Player* player) { //fire global event if is registered bool result = true; for(CreatureEventList::iterator it = m_creatureEvents.begin(); it != m_creatureEvents.end(); ++it) { if(it->second->getEventType() == CREATURE_EVENT_LOGIN && !it->second->executeLogin(player) && result) result = false; } return result; } Coloque embaixo: bool CreatureEvents::startEvent(Creature* creature, int32_t event, std::string buffer) { bool result = true; for(CreatureEventList::iterator it = m_creatureEvents.begin(); it != m_creatureEvents.end(); ++it) { if(it->second->getEventType() == CREATURE_EVENT_EVENT && !it->second->executeEvent(creature, event, buffer) && result) result = false; } return result; } Procure: else if(tmpStr == "preparedeath") m_type = CREATURE_EVENT_PREPAREDEATH; Coloque embaixo: else if(tmpStr == "event") m_type = CREATURE_EVENT_EVENT; Continuando em creatureevents.cpp procure: case CREATURE_EVENT_PREPAREDEATH: return "onPrepareDeath"; Coloque embaixo: case CREATURE_EVENT_EVENT: return "onEvent"; Procure: case CREATURE_EVENT_PREPAREDEATH: return "cid, deathList"; Coloque embaixo: case CREATURE_EVENT_EVENT: return "cid, event, buffer"; Procure: uint32_t CreatureEvent::executeDirection(Creature* creature, Direction old, Direction current) { //onDirection(cid, old, current) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local old = " << old << std::endl; scriptstream << "local current = " << current << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[30]; sprintf(desc, "%s", creature->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, old); lua_pushnumber(L, current); bool result = m_interface->callFunction(3); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeDirection] Call stack overflow." << std::endl; return 0; } } Coloque embaixo: uint32_t CreatureEvent::executeEvent(Creature* creature, int32_t event, std::string buffer) { //onOutfit(cid, old, current) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local event = " << event << std::endl; scriptstream << "local buffer = " << "'" << buffer << "'" << std::endl; scriptstream << m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ char desc[30]; sprintf(desc, "%s", creature->getName().c_str()); env->setEventDesc(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, event); lua_pushstring(L, buffer.c_str()); bool result = m_interface->callFunction(3); m_interface->releaseEnv(); return result; } } else { std::cout << "[Error - CreatureEvent::executeOutfit] Call stack overflow." << std::endl; return 0; } } Em creatureeevents.h procure: CREATURE_EVENT_PREPAREDEATH, Coloque embaixo: CREATURE_EVENT_EVENT Procure: bool playerLogout(Player* player, bool forceLogout); Coloque embaixo: bool startEvent(Creature* creature, int32_t event, std::string buffer); Continuando em creatureevents.h procure: uint32_t executeCombat(Creature* creature, Creature* target); E coloque embaixo: uint32_t executeEvent(Creature* creature, int32_t event, std::string buffer); Exemplo: function onSay(cid, words, param, channel) if startEvent(cid, 1, "\n") then return true end return false end function onEvent(cid, event, buffer) CREATURE_EVENT_PLAYERS_ON = 1 if event == CREATURE_EVENT_PLAYERS_ON then local players = getPlayersOnline() str = "" for i=1, #players do local sep = i >= #players and "" or buffer str = str..getCreatureName(players[i])..sep end doShowTextDialog(cid, 1397, str) return true end print("INVALID EVENT\nNumber "..event.."\nBuffer _"..buffer.."_') return true end
- 2 respostas
-
- startevent
- creatureevents
- (e 3 mais)
-
Bom dia, Alguém sabe como criar um scrip que faça com que um item seja dropado por todos os monstros do jogos?
-
Alguem me ajuda com os scripts da inquisition.. vlwss!!