Postado Junho 9, 2023 1 ano 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.
Postado Junho 10, 2023 1 ano 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
Postado Junho 10, 2023 1 ano Autor 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!
Postado Junho 15, 2023 1 ano Autor 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.
Postado Junho 17, 2023 1 ano Diretor 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 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
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.