Ir para conteúdo

Featured Replies

Postado

Boa tarde pessoal!

Estou utilizando o sistema de EXP HIT no meu OT, porém encontrei um problema com a função "'doSendAnimatedText'".

O que ocorre é o seguinte:

Está configurado para quando estiver em party aparecer a XP que cada um está ganhando, porém ao ativar a XP compartilhada na party, os players não conseguem dar nenhum tipo de dano nos bichos e aparece o seguinte erro na minha distro;

Citar


[15:55:55.101] [Error - CreatureScript Interface]
[15:55:55.107] data/creaturescripts/scripts/exphit.lua:onStatsChange
[15:55:55.108] Description:
[15:55:55.109] attempt to index a number value
[15:55:55.110] stack traceback:
[15:55:55.113]  [C]: in function 'doSendAnimatedText'
[15:55:55.118]  data/creaturescripts/scripts/exphit.lua:114: in function <data/creaturescripts/scripts/exphit.lua:43>

 

Conseguem me ajudar com isso?

Lembrando que fora da party funciona normalmente, o problema é quando eu ativo para compartilhar XP na party.

Segue abaixo o script que estou usando: (deixei em negrito as linhas que possuem a função 'doSendAnimatedText'.

 

Citar

useStages = true 
premiumMultipliqueExp = 1
rateExp = 100

local stages = { 
    ["1-50"] = 80,
    ["51-100"] = 60,
    ["101-150"] = 50,
    ["151-180"] = 40,
    ["181-200"] = 35,
    ["201-230"] = 30,
    ["231-250"] = 25,
    ["251-280"] = 20,
    ["281-300"] = 15,    
}

ultimateExp = 10


partyPorcent = 40 
levelBlockParty = 50
expShareRadiusX = 30 
expShareRadiusY = 30 
expShareRadiusZ = 1 


local rings = {
    [3048] = 2,
    [3049] = 4,
    [3050] = 6,
}


function CalculeExp(monsterhp, exptotal, hit)
    hit = hit <= monsterhp and math.ceil(exptotal * hit / monsterhp) or 0
    return hit < 0 and 0 or hit
end

function isSummon(cid)
return getCreatureMaster(cid)
end

function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(attacker) and isMonster(cid) then
        if getCreatureStorage(cid, 50001) ~= 1 then
            doCreatureSetStorage(cid, 50002, getMonsterInfo(getCreatureName(cid)).experience * rateExp)
            doCreatureSetStorage(cid, 50001, 1)
        end
    end
    if type == STATSCHANGE_HEALTHLOSS then
        if isMonster(cid) then
            if isCreature(attacker) then
                local _cid = isSummon(attacker) and getCreatureMaster(attacker) or attacker
                if isPlayer(_cid) then
                    if useStages then
                        for strstage, experience in pairs(stages) do
                            tabstage = string.explode(strstage, "-")
                            if getPlayerLevel(_cid) >= tonumber(tabstage[1]) and getPlayerLevel(_cid) <= tonumber(tabstage[2]) then
                                ultimateExp = experience
                            end
                        end
                        experienceRate = ultimateExp
                    else
                        experienceRate = rateExp
                    end
                    local expgain = CalculeExp(getCreatureMaxHealth(cid), getMonsterInfo(getCreatureName(cid)).experience * experienceRate, value)
                    if getCreatureStorage(cid, 50002) > 0 then
                        if getCreatureStorage(cid, 50002) - expgain < 0 then
                            expgain = getCreatureStorage(cid, 50002)
                        end
                        doCreatureSetStorage(cid, 50002, getCreatureStorage(cid, 50002) - expgain)
                        local ringexp = 1
                        for idring, expring in pairs(rings) do
                            if getPlayerSlotItem(_cid, 9).itemid == idring then
                                ringexp = expring
                                break
                            end
                        end
                        local premiumMultipliqueExp = isPremium(_cid) and premiumMultipliqueExp or 1
                        expgain = expgain * ringexp * premiumMultipliqueExp
                        local party = false
                        if isInParty(_cid) then
                            local partyMembers, expParty = getPartyMembers(getPartyLeader(_cid)), expgain / 100 * partyPorcent
                            for indice, partyMember in pairs(partyMembers) do
                                attackerLevel, partyLevel = getPlayerLevel(_cid), getPlayerLevel(partyMember)
                                attackerPos, partyPos = getThingPos(_cid), getThingPos(partyMember)
                                x = false
                                if math.abs(attackerLevel - partyLevel) > levelBlockParty then
                                    x = true
                                elseif math.abs(attackerPos.x - partyPos.x) > expShareRadiusX then
                                    x = true
                                elseif math.abs(attackerPos.y - partyPos.y) > expShareRadiusY then
                                    x = true
                                elseif attackerPos.z ~= partyPos.z then
                                    x = true
                                elseif _cid == partyMember then
                                    x = true
                                end
                                if x then
                                    partyMembers[indice] = nil
                                end
                            end
                            if #partyMembers ~= 0 then
                                expParty = math.ceil(expgain / 100 * partyPorcent)
                                expmember = math.ceil(expParty / #partyMembers)
                                for _, member in pairs(partyMembers) do
                                    if member ~= _cid then
                                        doPlayerSendTextMessage(member, 12, "You received "..expmember.." party exp.")
                                        doSendAnimatedText(getCreaturePosition(member), expmember, 215)
                                        doPlayerAddExp(member, expmember)
                                    end
                                end
                                doPlayerSendTextMessage(_cid, 12, "You gain "..expgain.." exp. (" ..partyPorcent.."% send to party)")
                                doSendAnimatedText(_cid, expgain - expParty, 215)
                                doPlayerAddExp(_cid, expgain - expParty)
                                party = true
                            else
                                party = false
                            end
                        end
                        if not party then
                            doPlayerAddExp(_cid, expgain)
                            doSendAnimatedText(getThingPos(_cid), expgain, 215)
                        end
                    end
                end
            end
        end
    end
    return true
end

function onCombat(cid, target)
    if isMonster(target) and not isSummon(target) and not isPlayer(target) then
        registerCreatureEvent(target, "ExpGain")
    end
    return true
end

Obrigado desde já!

Resolvido por Fabi Marzan

Ir para solução
Postado
  • Autor
Em 15/06/2022 em 16:33, Fabi Marzan disse:

Tenta em vez de "doSendAnimatedText" troca por = 




doCreatureSay(_cid, expgain - expParty, TALKTYPE_ORANGE_1)

 

Você é o cara meu irmão!

Funcionou sim.

EDITED

Vou permanecer com ele dessa forma!

Foi de grande ajuda, muito obrigado :)

 

Editado por carvaroth (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.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo