Ir para conteúdo
  • Cadastre-se

CreatureScript Como configurar StartSkills - TFS 0.4 dev 3777


Posts Recomendados

Amigos, boa noite.

 

Ando com um problema que esta me impedindo de colocar meu enforced online. Ja tentei de tudo, e estou ficando desanimado :/

Creio que o problema seja simples: Nao consigo configurar as Skills iniciais!

Por mais que eu coloque as skills que eu quero no startskill.lua, os players nascem bugados.

 

Meu tfs é o 0.4 dev 3777 8.6, e eu uso SQL, por acc/manager simples.

 

Segue aqui minha startskill.lua:

 

function onLogin(cid)

local playerVoc = getPlayerVocation(cid)

local reqTries = getPlayerRequiredSkillTries

local skillStor = 56364

local gotSkills = getPlayerStorageValue(cid, 56364)

 
 

if playerVoc == 1 and gotSkills == -1 then

doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid,70)))

setPlayerStorageValue(cid, skillStor, 1)

 

elseif playerVoc == 2 and gotSkills == -1 then

doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid,70)))

setPlayerStorageValue(cid, skillStor, 1)

 

elseif playerVoc == 3 and gotSkills == -1 then

doPlayerAddSkillTry(cid, SKILL_DISTANCE, reqTries(cid, SKILL_DISTANCE, 75))

doPlayerAddSkillTry(cid, SKILL_SHIELD, reqTries(cid, SKILL_SHIELD, 70))

doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid,20)))

setPlayerStorageValue(cid, skillStor, 1)

 

elseif playerVoc == 4 and gotSkills == -1 then

doPlayerAddSkillTry(cid, SKILL_AXE, reqTries(cid, SKILL_AXE, 80))

doPlayerAddSkillTry(cid, SKILL_SWORD, reqTries(cid, SKILL_SWORD, 80))

doPlayerAddSkillTry(cid, SKILL_CLUB, reqTries(cid, SKILL_CLUB, 80))

doPlayerAddSkillTry(cid, SKILL_SHIELD, reqTries(cid, SKILL_SHIELD, 70))

doPlayerAddMagLevel(cid, 9)

setPlayerStorageValue(cid, skillStor, 1)

 

end

return TRUE

end

 

Por favor, me ajudem!

Valeu

Link para o post
Compartilhar em outros sites
  • 2 weeks later...

Este tópico foi movido para a área correta. Esta é uma mensagem automática!
Pedimos que leia as regras do fórum!

Spoiler

This topic has been moved to the correct area. This is an automated message!
Please read the forum rules.

 

ichigo.gif
https://github.com/Cjaker/

  , _ ,
 ( o o )
