KI
dúvida

Zombie creaturescripts

Por Killua, 22 de dez. de 2013 em Scripts

script
13
936
KilluaK
22 de dezembro de 2013 às 17:54

Eu cansei de procurar um Zombie Event que funcionasse sem problema e resolvi fazer um do zero. Eu fiz, e ficou tudo certo, funcionando exatamente como eu queria.

 

A minha dúvida é na parte do Creaturescritps... Meu zombie da somente um hit no player e o player já sofre ação do script. Eu queria fazer de um jeito que o player tivesse que levar uns 3 hits pelo menos, mas não estou conseguindo pensar em como fazer isso...

 

Se alguém puder me dar uma luz eu agradeceria.

 

Meu script:

 

function onStatsChange(cid, attacker, type, combat, value)
    local artigo = getPlayerSex(cid) == 0 and "comida" or "comido"
    if getCreatureName(attacker) == "Event Zombie" and isInArea(getCreaturePosition(cid), amoebaZombie.fromPosition, amoebaZombie.toPosition) then
        
        if getGlobalStorageValue(amoebaZombie.playerStorage) > 2 then
            setGlobalStorageValue(amoebaZombie.playerStorage, getGlobalStorageValue(amoebaZombie.playerStorage)-1)
            local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
            doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
            doBroadcastMessage(getPlayerName(cid) .." foi " .. artigo .. " pelos zombies!")
            doPlayerAddItem(cid, amoebaZombie.consolo[1], amoebaZombie.consolo[2])
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
        elseif getGlobalStorageValue(amoebaZombie.playerStorage) == 2 then
            setGlobalStorageValue(amoebaZombie.playerStorage, getGlobalStorageValue(amoebaZombie.playerStorage)-1)
            local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
            doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
            doBroadcastMessage(getPlayerName(cid) .." foi " .. artigo .. " pelos zombies!")
            doPlayerAddItem(cid, amoebaZombie.consolo[1], amoebaZombie.consolo[2])
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            addEvent(winZombieEvent, 1000)
            addEvent(removeZombies, 1000)
        end
    end
    return true
end

 

 

Editado Dezembro 22 por amoeba13

VillsV
22 de dezembro de 2013 às 18:51

cê alguem puder da a luz para esse cara eu agradeço também.. seus scripts me ajudaram muito.

zipter98Z
22 de dezembro de 2013 às 19:03


function onStatsChange(cid, attacker, type, combat, value)

 

local artigo = getPlayerSex(cid) == 0 and "comida" or "comido"

local max_hits = 3 --Quantos hits o jogador irá levar, no máximo. 3 = 3 hits do Zombie.

 

if getCreatureName(attacker) == "Event Zombie" and isInArea(getCreaturePosition(cid), amoebaZombie.fromPosition, amoebaZombie.toPosition) then

if type == STATSCHANGE_HEALTHLOSS then

if getPlayerStorageValue(cid, 834412) <= (max_hits - 2) then

setPlayerStorageValue(cid, 834412, getPlayerStorageValue(cid, 834412) + 1)

else

if getGlobalStorageValue(amoebaZombie.playerStorage) > 2 then

setGlobalStorageValue(amoebaZombie.playerStorage, getGlobalStorageValue(amoebaZombie.playerStorage)-1)

local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))

doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")

doBroadcastMessage(getPlayerName(cid) .." foi " .. artigo .. " pelos zombies!")

doPlayerAddItem(cid, amoebaZombie.consolo[1], amoebaZombie.consolo[2])

doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))

setPlayerStorageValue(cid, 834412, 0)

elseif getGlobalStorageValue(amoebaZombie.playerStorage) == 2 then

setGlobalStorageValue(amoebaZombie.playerStorage, getGlobalStorageValue(amoebaZombie.playerStorage)-1)

local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))

doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")

doBroadcastMessage(getPlayerName(cid) .." foi " .. artigo .. " pelos zombies!")

doPlayerAddItem(cid, amoebaZombie.consolo[1], amoebaZombie.consolo[2])

doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))

setPlayerStorageValue(cid, 834412, 0)

addEvent(winZombieEvent, 1000)

addEvent(removeZombies, 1000)

end

end

end

end

return true

end

 

Editado Dezembro 22 por zipter98

KilluaK
23 de dezembro de 2013 às 00:53

Ótima idéia, Zipter, muito obrigado!

 

Vou pensar se posto o evento também pro pessoal

 

Edit: Infelizmente meu servidor ta fechando toda vez que o Zombie da os X hits, não to entendendo pq...

Editado Dezembro 23 por amoeba13

zipter98Z
23 de dezembro de 2013 às 01:19

Estranho, testei aqui e tá funcionando direitinho o.O (claro, tive que editar algumas coisas pra funcionar: criar as funções e a tabela)

Seu servidor tá fechando em ambas as ocasiões (storage global maior que 2 e igual a 2)?

KilluaK
23 de dezembro de 2013 às 01:25

ixi =S, ele fecha assim que o Zombie dá o terceiro hit (máximo), ou seja, na hora de executar oq ta debaixo do else

zipter98Z
23 de dezembro de 2013 às 01:43

Só pra confirmar uma coisa: retire tudo que está abaixo do else, e coloque um simples

print("test")

O server continua fechando, ou imprime o "test"?

Editado Dezembro 23 por zipter98

KilluaK
23 de dezembro de 2013 às 02:22

Ele imprimiu certinho... =S

zipter98Z
23 de dezembro de 2013 às 14:56

Hm, dessas duas seguintes maneiras, o servidor fecha, ou ocorre certinho o quê está escrito no código?

function onStatsChange(cid, attacker, type, combat, value)
 
    local artigo = getPlayerSex(cid) == 0 and "comida" or "comido"
    local max_hits = 3        --Quantos hits o jogador irá levar, no máximo. 3 = 3 hits do Zombie.
    
    if getCreatureName(attacker) == "Event Zombie" and isInArea(getCreaturePosition(cid), amoebaZombie.fromPosition, amoebaZombie.toPosition) then
        if type == STATSCHANGE_HEALTHLOSS then
            if getPlayerStorageValue(cid, 834412) <= (max_hits - 2) then
                setPlayerStorageValue(cid, 834412, getPlayerStorageValue(cid, 834412) + 1)
            else
                setGlobalStorageValue(amoebaZombie.playerStorage, getGlobalStorageValue(amoebaZombie.playerStorage)-1)
                local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
                doBroadcastMessage(getPlayerName(cid) .." foi " .. artigo .. " pelos zombies!")
                doPlayerAddItem(cid, amoebaZombie.consolo[1], amoebaZombie.consolo[2])
                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
                setPlayerStorageValue(cid, 834412, 0)
                addEvent(winZombieEvent, 1000)
                addEvent(removeZombies, 1000)
            end
        end
    end
    return true
end
function onStatsChange(cid, attacker, type, combat, value)
 
    local artigo = getPlayerSex(cid) == 0 and "comida" or "comido"
    local max_hits = 3        --Quantos hits o jogador irá levar, no máximo. 3 = 3 hits do Zombie.
    
    if getCreatureName(attacker) == "Event Zombie" and isInArea(getCreaturePosition(cid), amoebaZombie.fromPosition, amoebaZombie.toPosition) then
        if type == STATSCHANGE_HEALTHLOSS then
            if getPlayerStorageValue(cid, 834412) <= (max_hits - 2) then
                setPlayerStorageValue(cid, 834412, getPlayerStorageValue(cid, 834412) + 1)
            else
                setGlobalStorageValue(amoebaZombie.playerStorage, getGlobalStorageValue(amoebaZombie.playerStorage)-1)
                local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
                doBroadcastMessage(getPlayerName(cid) .." foi " .. artigo .. " pelos zombies!")
                doPlayerAddItem(cid, amoebaZombie.consolo[1], amoebaZombie.consolo[2])
                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
                setPlayerStorageValue(cid, 834412, 0)
            end
        end
    end
    return true
end

Editado Dezembro 23 por zipter98

KilluaK
23 de dezembro de 2013 às 16:09

Das duas maneiras o servidor fecou... to quebrando minha cabeça aqui tbm

zipter98Z
23 de dezembro de 2013 às 17:20

Hm, agora realmente complicou. Não tenho a mínima ideia do quê está fazendo seu servidor cair. Aparentemente, está tudo certinho (como eu disse, funcionou aqui). O jeito vai ser ir testando de linha em linha. Talvez seja uma única função usada que está causando isso. Se esta for descoberta, ficará mais fácil resolver.

Se não se importar, poderia ir testando cada vez com uma função diferente após o else? Por exemplo,

function onStatsChange(cid, attacker, type, combat, value)
 
    local artigo = getPlayerSex(cid) == 0 and "comida" or "comido"
    local max_hits = 3        --Quantos hits o jogador irá levar, no máximo. 3 = 3 hits do Zombie.
    
    if getCreatureName(attacker) == "Event Zombie" and isInArea(getCreaturePosition(cid), amoebaZombie.fromPosition, amoebaZombie.toPosition) then
        if type == STATSCHANGE_HEALTHLOSS then
            if getPlayerStorageValue(cid, 834412) <= (max_hits - 2) then
                setPlayerStorageValue(cid, 834412, getPlayerStorageValue(cid, 834412) + 1)
            else
                setGlobalStorageValue(amoebaZombie.playerStorage, getGlobalStorageValue(amoebaZombie.playerStorage)-1)
            end
        end
    end
    return true
end
Depois, se o anterior funcionar,
function onStatsChange(cid, attacker, type, combat, value)
 
    local artigo = getPlayerSex(cid) == 0 and "comida" or "comido"
    local max_hits = 3        --Quantos hits o jogador irá levar, no máximo. 3 = 3 hits do Zombie.
    
    if getCreatureName(attacker) == "Event Zombie" and isInArea(getCreaturePosition(cid), amoebaZombie.fromPosition, amoebaZombie.toPosition) then
        if type == STATSCHANGE_HEALTHLOSS then
            if getPlayerStorageValue(cid, 834412) <= (max_hits - 2) then
                setPlayerStorageValue(cid, 834412, getPlayerStorageValue(cid, 834412) + 1)
            else
                setGlobalStorageValue(amoebaZombie.playerStorage, getGlobalStorageValue(amoebaZombie.playerStorage)-1)
                local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
            end
        end
    end
    return true
end
E assim vai.
Ou, se o primeiro não funcionar,
function onStatsChange(cid, attacker, type, combat, value)
 
    local artigo = getPlayerSex(cid) == 0 and "comida" or "comido"
    local max_hits = 3        --Quantos hits o jogador irá levar, no máximo. 3 = 3 hits do Zombie.
    
    if getCreatureName(attacker) == "Event Zombie" and isInArea(getCreaturePosition(cid), amoebaZombie.fromPosition, amoebaZombie.toPosition) then
        if type == STATSCHANGE_HEALTHLOSS then
            if getPlayerStorageValue(cid, 834412) <= (max_hits - 2) then
                setPlayerStorageValue(cid, 834412, getPlayerStorageValue(cid, 834412) + 1)
            else
                local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
            end
        end
    end
    return true
end
aí depois, se funcionar
function onStatsChange(cid, attacker, type, combat, value)
 
    local artigo = getPlayerSex(cid) == 0 and "comida" or "comido"
    local max_hits = 3        --Quantos hits o jogador irá levar, no máximo. 3 = 3 hits do Zombie.
    
    if getCreatureName(attacker) == "Event Zombie" and isInArea(getCreaturePosition(cid), amoebaZombie.fromPosition, amoebaZombie.toPosition) then
        if type == STATSCHANGE_HEALTHLOSS then
            if getPlayerStorageValue(cid, 834412) <= (max_hits - 2) then
                setPlayerStorageValue(cid, 834412, getPlayerStorageValue(cid, 834412) + 1)
            else
                local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
                doBroadcastMessage(getPlayerName(cid) .." foi " .. artigo .. " pelos zombies!")
            end
        end
    end
    return true
end
e assim vai ._.

Editado Dezembro 23 por zipter98

KilluaK
24 de dezembro de 2013 às 03:45

Zipter eu não tenho idéia do pq de isso não ter funcionado, mas eu testei assim e funcionou certinho:


function onStatsChange(cid, attacker, type, combat, value)
    local artigo = getPlayerSex(cid) == 0 and "comida" or "comido"
    if isPlayer(cid) and getCreatureName(attacker) == "Event Zombie" and isInArea(getCreaturePosition(cid), amoebaZombie.fromPosition, amoebaZombie.toPosition) then
        if getPlayerStorageValue(cid, 28193) < 3 then
            doPlayerSetStorageValue(cid, 28193, getPlayerStorageValue(cid, 28193)+1)
        else
        if getGlobalStorageValue(amoebaZombie.playerStorage) > 2 then
            doPlayerSetStorageValue(cid, 28913, 0)
            setGlobalStorageValue(amoebaZombie.playerStorage, getGlobalStorageValue(amoebaZombie.playerStorage)-1)
            local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
            doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
            doBroadcastMessage(getPlayerName(cid) .." foi " .. artigo .. " pelos zombies!")
            doPlayerAddItem(cid, amoebaZombie.consolo[1], amoebaZombie.consolo[2])
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
        elseif getGlobalStorageValue(amoebaZombie.playerStorage) == 2 then
            setGlobalStorageValue(amoebaZombie.playerStorage, getGlobalStorageValue(amoebaZombie.playerStorage)-1)
            doPlayerSetStorageValue(cid, 28913, 0)
            local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
            doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(cid) .. ". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".")
            doBroadcastMessage(getPlayerName(cid) .." foi " .. artigo .. " pelos zombies!")
            doPlayerAddItem(cid, amoebaZombie.consolo[1], amoebaZombie.consolo[2])
            doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            addEvent(winZombieEvent, 1000)
            addEvent(removeZombies, 1000)
        end
        end
    end
    return true
end

Obrigado pela ajuda :)

zipter98Z
24 de dezembro de 2013 às 14:06

Opa, eu que agradeço por postar a resolução.

Sanado, movido.