Ir para conteúdo
  • Cadastre-se

(Resolvido)Skull System


Ir para solução Resolvido por Lyu,

Posts Recomendados

Boa noite a todos do TK, venho caridosamente pedir o suporte de vocês é claro se poderem ...
Estou com o seguinte problema, eu tenho o script pra dar o SKULL correto conforme a quantia de frags.

 

Aqui está o script que uso:

Spoiler

function onLogin(cid)
    if(getPlayerFrags(cid) >= 5 and getPlayerFrags(cid) < 7)then
        doCreatureSetSkullType(cid, 2)
    elseif(getPlayerFrags(cid) >= 8 and getPlayerFrags(cid) < 10)then
        doCreatureSetSkullType(cid, 3)
    elseif(getPlayerFrags(cid) >= 11 and getPlayerFrags(cid) < 13)then
        doCreatureSetSkullType(cid, 1)
    elseif(getPlayerFrags(cid) >= 14)then
        doCreatureSetSkullType(cid, 4)
    end
    return true
end

Essa função é um LOGIN.. Mas aparentemente quando abro o servidor ela não da problema, mas quando vou logar qualquer CHARACTER ele da a seguinte mensagem.. Segue anexo:

 

 

 

dsdsadsadsad.jpg

Editado por Andersen96 (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • Solução
4 minutos atrás, Andersen96 disse:

@Lyu E como adiciono ela? poderia explicar melhor? <3

 

Procurei a função aqui, não testei, mas adicione-a em data/lib/050-function.lua e veja se resolve o seu problema.

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

 

Link para o post
Compartilhar em outros sites

@Lyu Perfeito !!! Se poder me ajudar em uma ultima coisinha agradeço...
 

Spoiler

function onKill(cid, target, lastHit)
    
    if(getPlayerFrags(cid) >= 5 and getPlayerFrags(cid) < 6) and getPlayerStorageValue(cid, 7000) ~= 1 then
        doCreatureSetSkullType(cid, 2)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulation! You gained Green Skull! You have killed 500 players.")
        doBroadcastMessage("CONGRATULATIONS! ".. getCreatureName(cid) .." killed 500 players, he received the emblem - Green Skull!", MESSAGE_STATUS_CONSOLE_RED)
        setPlayerStorageValue(cid, 7000, 1)
    elseif(getPlayerFrags(cid) >= 7 and getPlayerFrags(cid) < 8) and getPlayerStorageValue(cid, 7001) ~= 1 then
        doCreatureSetSkullType(cid, 3)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulation! You gained White Skull! You have killed 2500 players.")
        doBroadcastMessage("CONGRATULATIONS! ".. getCreatureName(cid) .." killed 2500 players, he received the emblem - White Skull!", MESSAGE_STATUS_CONSOLE_RED)
        setPlayerStorageValue(cid, 7001, 1)
    elseif(getPlayerFrags(cid) >= 9 and getPlayerFrags(cid) < 10) and getPlayerStorageValue(cid, 7002) ~= 1 then
        doCreatureSetSkullType(cid, 1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulation! You gained Yellow Skull! You have killed 5000 players.")
        doBroadcastMessage("CONGRATULATIONS! ".. getCreatureName(cid) .." killed 5000 players, he received the emblem - Yellow Skull!", MESSAGE_STATUS_CONSOLE_RED)
        setPlayerStorageValue(cid, 7002, 1)
    elseif(getPlayerFrags(cid) >= 11 and getPlayerFrags(cid) < 100000) and getPlayerStorageValue(cid, 7003) ~= 1 then
        doCreatureSetSkullType(cid, 4)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulation! You gained Red Skull! You have killed 10000 players.")
        doBroadcastMessage("CONGRATULATIONS! ".. getCreatureName(cid) .." killed 10000 players, he received the emblem - Red Skull!", MESSAGE_STATUS_CONSOLE_RED)
        setPlayerStorageValue(cid, 7003, 1)
    end
    return true
end

Este script era pra trocar o SKULL quando avançasse os FRAGS requerido, ou seja.. EX: tenho 6 frags que é TYPESKULL: 2 quando mato um player deveria trocar para a caveira de FRAGS 7 que seria a TYPE: 1 .. Mas não está trocando após chegar nos frags requeridos. 

Link para o post
Compartilhar em outros sites
8 minutos atrás, Andersen96 disse:

@Lyu Perfeito !!! Se poder me ajudar em uma ultima coisinha agradeço...
 

  Mostrar conteúdo oculto

function onKill(cid, target, lastHit)
    
    if(getPlayerFrags(cid) >= 5 and getPlayerFrags(cid) < 6) and getPlayerStorageValue(cid, 7000) ~= 1 then
        doCreatureSetSkullType(cid, 2)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulation! You gained Green Skull! You have killed 500 players.")
        doBroadcastMessage("CONGRATULATIONS! ".. getCreatureName(cid) .." killed 500 players, he received the emblem - Green Skull!", MESSAGE_STATUS_CONSOLE_RED)
        setPlayerStorageValue(cid, 7000, 1)
    elseif(getPlayerFrags(cid) >= 7 and getPlayerFrags(cid) < ? and getPlayerStorageValue(cid, 7001) ~= 1 then
        doCreatureSetSkullType(cid, 3)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulation! You gained White Skull! You have killed 2500 players.")
        doBroadcastMessage("CONGRATULATIONS! ".. getCreatureName(cid) .." killed 2500 players, he received the emblem - White Skull!", MESSAGE_STATUS_CONSOLE_RED)
        setPlayerStorageValue(cid, 7001, 1)
    elseif(getPlayerFrags(cid) >= 9 and getPlayerFrags(cid) < 10) and getPlayerStorageValue(cid, 7002) ~= 1 then
        doCreatureSetSkullType(cid, 1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulation! You gained Yellow Skull! You have killed 5000 players.")
        doBroadcastMessage("CONGRATULATIONS! ".. getCreatureName(cid) .." killed 5000 players, he received the emblem - Yellow Skull!", MESSAGE_STATUS_CONSOLE_RED)
        setPlayerStorageValue(cid, 7002, 1)
    elseif(getPlayerFrags(cid) >= 11 and getPlayerFrags(cid) < 100000) and getPlayerStorageValue(cid, 7003) ~= 1 then
        doCreatureSetSkullType(cid, 4)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulation! You gained Red Skull! You have killed 10000 players.")
        doBroadcastMessage("CONGRATULATIONS! ".. getCreatureName(cid) .." killed 10000 players, he received the emblem - Red Skull!", MESSAGE_STATUS_CONSOLE_RED)
        setPlayerStorageValue(cid, 7003, 1)
    end
    return true
end

Este script era pra trocar o SKULL quando avançasse os FRAGS requerido, ou seja.. EX: tenho 6 frags que é TYPESKULL: 2 quando mato um player deveria trocar para a caveira de FRAGS 7 que seria a TYPE: 1 .. Mas não está trocando após chegar nos frags requeridos. 

 

tem que ver se o player não possui a storage referente, senão ele não recebe. Porque reparei aqui que está bloqueado para receber as skulls somente uma vez (storage), a não ser que, esteja manipulando essa storage a partir de outro script.

Link para o post
Compartilhar em outros sites
1 hora atrás, Andersen96 disse:

@Lyu Perfeito !!! Se poder me ajudar em uma ultima coisinha agradeço...
 

  Mostrar conteúdo oculto

function onKill(cid, target, lastHit)
    
    if(getPlayerFrags(cid) >= 5 and getPlayerFrags(cid) < 6) and getPlayerStorageValue(cid, 7000) ~= 1 then
        doCreatureSetSkullType(cid, 2)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulation! You gained Green Skull! You have killed 500 players.")
        doBroadcastMessage("CONGRATULATIONS! ".. getCreatureName(cid) .." killed 500 players, he received the emblem - Green Skull!", MESSAGE_STATUS_CONSOLE_RED)
        setPlayerStorageValue(cid, 7000, 1)
    elseif(getPlayerFrags(cid) >= 7 and getPlayerFrags(cid) < ? and getPlayerStorageValue(cid, 7001) ~= 1 then
        doCreatureSetSkullType(cid, 3)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulation! You gained White Skull! You have killed 2500 players.")
        doBroadcastMessage("CONGRATULATIONS! ".. getCreatureName(cid) .." killed 2500 players, he received the emblem - White Skull!", MESSAGE_STATUS_CONSOLE_RED)
        setPlayerStorageValue(cid, 7001, 1)
    elseif(getPlayerFrags(cid) >= 9 and getPlayerFrags(cid) < 10) and getPlayerStorageValue(cid, 7002) ~= 1 then
        doCreatureSetSkullType(cid, 1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulation! You gained Yellow Skull! You have killed 5000 players.")
        doBroadcastMessage("CONGRATULATIONS! ".. getCreatureName(cid) .." killed 5000 players, he received the emblem - Yellow Skull!", MESSAGE_STATUS_CONSOLE_RED)
        setPlayerStorageValue(cid, 7002, 1)
    elseif(getPlayerFrags(cid) >= 11 and getPlayerFrags(cid) < 100000) and getPlayerStorageValue(cid, 7003) ~= 1 then
        doCreatureSetSkullType(cid, 4)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulation! You gained Red Skull! You have killed 10000 players.")
        doBroadcastMessage("CONGRATULATIONS! ".. getCreatureName(cid) .." killed 10000 players, he received the emblem - Red Skull!", MESSAGE_STATUS_CONSOLE_RED)
        setPlayerStorageValue(cid, 7003, 1)
    end
    return true
end

Este script era pra trocar o SKULL quando avançasse os FRAGS requerido, ou seja.. EX: tenho 6 frags que é TYPESKULL: 2 quando mato um player deveria trocar para a caveira de FRAGS 7 que seria a TYPE: 1 .. Mas não está trocando após chegar nos frags requeridos. 

 

 

@KotZletY @xWhiteWolf

Link para o post
Compartilhar em outros sites

@Andersen96 Setá conforme o nome .. SKULL_WHITE , SKULL_YELLOW , SKULL_RED , SKULL_BLACK ..

você pode usar em mods seria até melhor 

PS: é do skyforever , você não falo qual versão era e tals 

 

Skullsystem.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Skull System" version="1.0" author="Skyforever" contact="tibiaking.com" enabled="yes">
<config name="SkullC_func"><![CDATA[
 
function setSkullColor(cid)
  if not isPlayer(cid) then
      return
  end
 
  local t = {
      [{15,29}] = SKULL_WHITE,
      [{30,49}] = SKULL_YELLOW,
      [{50,89}] = SKULL_WHITE,
      [{90,149}] = SKULL_RED,
      [{150,math.huge}] = SKULL_BLACK
  }
  local frags = getPlayerFrags(getPlayerGUID(cid))
  for var, ret in pairs(t) do
      if frags >= var[1] and frags <= var[2] then
          doCreatureSetSkullType(cid, ret)
      end
  end
end
 
function getPlayerFrags(guid)
   local result = db.getResult("SELECT COUNT(*) as count 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)
   if(result:getID() ~= -1) then
      local count = result:getDataInt("count")
       result:free()
      return count
   end
end
]]></config>
<event type="login" name="SkullLogin" event="script"><![CDATA[
domodlib('SkullC_func')
function onLogin(cid)
  registerCreatureEvent(cid, "ColorKill")
  setSkullColor(cid)
  return true
end]]></event>
<event type="kill" name="ColorKill" event="script"><![CDATA[
domodlib('SkullC_func')
function onKill(cid, target)
  if isPlayer(cid) and isPlayer(target) then
      doCreatureSetSkullType(target, 0)
      addEvent(setSkullColor, 100, cid)
  end
  return true
end]]></event>
</mod>

 

Vale lembrar você deve remover seu sistema antigo.

 

 

 

Editado por Celulose (veja o histórico de edições)
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.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo