Postado Dezembro 27, 2014 10 anos Este é um post popular. Bom eu criei essas duas funções para usar no meu OT, elas forçam o uso do cooldown do sistema do tibia, você pode usa lo mesmo que não tenha executado nenhuma spell. por exemplo: player:addCooldown(87, 10000) sendo 87 o código da spell, ou seja a imagem que ira aparecer no cooldown, lembrando que estas imagens podem ser editadas no tibia.pic. E 10000 o tempo do cooldown, lembrando a cada 1000 equivale a 1 segundo. resultado: e a função get ele retorna true ou false, para caso o cooldown estiver sendo executado: player:getCooldown(87) Vamos la. em luascript.cpp procure por: registerMethod("Player", "getMoney", LuaScriptInterface::luaPlayerGetMoney); registerMethod("Player", "addMoney", LuaScriptInterface::luaPlayerAddMoney); registerMethod("Player", "removeMoney", LuaScriptInterface::luaPlayerRemoveMoney); e logo depois dessas linhas de códigos adicione: registerMethod("Player", "addCooldown", LuaScriptInterface::luaPlayerAddCooldown); registerMethod("Player", "getCooldown", LuaScriptInterface::luaPlayerGetCooldown); ainda em luascript.cpp procure por: int32_t LuaScriptInterface::luaPlayerRemoveMoney(lua_State* L) e após a ultima linha desta função adicione: int32_t LuaScriptInterface::luaPlayerAddCooldown(lua_State* L) { // player:addCooldown(spellid, cooldown) Player* player = getUserdata<Player>(L, 1); if (player) { uint8_t spellId = getNumber<uint8_t>(L, 2); uint32_t cooldown = getNumber<uint32_t>(L, 3); Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_SPELLCOOLDOWN, cooldown, 0, false, spellId); player->addCondition(condition); pushBoolean(L, true); } else { lua_pushnil(L); } return 1; } int32_t LuaScriptInterface::luaPlayerGetCooldown(lua_State* L) { // player:getCooldown(spellid) Player* player = getUserdata<Player>(L, 1); if (!player) { lua_pushnil(L); return 1; } uint32_t spellid = getNumber<uint32_t>(L, 2); if (player->hasCondition(CONDITION_SPELLCOOLDOWN, spellid)) { pushBoolean(L, true); } else { pushBoolean(L, false); } return 1; } agora em luascript.h procure por: static int32_t luaPlayerGetMoney(lua_State* L); static int32_t luaPlayerAddMoney(lua_State* L); static int32_t luaPlayerRemoveMoney(lua_State* L); e logo após estes código adicione: static int32_t luaPlayerAddCooldown(lua_State* L); static int32_t luaPlayerGetCooldown(lua_State* L); depois é só compilar e usar ! Editado Dezembro 27, 2014 10 anos por Gantz (veja o histórico de edições)
Postado Janeiro 20, 2015 10 anos Não tem necessidade de fazer nas sourcers. Dá pra criar uma função pra executar direto do lua, aí não precisa compilar. Só colocar no global.lua ou em alguma lib "function Player.addCooldown(self, spellid, cooldown) ... end" Acho menos trabalho!
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.