Ir para conteúdo

Featured Replies

Postado

Entao galera, uso esse script de reset que e pelo npc. Pois se fosse possível adaptasse para cada reset o player ganhar 500hp e 500mp.

 

link do system: 

 

 

REP+ vllw

 

 

Editado por Jinx (veja o histórico de edições)

  • Respostas 5
  • Visualizações 992
  • Created
  • Última resposta

Top Posters In This Topic

Postado

creio q seja adicionar uma function dentro do addevent do script mas pede lá mesmo no tópico do wolf que ele vai poder te orientar e ajudar certinho pois ele que fez o script.

Scriptszinhos:

 

Não abandone seu tópico, quando você tiver a dúvida resolvida sozinho tente ensinar aos outros como resolve-la (você pode não ser o único com o problema) e quando ela for resolvida por outra pessoa não se esqueça de marcar como melhor resposta e deixar o gostei.

Postado

é muito mais simples do que parece, mantém a percent em 100 e só coloca + 500 em resethp e resetmana:

 

Spoiler

local config = {
	minlevel = 150, --- level inical para resetar
	price = 10000, --- preço inicial para resetar
	newlevel = 20, --- level após reset
	priceByReset = 0, --- preço acrescentado por reset
	percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
	maxresets = 50,
	levelbyreset = 0 --- quanto de level vai precisar a mais no próximo reset
}
--- end config

function getResets(uid)
	resets = getPlayerStorageValue(uid, 378378)
	if resets < 0 then
		resets = 0
	end
	return resets
end

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                  npcHandler:onThink()                  end
 
function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	function addReset(cid)
		if(npcHandler:isFocused(cid)) then
			npcHandler:releaseFocus(cid)
		end
		
		talkState[talkUser] = 0
		resets = getResets(cid)
		setPlayerStorageValue(cid, 378378, resets+1) 
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
		local hp = getCreatureMaxHealth(cid)
		local resethp = hp*(config.percent/100) + 500
		setCreatureMaxHealth(cid, resethp)
		local differencehp = (hp - resethp)
		doCreatureAddHealth(cid, -differencehp)
		local mana = getCreatureMaxMana(cid)
		local resetmana = mana*(config.percent/100) + 500
		setCreatureMaxMana(cid, resetmana)
		local differencemana = (mana - resetmana)
		doCreatureAddMana(cid, -differencemana)
		doRemoveCreature(cid)		
		local description = resets+1
		db.executeQuery("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."")
		db.executeQuery("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0 WHERE `players`.`id`= ".. playerid .."")
		return true
	end
	
	local newPrice = config.price + (getResets(cid) * config.priceByReset)
	local newminlevel = config.minlevel + (getResets(cid) * config.levelbyreset)

	if msgcontains(msg, 'reset') then
		if getResets(cid) < config.maxresets then
			selfSay('You want to reset your character? It will cost '..newPrice..' gp\'s!', cid)
			talkState[talkUser] = 1
		else
			selfSay('You already reached the maximum reset level!', cid)
		end
		
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if getPlayerMoney(cid) < newPrice then
			selfSay('Its necessary to have at least '..newPrice..' gp\'s for reseting!', cid)
		elseif getPlayerLevel(cid) < newminlevel then
			selfSay('The minimum level for reseting is '..newminlevel..'!', cid)
		else
			doPlayerRemoveMoney(cid,newPrice)
			playerid = getPlayerGUID(cid)
			addEvent(function()
				if isPlayer(cid) then
					addReset(cid)
				end
			end, 3000)
			local number = getResets(cid)+1
			local msg ="---[Reset: "..number.."]-- You have reseted!  You'll be disconnected in 3 seconds."
			doPlayerPopupFYI(cid, msg) 
			talkState[talkUser] = 0
			npcHandler:releaseFocus(cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no')) and isInArray({1}, talkState[talkUser]) == TRUE then
		talkState[talkUser] = 0
		npcHandler:releaseFocus(cid)
		selfSay('Ok.', cid)
	elseif msgcontains(msg, 'quantity') then
		selfSay('You have a total of '..getResets(cid)..' reset(s).', cid)
		talkState[talkUser] = 0
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Postado
  • Autor
15 minutos atrás, xWhiteWolf disse:

é muito mais simples do que parece, mantém a percent em 100 e só coloca + 500 em resethp e resetmana:

 

  Ocultar conteúdo


local config = {
	minlevel = 150, --- level inical para resetar
	price = 10000, --- preço inicial para resetar
	newlevel = 20, --- level após reset
	priceByReset = 0, --- preço acrescentado por reset
	percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
	maxresets = 50,
	levelbyreset = 0 --- quanto de level vai precisar a mais no próximo reset
}
--- end config

function getResets(uid)
	resets = getPlayerStorageValue(uid, 378378)
	if resets < 0 then
		resets = 0
	end
	return resets
end

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                  npcHandler:onThink()                  end
 
function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	function addReset(cid)
		if(npcHandler:isFocused(cid)) then
			npcHandler:releaseFocus(cid)
		end
		
		talkState[talkUser] = 0
		resets = getResets(cid)
		setPlayerStorageValue(cid, 378378, resets+1) 
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
		local hp = getCreatureMaxHealth(cid)
		local resethp = hp*(config.percent/100) + 500
		setCreatureMaxHealth(cid, resethp)
		local differencehp = (hp - resethp)
		doCreatureAddHealth(cid, -differencehp)
		local mana = getCreatureMaxMana(cid)
		local resetmana = mana*(config.percent/100) + 500
		setCreatureMaxMana(cid, resetmana)
		local differencemana = (mana - resetmana)
		doCreatureAddMana(cid, -differencemana)
		doRemoveCreature(cid)		
		local description = resets+1
		db.executeQuery("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."")
		db.executeQuery("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0 WHERE `players`.`id`= ".. playerid .."")
		return true
	end
	
	local newPrice = config.price + (getResets(cid) * config.priceByReset)
	local newminlevel = config.minlevel + (getResets(cid) * config.levelbyreset)

	if msgcontains(msg, 'reset') then
		if getResets(cid) < config.maxresets then
			selfSay('You want to reset your character? It will cost '..newPrice..' gp\'s!', cid)
			talkState[talkUser] = 1
		else
			selfSay('You already reached the maximum reset level!', cid)
		end
		
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if getPlayerMoney(cid) < newPrice then
			selfSay('Its necessary to have at least '..newPrice..' gp\'s for reseting!', cid)
		elseif getPlayerLevel(cid) < newminlevel then
			selfSay('The minimum level for reseting is '..newminlevel..'!', cid)
		else
			doPlayerRemoveMoney(cid,newPrice)
			playerid = getPlayerGUID(cid)
			addEvent(function()
				if isPlayer(cid) then
					addReset(cid)
				end
			end, 3000)
			local number = getResets(cid)+1
			local msg ="---[Reset: "..number.."]-- You have reseted!  You'll be disconnected in 3 seconds."
			doPlayerPopupFYI(cid, msg) 
			talkState[talkUser] = 0
			npcHandler:releaseFocus(cid)
		end
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'no')) and isInArray({1}, talkState[talkUser]) == TRUE then
		talkState[talkUser] = 0
		npcHandler:releaseFocus(cid)
		selfSay('Ok.', cid)
	elseif msgcontains(msg, 'quantity') then
		selfSay('You have a total of '..getResets(cid)..' reset(s).', cid)
		talkState[talkUser] = 0
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

Esta pegando a % ainda. 

Eu queria que a cada reset ele ganhasse 500hp/hp somente isso, e nao a porcentagem.

Tem como ajudar ?

32 minutos atrás, Jinx disse:

Esta pegando a % ainda. 

Eu queria que a cada reset ele ganhasse 500hp/hp somente isso, e nao a porcentagem.

Tem como ajudar ?

Entedir. Mas ele so ganha no primeiro reset, dps do segundo ele nao ganha mais. Como faz pra que nos outros (2..3..4..5..etc) ganhe + 500 ?

Postado
1 hour ago, Jinx said:

Esta pegando a % ainda. 

Eu queria que a cada reset ele ganhasse 500hp/hp somente isso, e nao a porcentagem.

Tem como ajudar ?

Entedir. Mas ele so ganha no primeiro reset, dps do segundo ele nao ganha mais. Como faz pra que nos outros (2..3..4..5..etc) ganhe + 500 ?

cara você tá moscando, se vc manter percent = 100 no config ele só vai adicionar 500 a cada reset. É matemática básica.
maxhp * (100/100) + 500 = maxhp * 1 + 500 = maxhp + 500

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo