Ir para conteúdo

Featured Replies

Postado
14 minutos atrás, xWhiteWolf disse:
  Mostrar conteúdo oculto


--[[Script made 100% by Nogard and Night Wolf.
   You can feel free to edit anything you want, but don't remove the credits]] 

local itemsbyreset = {
-- [quantidade de resets] = {premio, quantidade}
	[1] = {2160, 1},
	[2] = {2160, 3},
	[3] = {2160, 4},
}


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
		local resets = getResets(cid)
		setPlayerStorageValue(cid, 378378, resets+1) 
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
		local hp = getCreatureMaxHealth(cid)
		local resethp = hp*(config.percent/100)
		setCreatureMaxHealth(cid, resethp)
		local differencehp = (hp - resethp)
		doCreatureAddHealth(cid, -differencehp)
		local mana = getCreatureMaxMana(cid)
		local resetmana = mana*(config.percent/100)
		setCreatureMaxMana(cid, resetmana)
		local differencemana = (mana - resetmana)
		doCreatureAddMana(cid, -differencemana)
		if itemsbyreset[resets+1] then
			doPlayerAddItem(cid, itemsbyreset[resets+1][1], itemsbyreset[resets+1][2])
		end
		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())

 

 

Simplesmente perfeita !! vlw mesmo 

  • Respostas 187
  • Visualizações 33.6k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Ulatson, eu ando meio ocupado pra ficar scriptando então só vou dar dicas de como fazer ou onde conseguir: tem como colocar no script por exemplo para o Player falar só !resetar? Esse script foi fei

  • cara, aquilo que eu te passei era pra vc substituir no seu script;;; ficando assim:   local combat = createCombatObject()setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatPa

  • talkactions/scripts/rankinreset local storage = 378378 -- storage que fica salvo os resets local itens = {2182, 2190, 2456, 2395} -- itens cujas imagens aparecerao (se nao souber oque eh, nao mexa)

Posted Images

Postado
20 minutos atrás, xWhiteWolf disse:

me fala qual tfs vc usa.. ele não tá entendendo os comandos de database, parece que você usa tfs 1.x+.
 

Quando abro o otserver na primeira linha da distro aparece isso.. [07/04/2017 15:16:04] Alissow Server, version 0.4.1 (Alissow)

acho  é que seja 0.4.1 , mas ta havendo mais um problema semelhando em outra area mas tbm envolvendo esse db.query

não tenho certeza se é por causa desse erro que o system não quer funcionar.. já troquei os db.executequery que tinha lá pelas outras duas formas

porem não deu o mesmo resultado.. 

veja

Spoiler

[Error - GlobalEvent Interface] 
[07/04/2017 15:16:09] data/globalevents/scripts/start.lua:onStartup
[07/04/2017 15:16:09] Description: 
[07/04/2017 15:16:09] data/globalevents/scripts/start.lua:2: attempt to call field 'query' (a nil value)
[07/04/2017 15:16:09] stack traceback:
[07/04/2017 15:16:09]     data/globalevents/scripts/start.lua:2: in function <data/globalevents/scripts/start.lua:1>

 

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

Postado

@xWhiteWolf Pode reformular o script para 8.60 (tfs 0.4), fazendo com que o char volte level 8, com os hp respectivo do level e vocação, + 500 hp e mana? Pq por porcentagem não ficou bom, é mais pra baiakao xp 9999999999999

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.6k

Informação Importante

Confirmação de Termo