Ir para conteúdo
  • Cadastre-se

Posts Recomendados

Hi everyone. I need a rebirth ranking for my ot. Like frags rank or level rank, but to rebirths.

I dont have it in my db...so...i give you my script.

 

local config = {
	price = 0, -- Price of first rebirth
	priceIncrease = 0, -- Works as 'price' + current rebirths * priceIncrease.
	rebirthLevel = 717217, -- Level for first rebirth.
	rebirthIncrease = 0, -- Works as 'rebirthLevel' + current rebirths * rebirthIncrease.
	maxRebirths = 10000, -- Number of times a player can rebirth.
	level = 1000, -- The level the player is set to apon rebirth.
	healthPercent = 1.00, -- 1.00 = 100%.
	health = 100, -- Only used if 'healthPercent' = 0.
	manaPercent = 1.00, -- 1.00 = 100%.
	mana = 100, -- Only used if 'manaPercent' = 0.
	keepSkills = true, -- Wether players keep skills and level apon rebirth.
	skillLevel = 10, -- Only used if 'keepSkills' = false.
	magicLevel = 0, -- Only used if 'keepSkills' = false.
	capacity = 10000, -- The capacity players are set to apon rebirth.
	templePos = {x = 2000, y = 2000, z = 7}, -- The place where players reset to should there town id return 0.
	storage = 85987 -- Player storage rebirth count is kept on.
}
 
local focuses = {}
local function isFocused(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			return true
		end
	end
	return false
end
 
local function addFocus(cid)
	if(not isFocused(cid)) then
		table.insert(focuses, cid)
	end
end
local function removeFocus(cid)
	for i, v in pairs(focuses) do
		if(v == cid) then
			table.remove(focuses, i)
			break
		end
	end
end
local function lookAtFocus()
	for i, v in pairs(focuses) do
		if(isPlayer(v)) then
			doNpcSetCreatureFocus(v)
			return
		end
	end
	doNpcSetCreatureFocus(0)
end
 
function onCreatureDisappear(cid)
	if(isFocused(cid)) then
		selfSay("Goodbye.")
		removeFocus(cid)
	end
end
 
function onCreatureSay(cid, type, msg)
	if((msg == "hi") and not (isFocused(cid))) then
		selfSay("Welcome, ".. getCreatureName(cid) ..".", cid, true)
		selfSay("I can {rebirth} you!", cid)
		addFocus(cid)
		status = 1
	elseif((isFocused(cid)) and (msg == "rebirth") and (status == 1)) then
		if (getCreatureStorage(cid, config.storage) < config.maxRebirths) then
			storage = getCreatureStorage(cid, config.storage)
			rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
			if (getPlayerLevel(cid) >= rebirthLevel) then
				money = config.price + (config.priceIncrease * storage)
				if (getPlayerMoney(cid) >= money) then
					selfSay("I can rebirth you for " .. money .. " gold.", cid)
					selfSay("Do you want me to rebirth you?", cid)
					status = 2
				else
					selfSay("You need at least " .. money .. " gold before you can rebirth.", cid)
					status = 1
				end
			else
				selfSay("You need to be at least level " .. rebirthLevel .. " before you can rebirth.", cid)
				status = 1
			end
		else
			selfSay("It seems you can not rebirth anymore.", cid)
			status = 1
		end
	elseif((isFocused(cid)) and (msg == "yes") and (status == 2)) then
		selfSay("Ok then i will rebirth you.", cid)
		selfSay("You will now be logged out.", cid)
		doPlayerRemoveMoney(cid, money)
		addEvent(doRebirthPlayer, 2000, {cid=cid})
		removeFocus(cid)
	elseif((isFocused(cid)) and (msg == "no") and (status == 2)) then
		selfSay("Maybe one day you will wise up and change your mind!", cid)
		status = 1
	elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
		selfSay("Goodbye!", cid, true)
		removeFocus(cid)
	end
end
 
function onPlayerCloseChannel(cid)
	if(isFocused(cid)) then
		selfSay("Goodbye.")
		removeFocus(cid)
	end
end
 
function onThink()
	for i, focus in pairs(focuses) do
		if(not isCreature(focus)) then
			removeFocus(focus)
		else
			local distance = getDistanceTo(focus) or -1
			if((distance > 4) or (distance == -1)) then
				selfSay("Goodbye.")
				removeFocus(focus)
			end
		end
	end
	lookAtFocus()
end
 
function doRebirthPlayer(cid)
	cid = cid.cid
	if (cid == nil) then
		return true
	end
 
	local guid = getPlayerGUID(cid)
 
	if (config.healthPercent > 0) then
		health = getCreatureMaxHealth(cid) * config.healthPercent
	else
		health = config.health
	end
	if (config.manaPercent > 0) then
		mana = getCreatureMaxMana(cid) * config.manaPercent
	else
		mana = config.mana
	end
	if (getPlayerTown(cid) > 0) then
		pos = getTownTemplePosition(getPlayerTown(cid))
	else
		pos = config.templePos
	end
 
 
	doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
	doRemoveCreature(cid, true)
	db.executeQuery("UPDATE `players` SET level = " .. config.level .. " WHERE id = " .. guid .. ";")
	db.executeQuery("UPDATE `players` SET cap = " .. config.capacity .. " WHERE id = " .. guid .. ";")
	db.executeQuery("UPDATE `players` SET health = " .. health .. " WHERE id = " .. guid .. ";")
	db.executeQuery("UPDATE `players` SET healthmax = " .. health .. " WHERE id = " .. guid .. ";")
	db.executeQuery("UPDATE `players` SET mana = " .. mana .. " WHERE id = " .. guid .. ";")
	db.executeQuery("UPDATE `players` SET manamax = " .. mana .. " WHERE id = " .. guid .. ";")
	db.executeQuery("UPDATE `players` SET posx = " .. pos.x .. " WHERE id = " .. guid .. ";")
	db.executeQuery("UPDATE `players` SET posy = " .. pos.y .. " WHERE id = " .. guid .. ";")
	db.executeQuery("UPDATE `players` SET posz = " .. pos.z .. " WHERE id = " .. guid .. ";")
 
	if (not config.keepSkills) then
		db.executeQuery("UPDATE `players` SET maglevel = " .. config.magicLevel .. " WHERE id = " .. guid .. ";")
		db.executeQuery("UPDATE `player_skills` SET value = " .. config.skillLevel .. " WHERE id = " .. guid .. ";")
	end
	return true
end

 

Link para o post
Compartilhar em outros sites

Try this: 

 

talkactions.xml

<talkaction words="!rank rebirth" event="script" value="rank rebirth.lua"/>

talkactions/rank rebirth.lua

function onSay(cid, words, param)

    local players = 20 -- How many players will be showed in the highscore

    local str = ""
    local name = ""
    local player_id = 0
    local result = nil
    local result2 = nil
    local first_val = ""
    local first_nam = ""
	
	str = "# [Rebirths] - Name\n"
	name = "name"
	result = db.getResult("SELECT `player_id`, (`value` * 1) AS `value` FROM `player_storage` WHERE `key` = 85987 ORDER BY `value` DESC;")
	result2 = db.getResult("SELECT `name` FROM `players` WHERE id = "..result:getDataString("player_id")..";")
	first_val = result:getDataString("value")
	first_nam = result2:getDataString("name")
	str = str.."\n ".."1. ["..first_val.."] - "..first_nam
 	if (result:getID() ~= -1) then
 		local i = 2
 		while TRUE do
	 		if not(result:next()) or i > players then
 				break
 			end
 			result2 = db.getResult("SELECT `name` FROM `players` WHERE id = "..result:getDataString("player_id")..";")
 			str = str .. "\n " .. i .. ". [" .. result:getDataString("value") .. "] - " .. (name ~= "" and result2:getDataString("name") or getPlayerNameByGUID(result:getDataInt(player_id)))
 			i = i+1
 			result2:free()
 		end
 		result:free()
 	end

 	if str ~= "" then
	 	doPlayerPopupFYI(cid, str)
 	end

 	return TRUE
end

 

Link para o post
Compartilhar em outros sites
1 hour ago, Zanrix said:

Try this: 

 

talkactions.xml


<talkaction words="!rank rebirth" event="script" value="rank rebirth.lua"/>

talkactions/rank rebirth.lua


function onSay(cid, words, param)

    local players = 20 -- How many players will be showed in the highscore

    local str = ""
    local name = ""
    local player_id = 0
    local result = nil
    local result2 = nil
    local first_val = ""
    local first_nam = ""
	
	str = "# [Rebirths] - Name\n"
	name = "name"
	result = db.getResult("SELECT `player_id`, (`value` * 1) AS `value` FROM `player_storage` WHERE `key` = 85987 ORDER BY `value` DESC;")
	result2 = db.getResult("SELECT `name` FROM `players` WHERE id = "..result:getDataString("player_id")..";")
	first_val = result:getDataString("value")
	first_nam = result2:getDataString("name")
	str = str.."\n ".."1. ["..first_val.."] - "..first_nam
 	if (result:getID() ~= -1) then
 		local i = 2
 		while TRUE do
	 		if not(result:next()) or i > players then
 				break
 			end
 			result2 = db.getResult("SELECT `name` FROM `players` WHERE id = "..result:getDataString("player_id")..";")
 			str = str .. "\n " .. i .. ". [" .. result:getDataString("value") .. "] - " .. (name ~= "" and result2:getDataString("name") or getPlayerNameByGUID(result:getDataInt(player_id)))
 			i = i+1
 			result2:free()
 		end
 		result:free()
 	end

 	if str ~= "" then
	 	doPlayerPopupFYI(cid, str)
 	end

 	return TRUE
end

 

 

 

 

THANKS! IT WORKS VERY WELL!

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 Jaurez
      .
    • Por Cat
      Em alguns casos, o tibia 8.60 comum não abre de jeito nenhum no map editor, mesmo desmarcando check file signatures e configurando o path corretamente.
       
      Este é o client 8.60 adaptado para o Remere's Map Editor. Resolvi postar já que ele foi removido do site oficial do RME. (ficou apenas a versão para linux lá)
      Se estiver tendo problemas para abrir a versão 8.60, tente utilizar este.
                                                                                                                     
      Baixar o Tibia Client 8.60 que funciona no Remere’s Map Editor
      Essa versão do Tibia 8.60 client resolve o erro unsupported client version ou Could not locate tibia.dat and/or tibia.spr, please navigate to your tibia 8.60 installation folder.
       
      Downloads
      https://tibiaking.com/applications/core/interface/file/attachment.php?id=47333

      Scan: https://www.virustotal.com/gui/file/333e172ac49ba2028db9eb5889994509e7d2de28ebccfa428c04e86defbe15cc
       
    • Por danilo belato
      Fala Galera To Com um problema aki 
       
      quero exporta umas sprites de um server para colocar em outro 
       
      eu clico na sprites ai aparece tds a forma delas do lado de la >>
       
      ai eu clico nela e ponho a opiçao de export mais quando salvo a sprite ela n abri 
       
      aparece isso quando tento vê-la 
       
      visualização não disponível ( no formatos png e bitmap)
       
      Agora no formato idc fala que o paint n pode ler 
       
      me ajudem ae...
    • Por Vitor Bicaleto
      Galera to com o script do addon doll aqui, quando eu digito apenas "!addon" ele aparece assim: Digite novamente, algo está errado!"
      quando digito por exemplo: "!addon citizen" ele não funciona e não da nenhum erro
       
      mesma coisa acontece com o mount doll.. 
    • Por Ayron5
      Substitui uma stone no serve, deu tudo certo fora  esse  erro ajudem  Valendo  Rep+  Grato  

      Erro: data/actions/scripts/boost.lua:557: table index is nil
       [Warning - Event::loadScript] Cannot load script (data/actions/scripts/boost.lua)

      Script:
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo