Ir para conteúdo
  • Cadastre-se

(Resolvido)Controle de kills e remoção de kills por tempo (script quase pronto)


Ir para solução Resolvido por jcfd.joao,

Posts Recomendados

utiliso TFS 1.3

no caso, eu estava tentando concluir o script porem nao sei usar o "Addevent".
Conseguir fazer a restrição de quantidade de kills.
ainda coloquei 2 storagevalue (um para a quantidade de kills e o outro seria o countdown).
mas nao sei como configurar para o player que fica impossibilitado de ganhar xp, voltar a ganhar xp depois de 1 ou 2 horas a ganhar novamente.

sei que alem desse script sendo ele "onKill" irei precisar tambem acrescentar no "onLogin" o evento que será criado e uma a verificação do tempo(storage).

peço a ajuda de vcs, e agradeço desde já!

pedido de ajuda para concluir script

 

Está surgindo algum erro? Se sim coloque-o aqui. 

Citar

 

 

local playerOnKill = CreatureEvent("PlayerOnKill")

    function playerOnKill.onKill(player, creature, lastHit)
            if not creature:isPlayer() then
        return true
    end

        for cid, damage in pairs(creature:getDamageMap()) do
        local fragid = (20000000 + (creature:getId()))
        local timefrag = (30000000 + (creature:getId()))
        local participant = Player(cid)
        if participant and participant:isPlayer() then
            local difer = (creature:getLevel() - player:getLevel())
            local difer2 = (player:getLevel() - creature:getLevel())
            local ExpLow = math.ceil((creature:getExperience()*0.05)/(difer2+1))
            local ExpHigh = math.ceil((creature:getExperience()*0.01)*((difer*0.5)+1))
            if creature:getLevel() <= participant:getLevel() and participant:getStorageValue(fragid) <= 3 then
                participant:addItem(2152, 10)
                    --participant:addExperience(ExpLow,true)
                        participant:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You gained ' .. ExpLow .. ' experience points.')
                            participant:setStorageValue(fragid,(participant:getStorageValue(fragid))+1)
                                participant:setStorageValue(timefrag, os.time() + 60)
                                elseif participant:getStorageValue(fragid) >= 3 then
                                participant:sendTextMessage(MESSAGE_STATUS_WARNING, 'This player cant give experience for you.')
                            end

                if difer >= 1 and participant:getStorageValue(fragid) <= 3 then
                    participant:addItem(2152, (difer*5)+10)
                            --participant:addExperience(ExpHigh,true)
                                participant:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You gained ' .. ExpHigh .. ' experience points.')
                                    participant:setStorageValue(fragid )
                                        participant:setStorageValue(timefrag )
                        elseif participant:getStorageValue(fragid) >= 3 then
                        player:sendTextMessage(MESSAGE_STATUS_WARNING, 'This player cant give experience for you.')
                        end
                end
        end
    

    return true
end

playerOnKill:register()

 

 

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. 

 

Link para o post
Compartilhar em outros sites
  • Respostas 10
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

function onPlayerKill(player, creature, lastHit) if not creature:isPlayer() then return true end for cid, damage in pairs(creature:getDamageMap()) do local fragid = 20000000 + creature:getId() local timefrag = 30000000 + creature:getId() local participant = Player(cid) if participant and participant:isPlayer() then local difer = creature:getLevel() - player:getLevel() local difer2 = player:getLevel() - creature:getLeve

Se puder poste a solução para ajudar as outras pessoas

Vou fazer um resumo pq precisaria criar um tutorial ou post pois envolve varias modificações; Basicamente é necessário criar um script com a função "onGainExp", que esse script tera a condição se a xp vier de players nesse mesmo script setar o storage value para cada morte baseado na ID (getGuid) do player. dai vem a condição de controlar a quantidade de kills assim que ele ganhe exp de players (a cada ganho de xp um storage value). logo se acontecer de chegar o limite configurada, exp =

function onPlayerKill(player, creature, lastHit)
    if not creature:isPlayer() then
        return true
    end

    for cid, damage in pairs(creature:getDamageMap()) do
        local fragid = 20000000 + creature:getId()
        local timefrag = 30000000 + creature:getId()
        local participant = Player(cid)

        if participant and participant:isPlayer() then
            local difer = creature:getLevel() - player:getLevel()
            local difer2 = player:getLevel() - creature:getLevel()
            local ExpLow = math.ceil(creature:getExperience() * 0.05 / (difer2 + 1))
            local ExpHigh = math.ceil(creature:getExperience() * 0.01 * ((difer * 0.5) + 1))

            if creature:getLevel() <= participant:getLevel() and participant:getStorageValue(fragid) <= 3 then
                participant:addItem(2152, 10)
                --participant:addExperience(ExpLow, true)
                participant:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You gained ' .. ExpLow .. ' experience points.')
                participant:setStorageValue(fragid, participant:getStorageValue(fragid) + 1)
                participant:setStorageValue(timefrag, os.time() + 60)
            elseif participant:getStorageValue(fragid) >= 3 then
                participant:sendTextMessage(MESSAGE_STATUS_WARNING, 'This player cannot give experience to you.')
            end

            if difer >= 1 and participant:getStorageValue(fragid) <= 3 then
                participant:addItem(2152, (difer * 5) + 10)
                --participant:addExperience(ExpHigh, true)
                participant:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You gained ' .. ExpHigh .. ' experience points.')
                participant:setStorageValue(fragid, participant:getStorageValue(fragid))
                participant:setStorageValue(timefrag, participant:getStorageValue(timefrag))
            elseif participant:getStorageValue(fragid) >= 3 then
                player:sendTextMessage(MESSAGE_STATUS_WARNING, 'This player cannot give experience to you.')
            end
        end
    end

    return true
