Ir para conteúdo
Entre para seguir isso  
drakylucas

Sistemas de Reinos - V 1.0 29/03/2013 -

Recommended Posts

drakylucas    1
drakylucas

Permito a publicação em outros fórums, contanto que coloquem meus créditos em um tamanho de fonte grande (algo como 30 basta) - Original X_Tibia

 

 

Créditos:

 

 

Draky Lucas -- Desenvolvimento completo do sistema

Xampy -- Parte de retirar Frag (copiado do Guild War System 0.3.6 e modificado por mim)

LuckOake / Slicer -- Ajudas ao tirar dúvidas na seção de pedidos/duvidas de scripting

 

 

 

 

 

 

 

 

Testado Com:

The Forgotten Server 0.4 rev 3884 - 8.60

 

 

 

 

 

 

O que é?

 

 

é um sistema de reinos, funciona mais ou menos como guild, com poucas diferenças.

as pessoas necessitam apenas digitar !reinos e terão todas instruções de como funciona o sistema.

 

 

 

 

 

 

 

 

Bugs:

Está sem promover pessoas (ou seja, patentes intermediarias estão inutilizaveis por enquanto)

 

 

outros? REPORTE aqui no tópico!

 

 

 

 

 

 

 

 

Comandos:

 

 

!reinos

!reinos creditos - NAO ALTERAR

!reinos criar,Nome do Reino

!reinos invitar,Nome do Player

!reinos recusar

!reinos aceitar

!reinos membros

!reinos sair

!reinos expulsar,Nome do Player

 

 

 

 

 

 

 

 

 

 

Instalação

Na pasta Mods do servidor, adicione um arquivo chamado reinos.xml contendo isso:

 

 

<!--?xml version="1.0" encoding="iso-8859-1"?-->
<mod name="Reinos" version="1.0" author="Draky Lucas" contact="******************.com" enabled="yes">


   <config name="configuracao"><!--[CDATA[

   ------------------- CONFIGURE AQUI ---------------------
   storages = {
   invitation = 24545,
   }

   patentes = {
   [1] = {nivel = "Membro"},
   [2] = {nivel = "Vice lider"},   -- V1 -- AINDA INUTILIZAVEL
   [3] = {nivel = "Lider"},
   }

   patenteMinima = 2 -- patente minima para poder convidar/expulsar membros ao reino
   reinoSeAtaca = false -- Membros do mesmo reino podem se atacar?
   reinoMataOutrosReinos = true ---- True = reinos podem matar pessoas de outros reinos sem ganhar frag // False = Pode até mata, mas ganha frag normal  
   pz = true -- tem que estar sem battle pra sair/aceitar convites?    true = sim, false = nao
   anunciarSistema = true -- anunciar o sistema? (a cada meia hora, porem é só aumentar/diminuir o interval no final do script.. PS: interval baseado no TFS 0.4 Rev 3884 (1000 = 1 segundo)
  ------------------- A PARTIR DAQUI, NAO MEXA EM MAIS NADA --------------------
   -----
           function setReino(guid,id,nivel) -- nivel 1 = member, 2 = vice leader, 3 = dono
              return db.executeQuery("UPDATE `players` SET reino = " .. id .. ", nivelreino = ".. nivel .." where id = ".. guid ..";")
           end
   -----    

    -----
           function getReino(guid) -- retorna tabela com reino e nivel do reino da pessoa
                    local qr = db.getResult("SELECT `reino`,`nivelreino` FROM `players` WHERE `id`= ".. guid ..";")
                    reinoid = qr:getDataInt("reino")
                    nivelreino = qr:getDataInt("nivelreino")                    
                    return {reino = reinoid, nivel = nivelreino}
           end  
    -----
    -----
          function getNameReino(id)
                   if id == 0 then
                      return "Sem Reino"
                   end
                    local qr = db.getResult("SELECT `name` FROM `reinos` WHERE `id`= ".. id ..";")
                    name = qr:getDataString("name")                    
                    return name
          end
     -----
    -----
          function getMembersReino(id)
                   local result = db.getResult('SELECT `name`, `nivelreino` FROM `players` WHERE `reino`='..id..' ORDER BY `nivelreino` DESC;')
                   local table = {}
                   local i = 1
                   while TRUE do
                       table[i] = {result:getDataString("name"), patentes[result:getDataInt("nivelreino")].nivel}
                       if not(result:next()) then
                           break
                       end
                       i = i + 1
                   end
                   return table
          end
     -----

          function getIdReino(name)
                    local qr = db.getResult("SELECT `id` FROM `reinos` WHERE `name`= '".. name .."';")
                    if qr:getID() == -1 then return -1 end
                    return qr:getDataInt("id")
          end

    -----      
           function installReinos()
                    if db.executeQuery("ALTER TABLE `players` ADD reino INT(4) NOT NULL DEFAULT 0;") and db.executeQuery("ALTER TABLE `players` ADD nivelreino INT(4) NOT NULL DEFAULT 0;") and db.executeQuery("CREATE TABLE `reinos` (`id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `ownerid` INT NOT NULL, PRIMARY KEY (`id`), UNIQUE (`name`) ) ENGINE = InnoDB;") then
                       print("O Banco de dados foi criado com sucesso! [by Draky Lucas]")
                       print("O Sistema ja pode ser utilizado!")
                    return TRUE
                    end
               print("[Reinos - Draky Lucas] Não foi possível instalar o Sistema. Algum erro ocorreu no banco de dados")
               return FALSE
           end
    -----    

    -----
    function getInvitation(cid)
         local invites = getPlayerStorageValue(cid,storages.invitation)
         if invites == -1 or invites == nil then
            return -1
         end
         return {reino = string.match(invites, "{reino = (.-),"),nivel = string.match(invites, "nivel = (.-)}")} --tabela com reino e nivel
    end
    -----
    -----
          function invitar(cid,name,reinoid,reinonivel)
             if getReino(getPlayerGUID(cid)).reino <= 0 then      
                return "Você não pertence a reino algum!"
             end
             if getReino(getPlayerGUID(cid)).nivel < patenteMinima then
                 return "Você precisa ser ao menos ".. patentes[patenteMinima].." para poder convidar pessoas!"
             end
             if not isPlayer(getPlayerByNameWildcard(name)) then
                return "ERROR:\nDigite o nome do jogador corretamente!\nEle tem que estar online\n\nDigite !reinos invitar, nick do player!\nexemplo:\n!reinos invitar,Draky Lucas"
             end

             if getReino(getPlayerGUID(getPlayerByNameWildcard(name))).reino ~= 0 then
                return "O jogador "..name.." ja esta em outro reino! \nDesculpe"
             end
             if type(getInvitation(getPlayerByNameWildcard(name))) == "number" then
                setPlayerStorageValue(getPlayerByNameWildcard(name), storages.invitation, "{reino = " ..reinoid..", nivel = "..reinonivel.."}")  
                doShowTextDialog(getPlayerByNameWildcard(name),1976,"O Reino " ..getNameReino(reinoid).." quer que voce se torne " .. patentes[reinonivel].nivel .. "\n\nDigite \"!reinos aceitar\" para entrar no reino, \"!reinos recusar\" para recusar o convite!")
                doPlayerSendTextMessage(getPlayerByNameWildcard(name),19,"O Reino " ..getNameReino(reinoid).." quer que voce se torne " .. patentes[reinonivel].nivel)
                doPlayerSendTextMessage(getPlayerByNameWildcard(name),19,"Digite \"!reinos aceitar\" para entrar no reino, \"!reinos recusar\" para recusar o convite!")                
                return "Voce acabou de invitar o jogador "..name.." para o seu reino!"            
             else
                return "O jogador "..name.." ja foi convidado para outro reino! Desculpe"
             end
          return true
          end
    -----

    -----
          function expulsar(cid,name)
             if getReino(getPlayerGUID(cid)).reino <= 0 then      
                return "Você não pertence a reino algum!"
             end
             if not isPlayer(getPlayerByNameWildcard(name)) then
                return "ERROR:\nDigite o nome do jogador corretamente!\nEle tem que estar online\n\nDigite !reinos expulsar, nick do player!\nexemplo:\n!reinos expulsar,Draky Lucas"
             end

             if getReino(getPlayerGUID(cid)).nivel <= getReino(getPlayerByNameWildcard(name)).nivel then
                 return "Você precisa ser ao menos uma patente maior que a pessoa na qual voce deseja expulsar do reino!"
             end

             if getReino(getPlayerGUID(getPlayerByNameWildcard(name))).reino ~= 0 and getReino(getPlayerGUID(getPlayerByNameWildcard(name))).reino == getReino(getPlayerGUID(cid)).reino then
                doShowTextDialog(getPlayerByNameWildcard(name),1976,"O Jogador " .. getCreatureName(cid) .. " lhe expulsou do reino "..getNameReino(getReino(getPlayerGUID(cid)).reino).."!")
                doPlayerSendTextMessage(getPlayerByNameWildcard(name),19,"O Jogador " .. getCreatureName(cid) .. " lhe expulsou do reino "..getNameReino(getReino(getPlayerGUID(cid)).reino).."!")          
                setReino(getPlayerGUIDByName(name),0,0)
                return "Voce acabou de expulsar o jogador "..name.." do seu reino!"            
             else
                return "O jogador "..name.." não é do seu reino!"
             end
          return true
          end
    -----
    -----
         function recuseInvitation(cid)
                  local invites = getInvitation(cid)

                  if getReino(getPlayerGUID(cid)).reino ~= 0 then      
                     return "Você ja pertence a algum reino!\n\nCaso queira sair, digite:\n!reinos sair"
                  end        

                  if type(invites) == "number" then
                     return "Nenhum reino te invitou até agora!"
                  end

                  setPlayerStorageValue(cid, storages.invitation, -1)  
                  return "Voce recusou o convite do reino " .. getNameReino(invites.reino) .. "! Agora você pode ser convidado para outros reinos!"  
         end
   -----
   -----
         function acceptInvitation(cid)
                  local invites = getInvitation(cid)
                  if type(invites) == "number" then
                     return "Nenhum reino te invitou até agora!"
                  end

                  if pz == true and getCreatureCondition(cid, CONDITION_INFIGHT) == true then
                     return "Voce nao pode aceitar convites em quanto estiver em battle!"
                  end
                  setReino(getPlayerGUID(cid),tonumber(invites.reino),tonumber(invites.nivel))                    
                  setPlayerStorageValue(cid, storages.invitation, -1)
                  return "Voce entrou no reino " .. getNameReino(tonumber(invites.reino)) .. "!"
         end  
    -----    
    -----
         function sairReino(cid)
                  if getReino(getPlayerGUID(cid)).reino <= 0 then
                     return "Voce nao esta em nenhum reino!"
                  end

                  if pz == true and getCreatureCondition(cid, CONDITION_INFIGHT) == true then
                     return "Voce nao pode aceitar convites em quanto estiver em battle!"
                  end

                  setReino(getPlayerGUID(cid),0,0)  
             return "Voce acaba de deixar o reino!"
         end  
    -----    
    -----
         function criarReino(ownerName, nomeReino)
                  if getReino(getPlayerGUIDByName(ownerName)).reino --> 0 then
                     return "Voce ja esta em um reino. Deixe-o para criar o seu!"
                  end                   if pz == true and getCreatureCondition(getPlayerByNameWildcard(ownerName), CONDITION_INFIGHT) == true then
                     return "Voce nao pode aceitar convites em quanto estiver em battle!"
                  end                  

                  if getIdReino(nomeReino) > 0 then
                     return "Um reino com esse nome ja existe!\n\nTente outro nome!"
                  end


                  db.executeQuery("INSERT INTO reinos(name,ownerid) VALUES ('"..nomeReino.."',".. getPlayerGUIDByName(ownerName)..");")
                  setReino(getPlayerGUIDByName(ownerName),getIdReino(nomeReino),#patentes) -- #pattentes vai retornar quantas patentes tem, logo a ultima, se for 1 por 1, será a maior
                  doPlayerSendTextMessage(getPlayerByNameWildcard(ownerName),22,"Voce criou o reino ".. nomeReino.. "!")
                  doPlayerSendTextMessage(getPlayerByNameWildcard(ownerName),22,"Digite \"!reinos invitar,NOME\" para convidar o NOME para o seu reino!")  
                  return "Voce criou o reino ".. nomeReino.. "!\n\nDigite \"!reinos invitar,NOME\" para convidar o NOME para o seu reino!"
         end  
    -----
    -----
         function excluirReino(ID)
                  db.executeQuery("UPDATE `players` SET reino = 0, nivelreino = 0 where reino = ".. ID ..";")
                  db.executeQuery("DELETE from `reinos` where id = ".. ID ..";")
                  db.executeQuery("DELETE from `player_storage` where value like '{reino = ".. ID ..",%';")
             return true
         end  
    -----  
]=]=></config>




<event type="login" name="registerEvents" event="buffer"><!--[CDATA[
 domodlib('configuracao')
 -- function onLogin(cid)
 if reinoSeAtaca == false then
    registerCreatureEvent(cid,"naoAtacarProprioReino")
 end
 if reinoMataOutrosReinos == true then
    registerCreatureEvent(cid,"reinoMataOutrosReinos")
 end
       registerCreatureEvent(cid,"lookReino")




 -- return true
       -- end
]]--></event>
  <talkaction words="!reinos" event="buffer"><!--[CDATA[
 -- cid,word,param
 domodlib('configuracao')
---------------------------------
      if param == "instalar" and getPlayerGroupId(cid) --> 4 then
               doPlayerSendTextMessage(cid,19,"Veja no console se o sistema foi instalado!")
               return installReinos()
            end
---------------------------------            
 local reinos = getReino(getPlayerGUID(cid))
 local invites = getInvitation(cid)
 local string = ""
---------------------------------
--
       if param == "creditos" then
          doShowTextDialog(cid, 1976,"Draky Lucas - ******************\n\nEnjoy it!")
          return true
       end
--]]
 if param == "" or param == nil or param == false then




    if type(invites) == "number" and reinos.reino == 0 then
       string = "Voce nao pertence a nenhum reino e ainda nao foi convidado para pertencer a algum!\n\nDigite \"!reinos criar,NOME\" para criar um reino!"        
    end

    if type(invites) == "table" then

       string = string .. "Voce foi invitado para ser " .. patentes[tonumber(invites.nivel)].nivel .. " do reino " .. getNameReino(tonumber(invites.reino)) .."!\n"
       string = string .. "Digite uma das opções:\n"
       string = string .. "!reinos aceitar\n"
       string = string .. "!reinos recusar\n"      
    end

    if reinos.reino > 0 then
    string = string .. "Voce é ".. patentes[reinos.nivel].nivel .." do reino " .. getNameReino(reinos.reino) .."!\n"
    string = string .. "Digite uma das opções:\n"
       string = string .. "!reinos membros\n"
    string = string .. "!reinos sair\n"
    end
    if reinos.reino > 0 and reinos.nivel >= patenteMinima then
       string = string .. "!reinos invitar,NOME\n"
             string = string .. "!reinos expulsar,NOME\n"
    end

    if reinos.nivel == #patentes then
       string = string .. "\n----\nAtenção: Sendo a mais alta patente, ao sair do reino, ele será desfeito!\n----"
    end

    return doShowTextDialog(cid, 1976, string)
        end
---------------------------------
---------------------------------------------        
        if param == "membros" then
           if reinos.reino == 0 then
              string = string .. "Você não pertence a reino algum!"
           else
               local table = getMembersReino(reinos.reino)
               string = string .. "Membros do reino " .. getNameReino(reinos.reino) ..":\n"
               for i = 1,#table do
                  string = string .. table[i][1] .. " - " .. table[i][2] .. "\n"
               end
           end
           return doShowTextDialog(cid, 1976, string)

        end
----------------------------------------------    
---------------------------------------------        
        if param == "sair" then
              if reinos.nivel == #patentes then -- se tiver patente maxima
                 excluirReino(reinos.reino)
                 doShowTextDialog(cid, 1976, "Seu reino foi desfeito!")                        
                 return true
              end
                string = sairReino(cid)
                return doShowTextDialog(cid, 1976, string)                  

        end---------------------------------------------    
---------------------------------------------        
        if param == "recusar" then
           string = recuseInvitation(cid)
           return doShowTextDialog(cid, 1976, string)          
        end---------------------------------------------  
        if param == "aceitar" then
        string = acceptInvitation(cid)
        return doShowTextDialog(cid, 1976, string)
        end---------------------------------------------
       local t = string.explode(param, ",")
        if t[1] == "invitar" then
           if not t[2] then
               return doShowTextDialog(cid, 1976, "Digite !reinos invitar, nick do player!\nexemplo:\n!reinos invitar,Draky Lucas")
           end
           string = invitar(cid,t[2],reinos.reino,1)
           return doShowTextDialog(cid, 1976,string)
        end


        if t[1] == "criar" then
           if not t[2] then
               return doShowTextDialog(cid, 1976, "Digite !reinos criar, Nome do Reino!\nexemplo:\n!reinos criar,Imperio Draky")
           end
            recuseInvitation(cid)
            string = criarReino(getCreatureName(cid), tostring(t[2]))
            return doShowTextDialog(cid, 1976,string)  
        end

        if t[1] == "expulsar" then
           if not t[2] then
               return doShowTextDialog(cid, 1976, "Digite !reinos expulsar,NOME!\nexemplo:\n!reinos expulsar,Draky Lucas")
           end
            string = expulsar(cid,t[2])
            return doShowTextDialog(cid, 1976,string)  
        end
----------------------------------------------
------------------------ CONTEM PARTES EM CREATURESCRIPTS --------------------
]=]=></talkaction>




<globalevent name="anunciarReinos" interval="1800000" event="script"><!--[CDATA[
domodlib('configuracao')
if anunciarSistema == true then
  return doBroadcastMessage("O Servidor conta com um sistema de reinos! digite !reinos e saiba a respeito!")
end
return true
]]--></globalevent>
</mod>

 

 

 

 

Agora, na pasta data/creaturescripts/scripts crie uma pasta chamada reinos e nela crie três arquivos: look.lua naoAtacarProprioReino.lua reinoMataOutrosReinos.lua

 

 

no look.lua coloque isso:

    -----
           function getReino(guid) -- retorna tabela com reino e nivel do reino da pessoa
                    local qr = db.getResult("SELECT `reino`,`nivelreino` FROM `players` WHERE `id`= ".. guid ..";")
                    reinoid = qr:getDataInt("reino")
                    nivelreino = qr:getDataInt("nivelreino")                    
                    return {reino = reinoid, nivel = nivelreino}
           end  
    -----
    -----
          function getNameReino(id)
                   if id == 0 then
                      return "Sem Reino"
                   end
                    local qr = db.getResult("SELECT `name` FROM `reinos` WHERE `id`= ".. id ..";")
                    name = qr:getDataString("name")                    
                    return name
          end
     -----
[size=5][size=3]function onLook(cid, thing, position, lookDistance)
   if isPlayer(thing.uid) and thing.uid ~= cid then
       doPlayerSetSpecialDescription(thing.uid,' [Reino: '..getNameReino(getReino(getPlayerGUID(thing.uid)).reino)..']')
       return true
   elseif thing.uid == cid then
       doPlayerSetSpecialDescription(cid,' [Reino: '..getNameReino(getReino(getPlayerGUID(cid)).reino)..']')
       local string = 'You see yourself.'
       if getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION) then
           string = string..' You are '.. getPlayerGroupName(cid) ..'.'
       elseif getPlayerVocation(cid) ~= 0 then
           string = string..' You are '.. getPlayerVocationName(cid) ..'.'
       else
           string = string..' You have no vocation.'
       end


       if getPlayerNameByGUID(getPlayerPartner(cid), false, false) ~= nil then
           string = string..' You are '.. (getPlayerSex(cid) == 0 and 'wife' or 'husband') ..' of '.. getPlayerNameByGUID(getPlayerPartner(cid)) ..'.'
       end


       if getPlayerGuildId(cid) > 0 then
           string = string..' You are ' .. (getPlayerGuildRank(cid) == '' and 'a member' or getPlayerGuildRank(cid)) ..' of the '.. getPlayerGuildName(cid)
           string = getPlayerGuildNick(cid) ~= '' and string..' ('.. getPlayerGuildNick(cid) ..').' or string..'.'
       end


       if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then
           string = string..'\nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..'], Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].'
           string = string..'\nIP: '.. doConvertIntegerToIp(getPlayerIp(cid)) ..'.'
       end


       if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION) then
           string = string..'\nPosition: {x='.. position.x..',y='.. position.y..'z='.. position.z..'}'
       end
       string = string..getPlayerSpecialDescription(cid)..''
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)
       return false
   end
   return true
end
[/size][/size]

 

 

no naoAtacarProprioReino.lua coloque isso:

           function getReino(guid) -- retorna tabela com reino e nivel do reino da pessoa
                    local qr = db.getResult("SELECT `reino`,`nivelreino` FROM `players` WHERE `id`= ".. guid ..";")
                    reinoid = qr:getDataInt("reino")
                    nivelreino = qr:getDataInt("nivelreino")                    
                    return {reino = reinoid, nivel = nivelreino}
           end
[size=5][size=3]function onCombat(cid, target)
   if not isPlayer(target) then return true end
if (getReino(getPlayerGUID(cid)).reino == getReino(getPlayerGUID(target)).reino) and getReino(getPlayerGUID(cid)).reino > 0 then
doPlayerSendCancel(cid, "Voce nao pode atacar players da mesma guild.")
           return FALSE
   end
return true
end
[/size][/size]

 

 

No reinoMataOutrosReinos.lua (creditos 90% Xampy)coloque isso:

function getReino(guid) -- retorna tabela com reino e nivel do reino da pessoa
      local qr = db.getResult("SELECT `reino`,`nivelreino` FROM `players` WHERE `id`= ".. guid ..";")
      reinoid = qr:getDataInt("reino")
      nivelreino = qr:getDataInt("nivelreino")                    
      return {reino = reinoid, nivel = nivelreino}
end
[size=5][size=3]function onKill(cid, target, lastHit)
local PZ = createConditionObject(CONDITION_INFIGHT)
setConditionParam(PZ, CONDITION_PARAM_TICKS, getConfigInfo('whiteSkullTime'))[/size][/size][size=5][size=3]        if isPlayer(cid) == TRUE and isPlayer(target) == TRUE then
       local GUID = getPlayerGUID(cid)
       local namec = getPlayerName(cid)
       local namet = getPlayerName(target)
       local skull = getCreatureSkullType(cid)
       local skullend = getPlayerSkullEnd(cid)
       local playerPos = getPlayerPosition(cid)
       local targetPos = getPlayerPosition(target)
       local cidd = cid    [/size][/size]
[size=5][size=3]        local timeA = os.time()
       local timesA = {today = (timeA - 86400), week = (timeA - (7 * 86400))}[/size][/size][size=5][size=3]        local contentsA, resultA = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. getPlayerGUID(cid) .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (timeA - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
       if(resultA:getID() ~= -1) then
               repeat
                       local contentA = {
                               name = resultA:getDataString("name"),
                               level = resultA:getDataInt("level"),
                               date = resultA:getDataInt("date")
                       }
                       if(contentA.date > timesA.today) then
                               table.insert(contentsA.day, contentA)
                       elseif(contentA.date > timesA.week) then
                               table.insert(contentsA.week, contentA)
                       else
                               table.insert(contentsA.month, contentA)
                       end
               until not resultA:next()
               resultA:free()
       end[/size][/size]
[size=5][size=3]        local sizeA = {
               day = table.maxn(contentsA.day),
               week = table.maxn(contentsA.week),
               month = table.maxn(contentsA.month)
       }
local function removeFrag(cid)[/size][/size][size=5][size=3]        local timeB = os.time()
       local timesB = {today = (timeB - 86400), week = (timeB - (7 * 86400))}[/size][/size]
[size=5][size=3]        local contentsB, resultB = {day = {}, week = {}, month = {}}, db.getResult("SELECT `pd`.`date`, `pd`.`level`, `p`.`name` FROM `player_killers` pk LEFT JOIN `killers` k ON `pk`.`kill_id` = `k`.`id` LEFT JOIN `player_deaths` pd ON `k`.`death_id` = `pd`.`id` LEFT JOIN `players` p ON `pd`.`player_id` = `p`.`id` WHERE `pk`.`player_id` = " .. GUID .. " AND `k`.`unjustified` = 1 AND `pd`.`date` >= " .. (timeB - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
       if(resultB:getID() ~= -1) then
               repeat
                       local contentB = {
                               name = resultB:getDataString("name"),
                               level = resultB:getDataInt("level"),
                               date = resultB:getDataInt("date")
                       }
                       if(contentB.date > timesB.today) then
                               table.insert(contentsB.day, contentB)
                       elseif(contentB.date > timesB.week) then
                               table.insert(contentsB.week, contentB)
                       else
                               table.insert(contentsB.month, contentB)
                       end
               until not resultB:next()
               resultB:free()
       end[/size][/size][size=5][size=3]        local sizeB = {
               day = table.maxn(contentsB.day),
               week = table.maxn(contentsB.week),
               month = table.maxn(contentsB.month)
       }[/size][/size]


[size=5][size=3]if sizeB.day > sizeA.day or sizeB.week > sizeA.week or sizeB.month > sizeA.month then
       db.executeQuery("UPDATE `killers` SET `unjustified` = 0 WHERE `id` IN (SELECT `kill_id` FROM `player_killers` WHERE `player_id` = "..GUID..") ORDER BY `death_id` DESC LIMIT 1;")
       doPlayerSendTextMessage(cidd, 21, "O Frag do player "..namet.." não foi contado!")
end[/size][/size][size=5][size=3]if skull == SKULL_RED then
       if getCreatureSkullType(cidd) == SKULL_BLACK then
               doPlayerSetSkullEnd(cidd, skullend, SKULL_RED)
               doCreatureSetSkullType(cidd, SKULL_RED)
       end
elseif skull == SKULL_WHITE then
       if getCreatureSkullType(cidd) == SKULL_RED then
               doPlayerSetSkullEnd(cidd, timeB, SKULL_RED)
               doCreatureSetSkullType(cidd, SKULL_WHITE)
       end
end[/size][/size]
[size=5][size=3]end -- removefrag[/size][/size][size=5][size=3]                local myReino = getReino(getPlayerGUID(cid)).reino
               local enemyReino = getReino(getPlayerGUID(target)).reino[/size][/size]
[size=5][size=3]                if myReino ~= 0 and enemyReino ~= 0 then
               doAddCondition(cid, PZ)
               addEvent(removeFrag, 150)  -- pra comparar o posterior com o anterior
               end
       end   -- if isPlayer...
       return TRUE
end
[/size][/size]

 

 

Agora em data/creaturescripts abra o creaturescripts.xml e adicione:

<event type="look" name="lookReino" event="script" value="reinos/look.lua">
<event type="kill" name="reinoMataOutrosReinos" event="script" value="reinos/ReinoMataOutrosReinos.lua">
<event type="combat" name="naoAtacarProprioReino" event="script" value="reinos/naoAtacarProprioReino.lua">

 

 

 

 

Agora, abra o servidor (reload não funcionará), entre com um char de groupId acima de 5 e digite !reinos instalar APENAS UMA VEZ!

 

 

PS: Os creaturescripts estão fora do MOD pois estive tendo problemas com return false no MOD.

Confirme no console se o sistema instalou-se corretamente!

 

 

Enjoy it!

 

Edit: Não sei o porque mas o fórum está dividindo todos arquivos em 2 partes, uma pras funções e outra pro codigo, mas enfim, é só juntar os dois (seguindo a ordem, só colocar no mesmo arquivo um embaixo do outro)

thx

Editado por drakylucas
arrumar os [CODES]

Compartilhar este post


Link para o post
iuniX    4
iuniX

Nossa, ficou realmente muito organizado e bonito. Não consegui testar direito, mas pelo que eu li está correto (foi fácil entender como funciona, ótima organização).

 

Obrigado pela contribuição. Movido.

Compartilhar este post


Link para o post
Eventide    7
Eventide

gostei muito da ideia do sistema, infelizmente não estou em casa e não vou poder conferir, mas assim que chegar vou fazer isso, vai ter muita utilidade em uma ideia minha...

Compartilhar este post


Link para o post
Empty Flask    0
Empty Flask

[14:32:14.098] > Loading reinos.xml...[Error - LuaInterface::loadBuffer] [string

"LuaInterface::loadBuffer"]:6: 'then' expected near '='

[14:32:14.098] [Error - Event::checkBuffer] Cannot load buffer (

[14:32:14.099] domodlib('config')

[14:32:14.099]

 

[14:32:14.100] if param == "instalar" and getPlayerGroupId(cid) => 4 then

 

[14:32:14.100] doPlayerSendTextMessage(cid,19,"Veja no console s

e o sistema foi instalado!")

[14:32:14.101] return installReinos()

[14:32:14.101] end

[14:32:14.101]

[14:32:14.103] local reinos = getReino(getPlayerGUID(cid))

 

 

 

estou a obter este erro, mudei o nome do config para "config" e retirei alguns erros do codigo, o seu copy paste tem muitos --- em sitios errados.

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×