Ir para conteúdo

Featured Replies

Postado

Boa noite amigos, queria um script pra mostrar o número de resets quando o player da o look.
Segue meu script de reset, utilizo mysql para gerencia o db.
Versão do ot: 8.6 forgotten server.
 

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


local config = {
minlevel = 350, --- level inical para resetar
price = 100000, --- preço inicial para resetar
newlevel = 8, --- level após reset
priceByReset = 100000, --- preço acrescentado por reset
percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
maxresets = 1000,
levelbyreset = 5 --- 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)
	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)
    doRemoveCreature(cid)		
	local description = resets+1
    db.query("UPDATE `players` SET `description` = ' [Reset: "..description.."] ' WHERE `players`.`id`= ".. playerid .."")
	db.query("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('Voce quer resetar ? vai custar '..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('É necessário ter no mínimo'..newPrice..' gp\'s pra resetar!', cid)
	elseif getPlayerLevel(cid) < newminlevel then
		selfSay('O level minimo pra resetar é '..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.."]-- Voce resetou e será desconectado em 3 segundos."
		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, 'quantidade') then
	selfSay('Voce tem um total de '..getResets(cid)..' reset(s).', cid)
	talkState[talkUser] = 0
end

return true
end

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

 

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

  • Respostas 9
  • Visualizações 1.5k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • @Hunterii o sistema já vem com uma função que retorna a quantidade de resets que o player tem, basta aplicar a função no look.   Você tem algum script de look em seu server ? Posta em spolie

  • Faça um backup do seu arquivo, troque a tag "doplayersetspecialdescription" por essa e teste!   doPlayerSetSpecialDescription(cid,'\n[Frags: '..getPlayerFrags(cid)..'],\n[Resets: '..math.max

  • Bom dia @bandzenho, sobre as suas dúvidas, vou tentar responde-lo de forma mais exata possível. 1 - seuot/data é onde estão todos os scripts do seu OT, existem vários tipos e cada um você vai coloca

Postado

@Hunterii o sistema já vem com uma função que retorna a quantidade de resets que o player tem, basta aplicar a função no look.

 

Você tem algum script de look em seu server ? Posta em spolier aqui para que eu faça a alteração! 

                                                              ezgif-1-98aab239f3.gif.1a897c9c3225228909e7b356a5cfb8e4.gif

Postado
  • Autor
6 horas atrás, KotZletY disse:

@Hunterii o sistema já vem com uma função que retorna a quantidade de resets que o player tem, basta aplicar a função no look.

 

Você tem algum script de look em seu server ? Posta em spolier aqui para que eu faça a alteração! 

Tenho sim @KotZletY, esse é o sistema de look do ot, nele tem o sistema de frags que quando você da o look no player, mostra o número de frags.
 

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 onLogin(cid)
	registerCreatureEvent(cid, "fraglook")
	return true
end

function onLook(cid, thing, position, lookDistance)
	if isPlayer(thing.uid) and thing.uid ~= cid then
		doPlayerSetSpecialDescription(thing.uid,' [Frags: '..getPlayerFrags(thing.uid)..']')
		return true
	elseif thing.uid == cid then
		doPlayerSetSpecialDescription(cid,'\n[Frags: '..getPlayerFrags(cid)..']')
		local string = 'You see yourself. \nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..']\n Mana: ['.. getCreatureMana(cid) ..' / '.. getCreatureMaxMana(cid) ..'].\n'
		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
		string = string..getPlayerSpecialDescription(cid)..''

		if getPlayerNameByGUID(getPlayerPartner(cid), false, false) ~= nil then
			string = string..' You are '.. (getPlayerSex(cid) == 0 and 'wife' or 'husband') ..' of '.. getPlayerNameByGUID(getPlayerPartner(cid)) ..'.'
		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

		if getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS) then
			string = string..'\nHealth: ['.. getCreatureHealth(cid) ..' / '.. getCreatureMaxHealth(cid) ..']\n 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
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, string)  
		return false
	end
	return true
end

 

Postado

Olá bom dia!

Eu sou completamente novo nesse mundo dos OTserv, sou Webmaster e tenho experiência com MySQL e PHP, CSS e um pouco de tudo de Web, nesse caso creio que não terei grandes dificuldades em geral, porém tenho algumas dúvidas.

 

Coloquei ontem um OTServ 8.60 rodar no meu localhost, estou fazendo o mapa no RME e vi essa postagem referente a script de Reset com Look funcional e me interessei em implementar isto no OTServ Baiak a qual fiz o Download.

 

Vou citar algumas dúvidas minhas e se possível responder ficaria muito grato!

 

  1. Onde colocar novos scripts? não tenho conhecimento se OTServ's seguem padrões de pastas, o meu é o BestBaiak, eu creio que seja a pasta "BestBaiak\mods\scripts", é esta pasta mesmo? 
  2. O Script acima (----[[Script made 100% by Nogard and Night Wolf...) teria que ser adicionado dentro de um arquivo .lua com algum nome específico ou qualquer nome de arquivo executará o script normalmente?
  3. Onde encontro o arquivo de script de Look do meu OTServer? creio que já existe um também pois no OT também mostra os Frags dos Players quando dá look.

Obrigado pela atenção!

 

Postado
  • Autor

Bom dia @bandzenho, sobre as suas dúvidas, vou tentar responde-lo de forma mais exata possível.
1 - seuot/data é onde estão todos os scripts do seu OT, existem vários tipos e cada um você vai colocar na pasta correspondente. O nome do script vai variar de como o seu .lua vai chamar ele.
2 - Sim, ele tem que ser adicionando em um script .lua e funciona em conjunto com um script de NPC que executa a ação de dar o reset no player.
3 - Provavelmente vai estar na pasta seuot/data/creaturescipts/scripts ai é só procurar.

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

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