SHOW:
|
|
- or go back to the newest paste.
| 1 | uint32_t CreatureEvent::executeOpenChannel(Player* player, uint16_t channelId) | |
| 2 | {
| |
| 3 | //onOpenChannel(cid,channel) | |
| 4 | if(m_interface->reserveEnv()) | |
| 5 | {
| |
| 6 | ScriptEnviroment* env = m_interface->getEnv(); | |
| 7 | if(m_scripted == EVENT_SCRIPT_BUFFER) | |
| 8 | {
| |
| 9 | env->setRealPos(player->getPosition()); | |
| 10 | std::stringstream scriptstream; | |
| 11 | ||
| 12 | scriptstream << "local cid = " << env->addThing(player) << std::endl; | |
| 13 | scriptstream << "local channelId = " << channelId << std::endl; | |
| 14 | //added | |
| 15 | scriptstream << "local channelName = " << getChannel(player, channelId)->getChannelName(player, channelId) << std::endl; | |
| 16 | // | |
| 17 | ||
| 18 | scriptstream << m_scriptData; | |
| 19 | bool result = true; | |
| 20 | if(m_interface->loadBuffer(scriptstream.str())) | |
| 21 | {
| |
| 22 | lua_State* L = m_interface->getState(); | |
| 23 | result = m_interface->getGlobalBool(L, "_result", true); | |
| 24 | } | |
| 25 | ||
| 26 | m_interface->releaseEnv(); | |
| 27 | return result; | |
| 28 | } | |
| 29 | else | |
| 30 | {
| |
| 31 | #ifdef __DEBUG_LUASCRIPTS__ | |
| 32 | std::stringstream desc; | |
| 33 | desc << player->getName(); | |
| 34 | env->setEventDesc(desc.str()); | |
| 35 | #endif | |
| 36 | ||
| 37 | env->setScriptId(m_scriptId, m_interface); | |
| 38 | env->setRealPos(player->getPosition()); | |
| 39 | ||
| 40 | lua_State* L = m_interface->getState(); | |
| 41 | m_interface->pushFunction(m_scriptId); | |
| 42 | ||
| 43 | lua_pushnumber(L, env->addThing(player)); | |
| 44 | lua_pushnumber(L, channelId); | |
| 45 | // added | |
| 46 | lua_pushstring(L, getChannel(player, channelId)->getChannelName(player, channelId).c_str()); | |
| 47 | // | |
| 48 | ||
| 49 | bool result = m_interface->callFunction(2); | |
| 50 | m_interface->releaseEnv(); | |
| 51 | return result; | |
| 52 | } | |
| 53 | } | |
| 54 | else | |
| 55 | {
| |
| 56 | std::cout << "[Error - CreatureEvent::executeOpenChannel] Call stack overflow." << std::endl; | |
| 57 | return 0; | |
| 58 | } | |
| 59 | } |