Explica a função...
- Fórum
- OTServ
- Recursos
- Linguagens de Programação
- [CreatureScripts]Function onGainExp(cid, value)
PO
[CreatureScripts]Function onGainExp(cid, value)
Por PostadorHunter, 08 de mar. de 2013 em Linguagens de Programação
script
5
953
info
Grupo: Herói
Registrado: 14/12/10
Posts: 3.6k
Reputação: +846
Gênero: Masculino

08 de março de 2013 às 16:26
info
Grupo: Conde
Registrado: 10/12/11
Posts: 962
Reputação: +99
Gênero: Masculino

08 de março de 2013 às 16:30
é uma função que é executada quando o player ganha experiencia
1 mês depois...
25 de abril de 2013 às 11:23
vc nem testo a parada e ja vai postando
n dis nem pa ki verção e isso ai
ja tinha visto o poste do kinght
essa script n funciona
ps: v 0.4
Editado Abril 25 por Foxkbt





info
Grupo: Conde
Registrado: 10/12/11
Posts: 962
Reputação: +99
Gênero: Masculino
Créditos:knightxd
creatureevent.h
depois de:
adicione:
depois de:
adicione:
creatureevent.cpp
depois de:
adicione:
depois de:
adicione:
depois de:
adicione:
depois de:
adicione:
uint32_t CreatureEvent::executeGainExp(Player* player, int32_t value) { //onGainExp(cid, value) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(player->getPosition()); std::stringstream scriptstream; scriptstream << "local cid = " << env->addThing(player) << std::endl; scriptstream << "local value = " << value << 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[35]; sprintf(desc, "%s", player->getName().c_str()); env->setEvent(desc); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(player->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushnumber(L, value); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::clog << "[Error - CreatureEvent::executeGainExp] Call stack overflow." << std::endl; return 0; } }players.cpp
procure por:
substitua:
bool Player::gainExperience(double& gainExp, Creature* target) { if(!rateExperience(gainExp, target)) return false; if(gainExp >= 1) { bool deny = false; CreatureEventList gainExpEvents = this->getCreatureEvents(CREATURE_EVENT_GAINEXP); for(CreatureEventList::iterator it = gainExpEvents.begin(); it != gainExpEvents.end(); ++it) { if(!(*it)->executeGainExp(this, gainExp)) deny = true; } if(deny) return false; if(gainExp >= level) { if(Condition* condition = Condition::createCondition( CONDITIONID_DEFAULT, CONDITION_SOUL, 4 * 60 * 1000)) { condition->setParam(CONDITIONPARAM_SOULGAIN, vocation->getGainAmount(GAIN_SOUL)); condition->setParam(CONDITIONPARAM_SOULTICKS, (vocation->getGainTicks(GAIN_SOUL) * 1000)); addCondition(condition); } } addExperience((uint64_t)gainExp); } }