Ir para conteúdo
  • 0
EminemOP

Scripting Sistema de reset do RadBR

Pergunta

EminemOP    0
EminemOP

Descreva em algumas palavras a base utilizada. (Nome do servidor / Nome do cliente / Nome do website / etc.).

The Forgotten Server 1.3 https://github.com/opentibiabr

MyAAC site.
 

Base:

OTServBR-Global-develop

 

Qual é a sua pergunta?

Eu já consegui o sistema de reset.

Porém agora necessito que ao dar look em si mesmo ou em outro player apareça o número de reset.

 

Você tem o código disponível? Se tiver poste-o na caixa de código que está dentro do spoiler abaixo:

Spoiler

local config = {
    backToLevel = 8,
    redskull = false, -- need to be without redskull to reset?
    battle = true, -- need to be without battle to reset?
    pz = false, -- need to be in protect zone to reset?
    stages = {
        {resets = 4, level = 350, premium = 330},
        {resets = 9, level = 355, premium = 340},
        {resets = 14, level = 360, premium = 355},
        {resets = 19, level = 365, premium = 360},
        {resets = 24, level = 380, premium = 370},
        {resets = 29, level = 390, premium = 380},
        {resets = 34, level = 410, premium = 400},
        {resets = 39, level = 430, premium = 420},
        {resets = 44, level = 450, premium = 440},
        {resets = 49, level = 480, premium = 470},
        {resets = 54, level = 510, premium = 500},
        {resets = 59, level = 550, premium = 540},
        {resets = 64, level = 590, premium = 580},
        {resets = 69, level = 630, premium = 620},
        {resets = 74, level = 680, premium = 670},
        {resets = 79, level = 730, premium = 720},
        {resets = 84, level = 780, premium = 770},
        {resets = 89, level = 860, premium = 840},
        {resets = 94, level = 930, premium = 910},
        {resets = 100, level = 1010, premium = 990}
    }
}

function onSay(player, words, param)
    local function getExperienceForLevel(lv)
        lv = lv - 1
        return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
    end
    
    
 
    local function getPlayerResets()
        local resets = player:getStorageValue(500)
        return resets < 0 and 0 or resets
        
    end
    
    local function doPlayerAddResets(count)
        player:setStorageValue(500, getPlayerResets() + count)
    end
    if config.redskull and player:getSkull() == 4 then
        player:sendCancelMessage("You need to be without red skull to reset.")
        return false
    elseif config.pz and not getTilePzInfo(player:getPosition()) then
        player:sendCancelMessage("You need to be in protection zone to reset.")
        return false
    elseif config.battle and player:getCondition(CONDITION_INFIGHT) then
        player:sendCancelMessage("Você precisa estar sem battle para resetar.")
        return false
    end
    
    local resetLevel = 0
    for x, y in ipairs(config.stages) do
        if getPlayerResets() <= y.resets then
            resetLevel = player:isPremium() and y.premium or y.level
            break
        end
    end
    
    if getPlayerLevel(player) < resetLevel then
        player:sendCancelMessage("Você precisa do level " .. resetLevel .. " ou mais para resetar.")
        return false
    end
    
    doPlayerAddResets(1)
    local healthMax, manaMax, health, mana = player:getMaxHealth(), player:getMaxMana(), player:getHealth(), player:getMana()
    player:removeExperience(getExperienceForLevel(player:getLevel()) - getExperienceForLevel(config.backToLevel))
    player:setMaxHealth(healthMax)
    player:setMaxMana(manaMax)
    player:addHealth(health)
    player:addMana(mana)
    player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "Agora você tem " .. getPlayerResets() .. " " .. (getPlayerResets() == 1 and "reset" or "resets") .. ".")
    player:save()
    return false
    
end

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, anexe-a dentro do spoiler abaixo:

Spoiler

 

 

Editado por EminemOP

Compartilhar este post


Link para o post
Compartilhar em outros sites

8 respostass a esta questão

Recommended Posts

  • 0
Baah    6
Baah

Você precisa entender como funciona a lógica de programação antes de continuar.

Para isso recomendo pesquisar na internet artigos ou vídeos. Isso vai te ajudar a construir esses scripts sem dificuldade.

 

Lembre-se de que o código é executado na sequencia. Se você colocar algo antes ou depois é assim que será mostrado, como descrito no seu post.

 

function Player:onLook(thing, position, distance)
    local description = "You see " -- You see ... o que?
    if thing:isCreature() and thing:isPlayer() then
    description = string.format("%s\nResets: [%d] ", description, math.max(0, thing:getStorageValue(500))) -- aqui você junta a frase de cima (string) direto com a frase (string) do reset. Evidentemente, a sequencia será "You see Resets: [0]"
    end 

 

No script você precisa mostrar os resets DEPOIS que você já mostrou todo o resto.

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Kuma Bear    33
Kuma Bear

vá no arquivo

data/events/scripts/player.lua

procure o codigo

function Player:onLook(thing, position, distance)
	local description = "You see " .. thing:getDescription(distance)
	if self:getGroup():getAccess() then

e substitua-o para

function Player:onLook(thing, position, distance)
	local description = "You see " .. thing:getDescription(distance)
	if thing:isPlayer() then
		description = string.format("%s\nResets: %d", description, thing:getStorageValue(500))
	end
	if self:getGroup():getAccess() then

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
EminemOP    0
EminemOP

Não funcionou amigo, mas eu mexi e ficou assim.

function Player:onLook(thing, position, distance)
    local description = "You see "
    if thing:isCreature() and thing:isPlayer() then
    description = string.format("%s\nResets: [%d] ", description, math.max(0, thing:getStorageValue(500)))
    end

 

19:19 You see 
Resets: [0] yourself. You are ADM.
Health: 195 / 195, Mana: 195 / 195.
Position: 542, 539, 7
IP: 127.0.0.1.
KD: [0.00]

 

Como faço para ser depois do level?

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Kuma Bear    33
Kuma Bear

coloca a linha que vc adaptou no final da função que deve funcionar

 

if thing:isCreature() then
			if thing:isPlayer() then
				description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp()))
			end
		end
	end

    if thing:isCreature() and thing:isPlayer() then
    	description = string.format("%s\nResets: [%d] ", description, math.max(0, thing:getStorageValue(500)))
    end 

	self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

 

agr se vc quiser ser exatamente ao lado do level (tipo Level 10, Resets 15), voce vai precisar cortar description no final dessa função e inserir o valor lá dentro

esse math.max não deveria ser necessário, esse seu look do adm tinah algum reset?

segundo seu código o storage dos resets é o 500, como aqui:


    local function getPlayerResets()
        local resets = player:getStorageValue(500)
        return resets < 0 and 0 or resets
        
    end

 

Editado por Kuma Bear

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
EminemOP    0
EminemOP
1 hora atrás, Kuma Bear disse:

coloca a linha que vc adaptou no final da função que deve funcionar

 


if thing:isCreature() then
			if thing:isPlayer() then
				description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp()))
			end
		end
	end

    if thing:isCreature() and thing:isPlayer() then
    	description = string.format("%s\nResets: [%d] ", description, math.max(0, thing:getStorageValue(500)))
    end 

	self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

 

agr se vc quiser ser exatamente ao lado do level (tipo Level 10, Resets 15), voce vai precisar cortar description no final dessa função e inserir o valor lá dentro

esse math.max não deveria ser necessário, esse seu look do adm tinah algum reset?

segundo seu código o storage dos resets é o 500, como aqui:



    local function getPlayerResets()
        local resets = player:getStorageValue(500)
        return resets < 0 and 0 or resets
        
    end

 

Coloquei no final e não aparece nada do reset, olha a print http://prntscr.com/owfhde



function Player:onLook(thing, position, distance)
    local description = "You see "
    if thing:isItem() then
        if thing.actionid == 5640 then
            description = description .. "a honeyflower patch."
        elseif thing.actionid == 5641 then
            description = description .. "a banana palm."
        elseif thing.itemid >= ITEM_HEALTH_CASK_START and thing.itemid <= ITEM_HEALTH_CASK_END
        or thing.itemid >= ITEM_MANA_CASK_START and thing.itemid <= ITEM_MANA_CASK_END
        or thing.itemid >= ITEM_SPIRIT_CASK_START and thing.itemid <= ITEM_SPIRIT_CASK_END
        or thing.itemid >= ITEM_KEG_START and thing.itemid <= ITEM_KEG_END then
            description = description .. thing:getDescription(distance)
            local charges = thing:getCharges()
            if charges then
            description = string.format("%s\nIt has %d refillings left.", description, charges)
            end
        else
            description = description .. thing:getDescription(distance)
        end
        if thing:isCreature() and thing:isPlayer() then
    description = string.format("%s\nResets: [%d] ", description, math.max(0, thing:getStorageValue(500)))
    end

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Kuma Bear    33
Kuma Bear

@Majesty testa o codigo pro cara por favor pq eu nao tenho OT pra ficar debuggando e ficar fazendo da memoria n vai levar em nenhum lugar

@EminemOP e no começo com este exato codigo que voce fez está indo normal?

Editado por Kuma Bear

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
EminemOP    0
EminemOP
Em 23/08/2019 em 05:36, Kuma Bear disse:

@Majesty testa o codigo pro cara por favor pq eu nao tenho OT pra ficar debuggando e ficar fazendo da memoria n vai levar em nenhum lugar

@EminemOP e no começo com este exato codigo que voce fez está indo normal?

está sim, to quase desistindo desse sistema. Quando eu dou look pelo battle aparece certinho depois do level zzzz 

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
EminemOP    0
EminemOP
Em 09/09/2019 em 20:12, Baah disse:

Você precisa entender como funciona a lógica de programação antes de continuar.

Para isso recomendo pesquisar na internet artigos ou vídeos. Isso vai te ajudar a construir esses scripts sem dificuldade.

 

Lembre-se de que o código é executado na sequencia. Se você colocar algo antes ou depois é assim que será mostrado, como descrito no seu post.

 


function Player:onLook(thing, position, distance)
    local description = "You see " -- You see ... o que?
    if thing:isCreature() and thing:isPlayer() then
    description = string.format("%s\nResets: [%d] ", description, math.max(0, thing:getStorageValue(500))) -- aqui você junta a frase de cima (string) direto com a frase (string) do reset. Evidentemente, a sequencia será "You see Resets: [0]"
    end 

 

No script você precisa mostrar os resets DEPOIS que você já mostrou todo o resto.

Eu percebi esses dias, até dei risada pela falta de atenção kkkkk
mas obrigado mesmo assim !!

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×