Ir para conteúdo
  • Cadastre-se

Posts Recomendados

olá Galera do TK, estou aqui para pedir uma ajuda em um script de Frags e Deaths que eu uso,
ele está contando totalmente errado os deaths, ele conta muito mais a cada 1 morte !!!

 

ele conta muito mais deaths, e se alguem puder olhar se os frags estão contando mt mais do que matou também e arrumar seria bom, para ficar certinho as Frags e as Deaths !!!

darei REP+ par todos qe ajudar 

 

@Xagah , @Sekk 

 

function getDeaths(cid)
   local query, d = db.getResult("SELECT `player_id` FROM `player_killers` WHERE `player_id` = " ..getPlayerGUID(cid)), 0
   if (query:getID() ~= -1) then
      repeat
         d = d+1
      until not query:next()
      query:free()
   end
   return d  
end

function getPlayerFrags(cid)
    local time = os.time()
    local times = {today = (time - 86400), week = (time - (7 * 86400))}
    local contents, result = {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` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
    if(result:getID() ~= -1) then
        repeat
            local content = {date = result:getDataInt("date")}
            if(content.date > times.today) then
                table.insert(contents.day, content)
            elseif(content.date > times.week) then
                table.insert(contents.week, content)
            else
                table.insert(contents.month, content)
            end
        until not result:next()
        result:free()
    end
 
    local size = {
        day = table.maxn(contents.day),
        week = table.maxn(contents.week),
        month = table.maxn(contents.month)
    }
    return size.day + size.week + size.month
end

function onLook(cid, thing, position, lookDistance)
   if isPlayer(thing.uid) and thing.uid ~= cid then
      return doPlayerSetSpecialDescription(thing.uid, '\n'.. '[Frags: ' .. getPlayerFrags(thing.uid) .. ' - Deaths: ' .. getDeaths(thing.uid) .. ']')
   elseif thing.uid == cid then     
      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 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
      
      string = string..'\n'.. '[Frags: ' .. getPlayerFrags(cid) .. ' - Deaths: ' .. getDeaths(cid) .. ']'

      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
      return false, doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)  
   end
   return 1
end

 

Link para o post
Compartilhar em outros sites
local function getDeaths(cid)
	local query, d = db.getResult("SELECT `player_id` FROM `player_killers` WHERE `player_id` = " ..getPlayerGUID(cid)), 0
	if (query:getID() ~= -1) then
		repeat
			d = d+1
		until not query:next()
		query:free()
	end
	return d  
end

local function getPlayerFrags(cid)
	local time = os.time()
	local times = {today = (time - 86400), week = (time - (7 * 86400))}
	local contents, result = {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 `k`.`war` = 0 AND `pd`.`date` >= " .. (time - (30 * 86400)) .. " ORDER BY `pd`.`date` DESC")
	if(result:getID() ~= -1) then
		repeat
			local content = {date = result:getDataInt("date")}
			if(content.date > times.today) then
				table.insert(contents.day, content)
			elseif(content.date > times.week) then
				table.insert(contents.week, content)
			else
				table.insert(contents.month, content)
			end
		until not result:next()
		result:free()
	end
	
	local size = {
		day = table.maxn(contents.day),
		week = table.maxn(contents.week),
		month = table.maxn(contents.month)
	}
	return size.day + size.week + size.month
end

function onLook(cid, thing, position, lookDistance)
	if isPlayer(thing.uid) and thing.uid ~= cid then
		return doPlayerSetSpecialDescription(thing.uid, '\n'.. '[Frags: ' .. getPlayerFrags(thing.uid) .. ' - Deaths: ' .. getDeaths(thing.uid) .. ']')
	elseif thing.uid == cid then     
		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 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

		string = string..'\n'.. '[Frags: ' .. getPlayerFrags(cid) .. ' - Deaths: ' .. getDeaths(cid) .. ']'
		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
		return false, doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)  
	end
	return 1
end

 

Editado por Fir3element (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

@up

@Fir3element , amigo meu sistema de frags e death que eu uso é aquele que mostra assim [Frags 1 - Death 1]

 

o problema que ele ta marcando errado, eu gostaria se tu pudesse só arrumar ele, pq os Frags ele conta até certo, Mais as Deaths ele conta errado !

 

ou, se tiver um sistema de Frags e Deaths,, tfs 0.4 pra me passar ficaria grato,

 

 

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

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 FeeTads
      SALVE rapaziada do TK, esses dias vim pensando em novos scripts pro meu OT, e em um deles eu precisava que determinada area não contasse frag pro player que matasse outros, PORÉM eu precisava que os players que morressem nessa area ainda assim tivessem as penalidades da sua morte, procurei por ai, achei alguns scripts que apenas tiravam o SKULL e não realmente o FRAG do player.

      **script atualizado 22/10/2023** - melhorado e otimizado, levei o script pra puxar as infos por .lua / creatureScripts

      vou disponibilizar o code aqui, e o que fazer pra determinada area não contar frag.

      SOURCE OTX 2 / TFS 0.x, Funciona em TFS 1.x mudando as tags e ajeitando as sintaxes.

      vá em creatureevent.cpp

      procure por:
      else if(type == "preparedeath") _type = CREATURE_EVENT_PREPAREDEATH;
      Adiciona abaixo:
      else if(type == "nocountfrag") _type = CREATURE_EVENT_NOCOUNTFRAG;

      procure por:
      case CREATURE_EVENT_PREPAREDEATH: return "onPrepareDeath";  
      Adicione abaixo: 
      case CREATURE_EVENT_NOCOUNTFRAG: return "noCountFragArea";

      procure por:
      case CREATURE_EVENT_PREPAREDEATH: return "cid, deathList";
      Adicione abaixo:
      case CREATURE_EVENT_NOCOUNTFRAG: return "cid, target";

      agora no mesmo arquivo, vá até o final do arquivo e adicione essa função:
      uint32_t CreatureEvent::executeNoCountFragArea(Creature* creature, Creature* target) { //noCountFragArea(cid, target) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::ostringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; if(m_scriptData) 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__ std::ostringstream desc; desc << creature->getName(); env->setEvent(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(target)); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::clog << "[Error - CreatureEvent::noCountFragArea] Call stack overflow." << std::endl; return 0; } }

      agora vá em creatureevent.h

      procure por:
      CREATURE_EVENT_PREPAREDEATH
      adicione abaixo:
      CREATURE_EVENT_NOCOUNTFRAG

      procure por:
      uint32_t executePrepareDeath(Creature* creature, DeathList deathList);
      Adicione abaixo:
      uint32_t executeNoCountFragArea(Creature* creature, Creature* target);

      agora vá em player.cpp

      procure por:
      bool Player::onKilledCreature(Creature* target, DeathEntry& entry)
      abaixo de:
      War_t enemy; if(targetPlayer->getEnemy(this, enemy)) { if(entry.isLast()) IOGuild::getInstance()->updateWar(enemy); entry.setWar(enemy); }
      Adicione o seguinte código:
      if (targetPlayer){ CreatureEventList killEvents = getCreatureEvents(CREATURE_EVENT_NOCOUNTFRAG); for (const auto &event : killEvents) { if (!event->executeNoCountFragArea(this, target)) { return true; } } }

      //

      Feito isso, tudo completo na sua source, agora é necessário adicionar o creaturescript dentro do servidor

      vá até creaturescripts/scripts
      crie um arquivo chamado, "noCountFragInArea.lua"
      e dentro dele cole o código:
       
      --[[ script feito por feetads / TibiaKing ]]-- --[[ discord: feetads / FeeTads#0246 ]]-- -- Add positions here for which you do not want to count frags local areas = { [1] = {from = {x = 91, y = 122, z = 7}, to = {x = 98, y = 127, z = 7}}, -- from = area superior esquerda / to = area inferior direita (formando um quadrado) } local onlyKillerInArea = false -- only killer need to be in area? function noCountFragArea(cid, target) if not isCreature(cid) or not isCreature(target) then return true end local posKiller = getPlayerPosition(cid) local posTarget = getPlayerPosition(target) for i = 1, #areas do local area = areas[i] if isInArea(posKiller, area.from, area.to) then if onlyKillerInArea then return false elseif isInArea(posTarget, area.from, area.to) then return false end end end return true end
      agora em creaturescripts.xml
      <event type="nocountfrag" name="fragarea" event="script" value="noCountFragInArea.lua"/>
      agora em creaturescripts/scripts/login.lua
       procure por OU semelhante a esse:
      registerCreatureEvent(cid, "AdvanceSave")
      e abaixo adicione:
      registerCreatureEvent(cid, "fragarea")

      //


      Agora tudo certo, quando quiser adiciona uma area que não pega frag, vá até o script e apenas coloque a area, igual o demonstrado no script

      Exemplo:
      local areas = { [1] = {from = {x = 91, y = 122, z = 7}, to = {x = 98, y = 127, z = 7}}, [2] = {from = {x = 1000, y = 1000, z = 7}, to = {x = 1100, y = 1100, z = 7}}, }
      assim somente colocando a area no script e abrindo o server ou dando /reload, já funcionará a area como não pegar frag.
      Esse sistema pode ser bom pra areas de pvp ativo, onde você ainda quer que o player que morrer perca os atributos, como se fosse uma morte normal, porém não conta frag pra quem matar.
      Bom pra sistemas tipo castle 48h (guild war), onde há diversas mortes e risco de pegar red, atrapalhando a war.

      Façam bom proveito dos scripts, e deixem os créditos no script rsrs

      **Eu fiz as alterações e o simples código por isso vim disponibilizar, créditos meus**
    • Por Jaurez
      .
    • Por Thiagodsw
      Olá galera do Tibia King !
      Venho por meio deste tópico, publicar a ultima versão do meu servidor derivado de Tibia NTO Battle.
       
      deixei para brincarem e verem sistemas, as sources não disponibilizarei nem o site. afinal é um projeto que fiz com carinho e está a venda as sources. Thogo#9713
       
      O que tem de diferente no NTO Battle ? 
       
      Aura System e Wings Healthbar Monster Bar Healthbar vocation Sistema Raridade Shaders Dungeons e Tasks Game Shop Entre outros Veja algumas Imagens !
       
       
      O que tem nesse Pacote de Arquivos NTO Battle? 
       
      Datapack mais recente e completa do servidor. ( compilada pra windows Client Compilado SQL
      ACC GOD - god/god


      QUALQUER MSG NO DISCORD Thogo#9713
      -source client e otserv e site.
       
      DOWNLOAD  &  SCAN


       
      Client:
      https://mega.nz/file/hbgnSDRJ#xQT-qQHWLUV2Dn8jalwMGblCWnmL0_s3rZfqbxO7znw
      Server:
      https://mega.nz/file/sSZXlZ6a#gow-Db6diNVrnnPIH7qyBqP8WmVLFxWy85-yub_f32Y


       
      Scan
      Client
      https://www.virustotal.com/gui/file/86da72135d75d826c2665bb572084c30288eea843c2cfe2f7a405cfe1ea2f59c/detection
      Servidor
      https://www.virustotal.com/gui/file/cfa4d83c8b6c12fa0daf28cefd6762a053aee7245e6be8f5c02594825a2e2c1e?nocache=1
    • Por Thony D. Serv
      tfs 0.4 (não testei em outras apenas na 0.4)
      Esse script eu fiz pois, meu servidor sempre que reiniciava todos os players voltavam sem bless, então para sanar isso eu fiz um check de bless pela database para poder sempre que cair o servidor os players não morressem sem bless e dropassem os itens
      vamos lá!

      Primeiro Execute Este Comando Em Sua Db:
       

      Va No Fim E Adicione
      050-function.lua 
       

      Agora vá no seu comando de Bless ou Npc e ponha cada um no seu devido lugar
       
       
      Agora Em Creaturescript/scripts Crie Uma Pasta Chamada Bless E Ponha La Dentro:

      blessingdeath.lua
       

      blessinglogin.lua
       

      Adicione Ambas No Login.lua
       
       
      Creaturescript.xml
       

      -- Creditos A Mim Mesmo hahaha. Espero Ajudar Vocês ?
    • Por Imperius
      Tinha visto isso no servidor do MegaTibia / Kaldrox e achei bem interessante.
       
      Todos os tópicos que encontrei sobre o assunto de alterar a cor das mensagens dos GMs, CMs e ADM no channel Help para vermelho, falavam que tinham que fazer uma configuração na própria source do servidor.
       
      Fiz uma gambiarra que funciona, sem a necessidade de mexer na source do servidor e de utilizar comandos para isso. Testei somente em TFS 0.4 e funciona tranquilamente.
       
      segue abaixo como configurar em seu otserver:
       
      data > talkactions > scripts > crie um arquivo chamado gmsayred.lua e cole o código abaixo:
       
      function onSay(cid, words, param, channel) if channel == CHANNEL_HELP then for _, pid in ipairs(getPlayersOnline()) do doPlayerSendChannelMessage(pid, '', "".. getCreatureName(cid) .. ": ".. words, TALKTYPE_CHANNEL_R1, CHANNEL_HELP) end return true end end  
      em talkactions.xml cole a tag abaixo:

       
      <!-- Gamemasters --> <talkaction default="yes" filter="quotation" logged="no" access="3" event="script" value="gmsayred.lua"/>    
      e pronto! Agora é só enviar alguma mensagem no Help que a mensagem ficará em vermelho.
       

       
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo