--º By: OrochiElf º--
Função testada na versao
TFS 0.3.6pl1
Essa funçao como diz o titulo , adiciona direto os pontos de SKILLS, com o ID escolhidlo. sem precisar "RELOGAR", para atulizar o SQL.
Bom ,então vamos começar a instalar.
Primeiro vá em LUASCRIPT.CPP, e procure por
//doSendAnimatedText(pos, text, color[, player]) lua_register(m_luaState, "doSendAnimatedText", LuaScriptInterface::luaDoSendAnimatedText);
E logo abaixo adicione
//doPlayerSetSkillLevel(cid, skill, value) /* new */ lua_register(m_luaState, "doPlayerSetSkillLevel", LuaScriptInterface::luaDoPlayerSetSkillLevel);
Procure por
int32_t LuaScriptInterface::luaDoSendDistanceShoot(lua_State* L) { //doSendDistanceShoot(fromPos, toPos, type[, player]) ScriptEnviroment* env = getEnv(); SpectatorVec list; if(lua_gettop(L) > 3) { if(Creature* creature = env->getCreatureByUID(popNumber(L))) list.push_back(creature); } uint32_t type = popNumber(L); PositionEx toPos, fromPos; popPosition(L, toPos); popPosition(L, fromPos); if(fromPos.x == 0xFFFF) fromPos = env->getRealPos(); if(toPos.x == 0xFFFF) toPos = env->getRealPos(); if(!list.empty()) g_game.addDistanceEffect(list, fromPos, toPos, type); else g_game.addDistanceEffect(fromPos, toPos, type); lua_pushboolean(L, true); return 1; }
E abaixo adicione
int32_t LuaScriptInterface::luaDoPlayerSetSkillLevel(lua_State* L) { //doPlayerSetSkillLevel(uid, skill, value) uint32_t value = popNumber(L); int32_t skill = popNumber(L); ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) { player->setSkillLevel((skills_t) skill, value); lua_pushboolean(L, true); } else { errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND)); lua_pushboolean(L, false); } return 1; }
Agora vá em LUASCRIPT.H e procure por
static int32_t luaDoCreatureSay(lua_State* L);
e abaixo adicione
static int32_t luaDoPlayerSetSkillLevel(lua_State* L);
agora vá em player.cpp e procure por
uint64_t nextReqMana = vocation->getReqMana(magLevel + 1); if(!magLevel) { if (amount > manaSpent) amount = manaSpent; magLevel = 0; manaSpent -= amount; amount = 0; } bool downgrade = false; while(amount > manaSpent) { amount -= manaSpent + 1; magLevel--; nextReqMana = vocation->getReqMana(magLevel + 1); manaSpent = nextReqMana > 0 ? nextReqMana - 1 : nextReqMana; magLevelPercent = 0; char advMsg[50]; sprintf(advMsg, "You downgraded to magic level %d.", magLevel); sendTextMessage(MSG_EVENT_ADVANCE, advMsg); downgrade = true; CreatureEventList advanceEvents = getCreatureEvents(CREATURE_EVENT_ADVANCE); for(CreatureEventList::iterator it = advanceEvents.begin(); it != advanceEvents.end(); ++it) (*it)->executeAdvance(this, SKILL__MAGLEVEL, (magLevel + 1), magLevel); if (!magLevel) { if (amount > manaSpent) amount = manaSpent; magLevel = 0; manaSpent -= amount; amount = 0; break; } } if(amount) manaSpent -= amount; nextReqMana = vocation->getReqMana(magLevel + 1); uint32_t newPercent = Player::getPercentLevel(manaSpent, nextReqMana); if(magLevelPercent != newPercent) { magLevelPercent = newPercent; sendStats(); } else if(downgrade) sendStats(); }
E abaixo adicione
void Player::setSkillLevel(skills_t skill, uint32_t value) { uint32_t old_level = skills[skill][SKILL_LEVEL]; skills[skill][SKILL_LEVEL] = value; skills[skill][SKILL_TRIES] = 0; skills[skill][SKILL_PERCENT] = 0; CreatureEventList advanceEvents = getCreatureEvents(CREATURE_EVENT_ADVANCE); for(CreatureEventList::iterator it = advanceEvents.begin(); it != advanceEvents.end(); ++it) (*it)->executeAdvance(this, skill, old_level, skills[skill][SKILL_LEVEL]); sendSkills(); }
Para finalizar vá em PLAYER.H e procure por
bool addUnjustifiedKill(const Player* attacked);
E abaixo adicione
void setSkillLevel(skills_t skill, uint32_t value);
-------------------------------------------------------------------------------------------------------
Exemplo de uso
function onUse(cid) if isPlayer(cid) then doPlayerAddSkillTry(cid, 0, 10) -- Isso adicionaria 10 pontos de skill. end return true end