/'` ' `'\                     ESTOU TE OBSERVANDO O_O
|'''''''|
|\\'''//|
   """

 

Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.


  • Conteúdo Similar

    • Por Imperius
      O propósito é criar uma nova função em creaturescripts que será acionada toda vez que um novo report (CTRL + R) for aberto.
       
      Eu implementei para enviar uma notificação no grupo do Telegram, contendo os dados do report.
       
      Isso garantirá que os GMs tenham acesso aos reports dos jogadores mesmo quando não estiverem logados, e também evitará que algum report seja perdido caso o jogador saia do servidor.
      A parte do Telegram é apenas um exemplo. Você pode ajustar o script para executar outras ações desejadas.
       
      creatureevent.cpp:
      Dentro deste arquivo, localize a função:
       
      uint32_t CreatureEvent::executeChannelLeave(Player* player, uint16_t channelId, UsersMap usersMap)  
      abaixo dela, adicione:
       
      uint32_t CreatureEvent::executeOpenRuleViolation(Player* player, std::string message) { if (!m_interface->reserveEnv()) { std::clog << "[Error - CreatureEvent::executeOpenRuleViolation] Call stack overflow." << std::endl; return 0; } ScriptEnviroment* env = m_interface->getEnv(); env->setScriptId(m_scriptId, m_interface); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(player)); lua_pushstring(L, message.c_str()); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; }  
      Após, procure por:
       
      std::string CreatureEvent::getScriptEventName() const  
      abaixo de:
       
      case CREATURE_EVENT_CHANNEL_LEAVE: return "onLeaveChannel";  
      adicione:
       
      case CREATURE_EVENT_OPEN_RULE_VIOLATION: return "onOpenRuleViolation";  
      Agora, procure por:
       
      std::string CreatureEvent::getScriptEventParams() const  
      abaixo de:
       
      case CREATURE_EVENT_CHANNEL_LEAVE: return "cid, channel, users";  
      adicione:
       
      case CREATURE_EVENT_OPEN_RULE_VIOLATION: return "cid, message";  
      Procure por:
       
      bool CreatureEvent::configureEvent(xmlNodePtr p)  
      abaixo de:
       
      else if(tmpStr == "leavechannel") m_type = CREATURE_EVENT_CHANNEL_LEAVE;  
      adicione:
       
      else if(tmpStr == "openruleviolation") m_type = CREATURE_EVENT_OPEN_RULE_VIOLATION;  
       
      creatureevent.h:
      Dentro deste arquivo, localize:
       
      enum CreatureEventType_t  
      adicione "CREATURE_EVENT_OPEN_RULE_VIOLATION" como o último item de enum CreatureEventType_t
       
      Exemplo:
       
      enum CreatureEventType_t { // ... CREATURE_EVENT_OPEN_RULE_VIOLATION };  
      Agora, procure por:
       
      uint32_t executeChannelLeave(Player* player, uint16_t channelId, UsersMap usersMap);  
      abaixo dela, adicione:
       
      uint32_t executeOpenRuleViolation(Player* player, std::string message);  
      game.cpp:
      Dentro deste arquivo, localize:
       
      bool Game::playerReportRuleViolation(Player* player, const std::string& text)  
      e substitua por:
       
      bool Game::playerReportRuleViolation(Player* player, const std::string& text) { //Do not allow reports on multiclones worlds since reports are name-based if(g_config.getNumber(ConfigManager::ALLOW_CLONES)) { player->sendTextMessage(MSG_INFO_DESCR, "Rule violation reports are disabled."); return false; } cancelRuleViolation(player); boost::shared_ptr<RuleViolation> rvr(new RuleViolation(player, text, time(NULL))); ruleViolations[player->getID()] = rvr; ChatChannel* channel = g_chat.getChannelById(CHANNEL_RVR); if(!channel) return false; for(UsersMap::const_iterator it = channel->getUsers().begin(); it != channel->getUsers().end(); ++it) it->second->sendToChannel(player, SPEAK_RVR_CHANNEL, text, CHANNEL_RVR, rvr->time); CreatureEventList joinEvents = player->getCreatureEvents(CREATURE_EVENT_OPEN_RULE_VIOLATION); for(CreatureEventList::iterator it = joinEvents.begin(); it != joinEvents.end(); ++it) (*it)->executeOpenRuleViolation(player, text); return true; }  
      Agora é só compilar a source.
       
      depois em "data > creaturescripts > creaturescripts.xml", adicione:
       
      <event type="login" name="loginNotifyRuleViolation" script="notifyRuleViolation.lua"/> <event type="openruleviolation" name="openNotifyRuleViolation" script="notifyRuleViolation.lua"/>  
      em "data > creaturescripts > scripts", crie um arquivo notifyRuleViolation.lua e adicione:
       
      function onOpenRuleViolation(cid, message) local config = { token = "", -- Token do seu BOT no Telegram chatId = "" -- ID do chat do Telegram que será enviado a notificação. } local message = "Player: "..getCreatureName(cid).."\n\nReport:\n"..message.."" message = string.gsub(message, "\n", "%%0A") local url = "https://api.telegram.org/bot"..config.token.."/sendMessage" local data = "chat_id="..config.chatId.."&text="..message.."" local curl = io.popen('curl -d "'..data..'" "'..url..'"'):read("*a") return true end function onLogin(cid) registerCreatureEvent(cid, "openNotifyRuleViolation") return true end  
       
      Demonstração:
      1. Jogador abre um novo report (CTRL + R)

      2. notifyRuleViolation.lua, definido em creaturescripts.xml, é acionado para enviar uma notificação ao grupo do Telegram.
       

       
    • Por Ghaz
      Fala pessoal tudo bem?
       
      Estou com dificuldades em um script e preciso da ajuda dos magos do LUA rs.
       
      Tenho um script que quando o player morre (onDeath), ele faz algumas coisas e depois ele chama uma função que deveria retornar uma table (array) para eu fazer o for com o ipairs certinho. Segue abaixo o código:
       
       
      Segue abaixo a função getPlayersInArea:
       
       
      Acontece que no código de cima (do primeiro spoiler) eu dou um print no retorno da função getPlayersInArea, porém ela não tá me retornando a table, tá me retornando só: 2
       
       
       
      Alguém consegue me ajudar em, como raios eu faço a função retornar a lista de players ao invés da quantidade? Acredito que ta retornando o count da table, e não os itens do array.
       
       
      Agradeço desde já, valeu tchurma!
    • Por FeeTads
      salve rapaziada, estou fazendo uma quest no meu OT que é necessário faze-la durante 10 dias consecutivos, porém caso o player perca um dia, a storage da quest reseta.
      Já tenho esses scripts prontos de 2 formas: global event que checa a storage de todos os player online no momento e caso ja tenha passado 24h ele tira a storage do player que está entre os 10 dias de quest.
      E também tenho um creatureScript de onLogin() que quando o player loga, ele entra num loop de verificação a cada 60s

      minha duvida: globalEvents vai checar todos os players online de uma só vez e fazer as alterações necessarias, isso pode lagar a distro, ou até mesmo crashar?
      o creatureScript vai entrar num loop até o player deslogar, isso numa média de 250 pessoa são diversas verificações em momentos diferentes, pode acabar lagando ou crashando?

      meu OT possui uma media de 300 pessoas online.

      Script globalEvents é esse:

      function onThink(interval, lastExecution)
          local players = {}
          local timer = os.time()
          for _, pid in pairs (getPlayersOnline()) do
              local storage = getPlayerStorageValue(pid, 1231234)
              if getPlayerStorageValue(pid,888251) > 0 and getPlayerStorageValue(pid,888251) <= 9 then
                  if storage - timer <= 1  then
                      table.insert(players, pid)
                  end
              end
          end
          
          if #players > 0 then
              for i = 1, #players do
                  doPlayerSendTextMessage(players[i],22,"seu dano voltou ao normal por vc nao ter feito a quest!")
                  setPlayerStorageValue(players[i],888251,0)
              end
          end
      return true
      end

      Script do Creature é esse:
      local storage = getPlayerStorageValue(cid,1231234)
              function checkStorage(cid) local timer = os.time()
                     if not isPlayer(cid) then return true end
                     if getPlayerStorageValue(cid,888251) > 0 and getPlayerStorageValue(cid, 888251) <= 9 then
                             if storage - timer <= 1 then
                                     setPlayerStorageValue(cid,888251,0)
                             end
                   end
                   addEvent(function()
                              checkStorage(cid)
                    end, 60000)
      end
      function onLogin(cid)
              checkStorage(cid)
      return true
      end
      function onLogout(cid)
             stopEvent(checkStorage[cid])
      return true
      end


      caso os códigos nao estejam legiveis me avisem como arrumar em .lua pf

      se quiserem usar os códigos podem usar a vontade kkkkkkk
    • Por thelifeofpbion
      Existem alguns scripts que depois de matar boss abri tp para os players entrarem em uma sala de recompensa, porém (não sei se já existe) vou postar 2 scripts:

      1º Script: Todos players que der algum dano no boss é teleportado
      2º Script: Depois que o Boss for derrotado todos players de uma sala são teleportados.
       
       

       
      É Basicamente isso, tava ajudando no suporte quando pediram isso e resolvi postar para ficar mais facil de achar (e depois pra eu achar também).

      Agradeço o vodkart por ter disponibilizado a parte do script onde seleciona todos players de uma area (retirei de algum post do forum),
      e Xagah que copiei descaradamente as imagens de tópico porque achei bonito  

      Ajudei de alguma Forma? REP+.


       
    • Por Bruno Minervino
      Fala galera,
       
      Um membro fez um pedido, e achei que deveria compartilhar com vocês, algo simples porém útil. Principalmente em OT's do estilo Baiak.
       
      O que o script faz ?
      Ele simplesmente manda um efeito para o Top Level caso ele estiver online.
       
      Instalação:

      Em data/creaturescripts/creaturescripts.xml adicione:
      <event type="login" name="TopEffect" event="script" value="topeffect.lua"/> <event type="advance" name="CheckTop" event="script" value="topeffect.lua"/> Agora crie um arquivo em data/creaturescripts/scripts com o nome topeffect.lua e adicione:
      --[[ Script by Bruno Minervino para o Tibia King Caso for postar, colocar os créditos ]] local config = { tempo = 10, --tempo em segundos mensagem = { texto = "[TOP]", --não use mais de 9 caracteres efeito = TEXTCOLOR_LIGHTBLUE --efeito para a função doSendAnimatedText }, efeito = 30, --efeito da função doSendMagicEffect globalstr = 5687 -- uma global storage qualquer q esteje vazia } --[[ Não mexa em nada abaixo ]] local topPlayer = getGlobalStorageValue(config.globalstr) > 0 and getGlobalStorageValue(config.globalstr) or 0 function onLogin(cid) local query = db.getResult("SELECT `id`, `name`, `level` FROM `players` WHERE `group_id` < 2 ORDER BY `level` DESC LIMIT 1") if (query:getID() ~= -1) then local pid = query:getDataString("id") local name = query:getDataString("name") if getPlayerName(cid) == name then if topPlayer ~= getPlayerID(cid) then topPlayer = getPlayerID(cid) end setGlobalStorageValue(config.globalstr, pid) TopEffect(cid) end end registerCreatureEvent(cid, "CheckTop") return true end function onAdvance(cid, skill, oldlevel, newlevel) if skill == 8 then local query = db.getResult("SELECT `id`, `name`, `level` FROM `players` WHERE `group_id` < 2 ORDER BY `level` DESC LIMIT 1") if (query:getID() ~= -1) then local level = tonumber(query:getDataString("level")) if level < newlevel and topPlayer ~= getPlayerID(cid) then doBroadcastMessage("O jogador " .. getPlayerName(cid) .. " tornou-se o novo Top Level. Parabens!", 22) topPlayer = getPlayerID(cid) doSaveServer() setGlobalStorageValue(config.globalstr, getPlayerID(cid)) TopEffect(cid) end end end return true end function TopEffect(cid) if not isPlayer(cid) then return true end if topPlayer == getPlayerID(cid) then doSendAnimatedText(getCreaturePosition(cid), config.mensagem.texto, config.mensagem.efeito) doSendMagicEffect(getCreaturePosition(cid), config.efeito) addEvent(TopEffect, config.tempo * 1000, cid) end end function getPlayerNameById(id) local query = db.getResult("SELECT `name` FROM `players` WHERE `id` = " .. db.escapeString(id)) if query:getID() ~= -1 then return query:getDataString("name") end return 0 end function getPlayerIdByName(name) local query = db.getResult("SELECT `id` FROM `players` WHERE `name` = " .. db.escapeString(name)) if query:getID() ~= -1 then return tonumber(query:getDataString("id")) end return 0 end function getPlayerID(cid) return getPlayerIdByName(getPlayerName(cid)) end  
      Espero ajudar!
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo