Ir para conteúdo

Featured Replies

Postado
  • Autor

Deixa eu ver se entendi:

Está supondo que eu adicione +1 value em uma GlobalStorage cada vez que algum membro do time atacar o monstro - usando attacker - e que no final faça uma verificação de qual GlobalStorage está maior?

 

 

OBS: Aqui esta o Script rascunho que fiz apenas pra testar.

function onDeath(cid, corpse, killer)
--==============================================================================--
local monstName = "Dragon" -- Nome do monstro
--==============================================================================--


if isMonster(cid) then
        if string.lower(getCreatureName(cid)) == string.lower(monstName) then
if getPlayerStorageValue(killer[1], 5000) == 1 then
doCreatureSay(cid, "O Time 1 me matou.", TALKTYPE_ORANGE_1)
end
if getPlayerStorageValue(killer[1], 5001) == 1 then
doCreatureSay(cid, "O Time 2 me matou.", TALKTYPE_ORANGE_1)
end
end
end 


return TRUE
end

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

cms1-pr%C3%AAmio.png

  • Respostas 7
  • Visualizações 326
  • Created
  • Última resposta

Top Posters In This Topic

Postado

 

OBS: Aqui esta o Script rascunho que fiz apenas pra testar.
function onDeath(cid, corpse, killer)
--==============================================================================--
local monstName = "Dragon" -- Nome do monstro
--==============================================================================--


if isMonster(cid) then
        if string.lower(getCreatureName(cid)) == string.lower(monstName) then
if getPlayerStorageValue(killer[1], 5000) == 1 then
doCreatureSay(cid, "O Time 1 me matou.", TALKTYPE_ORANGE_1)
end
if getPlayerStorageValue(killer[1], 5001) == 1 then
doCreatureSay(cid, "O Time 2 me matou.", TALKTYPE_ORANGE_1)
end
end
end 


return TRUE
end

Nesse caso, seria utilizado um global storage e como o próprio nome já diz, é global.

E na função, não se inclui um creatureid. Apenas o id do value, pois é global (reforçando):

getGlobalStorageValue(valueid)

Então, seria:

local stor = {1234, 5678} -- storage ~ {team1, team2}
local gstor = {5000, 5001} -- global storage ~ {team1, team2}

function onStatsChange(cid, attacker, type, combat, value)
    if value > 0 and type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) then
        if getPlayerStorageValue(attacker, stor[1]) <= 0 then
            if getGlobalStorageValue(gstor[1]) < 0 then
                setGlobalStorageValue(gstor[1], 0)
            end
            
            setGlobalStorageValue(gstor[1], getGlobalStorageValue(gstor[1]) + value)
        elseif getPlayerStorageValue(attacker, stor[2]) <= 0 then
            if getGlobalStorageValue(gstor[2]) < 0 then
                setGlobalStorageValue(gstor[2], 0)
            end
            
            setGlobalStorageValue(gstor[2], getGlobalStorageValue(gstor[2]) + value)
        end
    end
    
    return true
end

function onDeath(cid)
    if getGlobalStorageValue(gstor[1]) > getGlobalStorageValue(gstor[2]) then
        doCreatureSay(cid, 'O Time 1 me matou.', TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'O Time 2 me matou.', TALKTYPE_ORANGE_1)
    end
    
    return true
end

PS: Já que você registra os creature events no arquivo XML do monstro em específico, não tem necessidade de checar o nome do creatureid ou checar se ele é um monstro.

The corrupt fear us.

The honest support us.

The heroic join us.

Postado
  • Autor

Estou no serviço agora, mas assim que chegar em casa eu testo.

 

 

 

PS: Já que você registra os creature events no arquivo XML do monstro em específico, não tem necessidade de checar o nome do creatureid ou checar se ele é um monstro.

 

Obrigado pela dica. 


#Suicide

Infelizmente, o seu Script não funcionou.

Independente de quem mate - seja Time 1, seja Time 2

O Time 2 sempre recebe a mensagem.

 

#EDIT²

Fiz uma pequena modificação aqui pra mim testar assim que chegar em casa.

 

local stor = {8888, 9999} -- storage ~ {team1, team2}
local gstor = {5000, 5001} -- global storage ~ {team1, team2}


function onStatsChange(cid, attacker, type, combat, value)
    if type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) then
        if getPlayerStorageValue(attacker, stor[1]) == 1 then
            if getGlobalStorageValue(gstor[1]) < 0 then
                setGlobalStorageValue(gstor[1], 0)
            end
            
            setGlobalStorageValue(gstor[1], getGlobalStorageValue(gstor[1])+1)
        elseif getPlayerStorageValue(attacker, stor[2]) == 1 then
            if getGlobalStorageValue(gstor[2]) < 0 then
                setGlobalStorageValue(gstor[2], 0)
            end
            
            setGlobalStorageValue(gstor[2], getGlobalStorageValue(gstor[2])+1)
        end
    end
    
    return true
end


function onDeath(cid)
    if getGlobalStorageValue(gstor[1]) > getGlobalStorageValue(gstor[2]) then
        doCreatureSay(cid, 'O Time 1 me matou.', TALKTYPE_ORANGE_1)
    else
        doCreatureSay(cid, 'O Time 2 me matou.', TALKTYPE_ORANGE_1)
    elseif getGlobalStorageValue(gstor[1]) == getGlobalStorageValue(gstor[2]) then
    doCreatureSay(cid, 'Empate Tecnico.', TALKTYPE_ORANGE_1)
    end
    
    return true
end

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

cms1-pr%C3%AAmio.png

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.7k

Informação Importante

Confirmação de Termo