end

function registerPlayerOnKill()
    addEvent(onPlayerKill)
end

registerPlayerOnKill()

testa ai e me fala aqui se deu erro no console

Link para o post
Compartilhar em outros sites
10 horas atrás, sverkoa disse:

function onPlayerKill(player, creature, lastHit)
    if not creature:isPlayer() then
        return true
    end

    for cid, damage in pairs(creature:getDamageMap()) do
        local fragid = 20000000 + creature:getId()
        local timefrag = 30000000 + creature:getId()
        local participant = Player(cid)

        if participant and participant:isPlayer() then
            local difer = creature:getLevel() - player:getLevel()
            local difer2 = player:getLevel() - creature:getLevel()
            local ExpLow = math.ceil(creature:getExperience() * 0.05 / (difer2 + 1))
            local ExpHigh = math.ceil(creature:getExperience() * 0.01 * ((difer * 0.5) + 1))

            if creature:getLevel() <= participant:getLevel() and participant:getStorageValue(fragid) <= 3 then
                participant:addItem(2152, 10)
                --participant:addExperience(ExpLow, true)
                participant:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You gained ' .. ExpLow .. ' experience points.')
                participant:setStorageValue(fragid, participant:getStorageValue(fragid) + 1)
                participant:setStorageValue(timefrag, os.time() + 60)
            elseif participant:getStorageValue(fragid) >= 3 then
                participant:sendTextMessage(MESSAGE_STATUS_WARNING, 'This player cannot give experience to you.')
            end

            if difer >= 1 and participant:getStorageValue(fragid) <= 3 then
                participant:addItem(2152, (difer * 5) + 10)
                --participant:addExperience(ExpHigh, true)
                participant:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You gained ' .. ExpHigh .. ' experience points.')
                participant:setStorageValue(fragid, participant:getStorageValue(fragid))
                participant:setStorageValue(timefrag, participant:getStorageValue(timefrag))
            elseif participant:getStorageValue(fragid) >= 3 then
                player:sendTextMessage(MESSAGE_STATUS_WARNING, 'This player cannot give experience to you.')
            end
        end
    end

    return true
end

function registerPlayerOnKill()
    addEvent(onPlayerKill)
end

registerPlayerOnKill()

testa ai e me fala aqui se deu erro no console

No caso,
vc inseriu o "addEvent" ok.

porem eu preciso saber como faço para que esse esse "event" só inicie depois que o storage de frags estiver >= 3, e apos 2 horas o contador "timeFrag" modifique o storage "fragid" para 0 novamente...
e que quando o player deslogar nao der erro ou pare de contar, como acontece com os "familiar summons".

 

muito obrigado pela força.

 

em resumo: o script que preciso é um controle de kill para o servidor hardcore-pvp onde os players só consigam obter xp apenas 3 vezes no mesmo player.

estou estudando um pouco sobre SQL para nao precisar usar storagevalues, pois percebi uma tabela chamada: player_kills.

onde fica registrado quem matou, o tempo e quem morreu. porem nao tem a coluna.

irei estudar como consigo pegar a quantidade de vezes que o registro se repete na tabela para assim fazer o "controle".


caso vc tenha um outro metodo (pois sei que o meu script ta uma bagunça), e se for possivel fazer com database, me avise.

 

obrigado pela atenção!

Link para o post
Compartilhar em outros sites
  • Solução

Já consegui de outra forma,

quem quiser abrir um hardcore e precisar colocar controle de kills eu estarei disposto a ajudar.


podem fechar

 

obrigado.

Link para o post
Compartilhar em outros sites
  • Sub-Admin
Em 15/06/2023 em 09:14, jcfd.joao disse:

Já consegui de outra forma,

quem quiser abrir um hardcore e precisar colocar controle de kills eu estarei disposto a ajudar.


podem fechar

 

obrigado.

Se puder poste a solução para ajudar as outras pessoas ;)

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

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.

  • Estatísticas dos Fóruns

    96842
    Tópicos
    519597
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo