Ir para conteúdo
  • 0

Modificação nesse zombie event


180319mu

Pergunta

Eu peguei um zombie event aqui no xtibia e funcionou perfeitamente, mas eu gostaria de fazer umas mudanças nele:

 

 

local config = {

playerCount = 2001, -- Global storage for counting the players left/entered in the event
goblet = 5805, -- id of the gold goblet you'll get when finishing the event.
rewards = {2159}, -- You will get this + a gold goblet with your name on.
-- {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
moneyReward = {2159, 10, 1},
-- Should be same as in the globalevent!
-- The zombies will spawn randomly inside this area
fromPosition = {x = 1150, y = 1024, z = 7}, -- top left cornor of the playground
toPosition = {x = 1178, y = 1040, z = 7}, -- bottom right cornor of the playground
}
function onStatsChange(cid, attacker, type, combat, value)
if isPlayer(cid) and isMonster(attacker) then
if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
if getGlobalStorageValue(config.playerCount) >= 2 then
doBroadcastMessage(getPlayerName(cid) .. " have been eated by Zombies!", MESSAGE_STATUS_CONSOLE_RED)
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")..".")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)-1)
elseif getGlobalStorageValue(config.playerCount) == 1 then
if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
doBroadcastMessage(getPlayerName(cid) .. " won the Zombie event! Congratulations!", MESSAGE_STATUS_WARNING)
local goblet = doPlayerAddItem(cid, config.goblet, 1)
doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
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")..".")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
for _,items in ipairs(config.rewards) do
doPlayerAddItem(cid, items, 1)
end
if config.moneyReward[3] == 1 then
doPlayerAddItem(cid, config.moneyReward[1], config.moneyReward[2])
end
end
for x = config.fromPosition.x, config.toPosition.x do
for y = config.fromPosition.y, config.toPosition.y do
for z = config.fromPosition.z, config.toPosition.z do
areapos = {x = x, y = y, z = z, stackpos = 253}
getMonsters = getThingfromPos(areapos)
if isMonster(getMonsters.uid) then
doRemoveCreature(getMonsters.uid)
end
end
end
end
end
return false
end
end
return true
end

Nesse script ai, quando o evento acaba, o player vencedor recebe uns premios e um trófeu de ouro com o nome dele, o problema é que a quantia em event coins (moeda vip do meu server) ta vindo num numero exato e eu queria que ela variasse entre 10~14, outra coisa que eu queria também é que o segundo/terceiro player também recebessem esses coins e troféis.
Alguem conseguiria modificar isso pra mim? agradeço
@Esse script que eu coloquei é apenas o creaturescript, onde pelo menos eu acho que é o lugar onde se deve fazer essas mudanças, caso precise mudar outra coisa no script todo o link do zombie event tá aqui.
Link para o comentário
Compartilhar em outros sites

11 respostass a esta questão

Posts Recomendados

  • 0



local config = {

playerCount = 2001, -- Global storage for counting the players left/entered in the event

 

goblet = 5805, -- id of the gold goblet you'll get when finishing the event.

rewards = {2159}, -- You will get this + a gold goblet with your name on.

-- {moneyId, count, using? 1 for using moneyReward, 0 for not using.}

moneyReward = {2159, 10, 1},

 

-- Should be same as in the globalevent!

-- The zombies will spawn randomly inside this area

fromPosition = {x = 1150, y = 1024, z = 7}, -- top left cornor of the playground

toPosition = {x = 1178, y = 1040, z = 7}, -- bottom right cornor of the playground

id_trofeis = {5805, 7370, 7371}, -- Bote os 3 id dos trofeis, separados por vírgula. Tem que ser em order (primeiro o de ouro, dps prata e dps bronze)

quant_points = {{10, 14}, {5, 9}, {1, 5}}

 

}

 

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

if isPlayer(cid) and isMonster(attacker) then

if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then

if getGlobalStorageValue(config.playerCount) >= 4 then

doBroadcastMessage(getPlayerName(cid) .. " have been eated by Zombies!", MESSAGE_STATUS_CONSOLE_RED)

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")..".")

doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

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

doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)

setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)-1)

elseif getGlobalStorageValue(config.playerCount) <= 3 then

if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then

 

local desc_ = getGlobalStorageValue(config.playerCount) == 3 and 2 or 3

if getGlobalStorageValue(config.playerCount) == 1 then

local goblet = doPlayerAddItem(cid, config.id_trofeis[1], 1)

doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")

else

local goblet = doPlayerAddItem(cid, config.id_trofeis[desc_], 1)

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

doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")

end

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")..".")

doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

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

doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)

for _,items in ipairs(config.rewards) do

doPlayerAddItem(cid, items, 1)

end

if getGlobalStorageValue(config.playerCount) == 1 then

doPlayerAddItem(cid, config.moneyReward[1], math.random(config.quant_points[1][1], config.quant_points[1][2]))

else

local quant = getGlobalStorageValue(config.playerCount) == 3 and math.random(config.quant_points[3][1], config.quant_points[3][2]) or math.random(config.quant_points[2][1], config.quant_points[2][2])

doPlayerAddItem(cid, config.moneyReward[1], quant)

end

end

if getGlobalStorageValue(config.playerCount) == 1 then

doBroadcastMessage(getPlayerName(cid) .. " won the Zombie event! Congratulations!", MESSAGE_STATUS_WARNING)

for x = config.fromPosition.x, config.toPosition.x do

for y = config.fromPosition.y, config.toPosition.y do

for z = config.fromPosition.z, config.toPosition.z do

areapos = {x = x, y = y, z = z, stackpos = 253}

getMonsters = getThingfromPos(areapos)

if isMonster(getMonsters.uid) then

doRemoveCreature(getMonsters.uid)

end

end

end

end

end

end

return false

end

end

return true

end

Link para o comentário
Compartilhar em outros sites

  • 0

Use assim mas preste atenção, vc deve configurar a tabela id_trofeis corretamente:


local config = {
    playerCount = 2001, -- Global storage for counting the players left/entered in the event
    
    goblet = 5805, -- id of the gold goblet you'll get when finishing the event.
    rewards = {2159}, -- You will get this +  a gold goblet with your name on.
    --        {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
    moneyReward = {2159, 10, 1},
    
    -- Should be same as in the globalevent!
    -- The zombies will spawn randomly inside this area
    fromPosition = {x = 1150, y = 1024, z = 7}, -- top left cornor of the playground
    toPosition = {x = 1178, y = 1040, z = 7}, -- bottom right cornor of the playground
    id_trofeis = {5805} -- Bote os 3 id dos trofeis, separados por vírgula. Tem que ser em order (primeiro o de ouro, dps prata e dps bronze)
    
    }
 
function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(cid) and isMonster(attacker) then
        if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
            if getGlobalStorageValue(config.playerCount) >= 4 then
                doBroadcastMessage(getPlayerName(cid) .. " have been eated by Zombies!", MESSAGE_STATUS_CONSOLE_RED)
                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")..".")
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)-1)
            elseif getGlobalStorageValue(config.playerCount) <= 3 then
                if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
                    doBroadcastMessage(getPlayerName(cid) .. " won the Zombie event! Congratulations!", MESSAGE_STATUS_WARNING)
                    local desc_ = getGlobalStorageValue(config.playerCount) == 3 and 2 or 3
                    if getGlobalStorageValue(config.playerCount) == 1 then
                        local goblet = doPlayerAddItem(cid, config.id_trofeis[1], 1)
                        doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
                    else
                        local goblet = doPlayerAddItem(cid, if_trofeis[desc_], 1)
                        local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                        doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
                    end
                    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")..".")
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                    doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                    for _,items in ipairs(config.rewards) do
                        doPlayerAddItem(cid, items, 1)
                    end
                    if config.moneyReward[3] == 1 then
                        doPlayerAddItem(cid, config.moneyReward[1], math.random(10, 14))
                    end
                end
                        
                for x = config.fromPosition.x, config.toPosition.x do
                    for y = config.fromPosition.y, config.toPosition.y do
                        for z = config.fromPosition.z, config.toPosition.z do
                            areapos = {x = x, y = y, z = z, stackpos = 253}
                            getMonsters = getThingfromPos(areapos)
                            if isMonster(getMonsters.uid) then
                                doRemoveCreature(getMonsters.uid)
                            end
                        end
                    end
                end
            end
            return false
        end
    end
return true
end
Link para o comentário
Compartilhar em outros sites

  • 0

Então, não funcionou cara, quando o zombie toca no player da a mensagem "Fulano won the zombie event" mas ele não é teleportado e nem ganha os items e aparece esse erro aqui:

 

[15/03/2014 10:15:27] [Error - CreatureScript Interface]
[15/03/2014 10:15:27] data/creaturescripts/scripts/zombieevent.lua:onStatsChange
[15/03/2014 10:15:27] Description:
[15/03/2014 10:15:27] data/creaturescripts/scripts/zombieevent.lua:36: attempt to index global 'if_trofeis' (a nil value)
[15/03/2014 10:15:27] stack traceback:
[15/03/2014 10:15:27] data/creaturescripts/scripts/zombieevent.lua:36: in function <data/creaturescripts/scripts/zombieevent.lua:17>
[15/03/2014 10:15:29] > Broadcasted message: "Knigh won the Zombie event! Congratulations!".
Aproposito, se esse tivesse funcionando como eu modificaria a quantidade de coin que o 1º/2º/3º iam ganhar? porque eu dei uma olhada ai e só achei o doPlayerAddItem(cid, config.moneyReward[1], math.random(10, 14)) e eu queria que fosse isso pro primeiro apenas, pros outros eu ia por outros valores menores.
@Edit como eu faço pra te dar REP+? não lembro como faz.
Editado por Chaos666
Link para o comentário
Compartilhar em outros sites

  • 0


local config = {

playerCount = 2001, -- Global storage for counting the players left/entered in the event


goblet = 5805, -- id of the gold goblet you'll get when finishing the event.

rewards = {2159}, -- You will get this + a gold goblet with your name on.

-- {moneyId, count, using? 1 for using moneyReward, 0 for not using.}

moneyReward = {2159, 10, 1},


-- Should be same as in the globalevent!

-- The zombies will spawn randomly inside this area

fromPosition = {x = 1150, y = 1024, z = 7}, -- top left cornor of the playground

toPosition = {x = 1178, y = 1040, z = 7}, -- bottom right cornor of the playground

id_trofeis = {5805, 7370, 7371} -- Bote os 3 id dos trofeis, separados por vírgula. Tem que ser em order (primeiro o de ouro, dps prata e dps bronze)


}


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

if isPlayer(cid) and isMonster(attacker) then

if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then

if getGlobalStorageValue(config.playerCount) >= 4 then

doBroadcastMessage(getPlayerName(cid) .. " have been eated by Zombies!", MESSAGE_STATUS_CONSOLE_RED)

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")..".")

doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

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

doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)

setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)-1)

elseif getGlobalStorageValue(config.playerCount) <= 3 then

if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then

doBroadcastMessage(getPlayerName(cid) .. " won the Zombie event! Congratulations!", MESSAGE_STATUS_WARNING)

local desc_ = getGlobalStorageValue(config.playerCount) == 3 and 2 or 3

if getGlobalStorageValue(config.playerCount) == 1 then

local goblet = doPlayerAddItem(cid, config.id_trofeis[1], 1)

doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")

else

local goblet = doPlayerAddItem(cid, id_trofeis[desc_], 1)

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

doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")

end

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")..".")

doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)

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

doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)

for _,items in ipairs(config.rewards) do

doPlayerAddItem(cid, items, 1)

end

if config.moneyReward[3] == 1 then

doPlayerAddItem(cid, config.moneyReward[1], math.random(10, 14))

end

end


for x = config.fromPosition.x, config.toPosition.x do

for y = config.fromPosition.y, config.toPosition.y do

for z = config.fromPosition.z, config.toPosition.z do

areapos = {x = x, y = y, z = z, stackpos = 253}

getMonsters = getThingfromPos(areapos)

if isMonster(getMonsters.uid) then

doRemoveCreature(getMonsters.uid)

end

end

end

end

end

return false

end

end

return true

end



Erro: [15/03/2014 13:04:02] [Error - CreatureScript Interface]

[15/03/2014 13:04:03] data/creaturescripts/scripts/zombieevent.lua:onStatsChange

[15/03/2014 13:04:03] Description:

[15/03/2014 13:04:03] data/creaturescripts/scripts/zombieevent.lua:36: attempt to index global 'id_trofeis' (a nil value)

[15/03/2014 13:04:03] stack traceback:

[15/03/2014 13:04:03] data/creaturescripts/scripts/zombieevent.lua:36: in function <data/creaturescripts/scripts/zombieevent.lua:17>


Quando eu disse que foi o mesmo erro, eh que so mudou o 'if_trofeis' pra 'id_trofeis'

Editado por Chaos666
Link para o comentário
Compartilhar em outros sites

  • 0

local config = {
    playerCount = 2001, -- Global storage for counting the players left/entered in the event
    
    goblet = 5805, -- id of the gold goblet you'll get when finishing the event.
    rewards = {2159}, -- You will get this +  a gold goblet with your name on.
    --        {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
    moneyReward = {2159, 10, 1},
    
    -- Should be same as in the globalevent!
    -- The zombies will spawn randomly inside this area
    fromPosition = {x = 1150, y = 1024, z = 7}, -- top left cornor of the playground
    toPosition = {x = 1178, y = 1040, z = 7}, -- bottom right cornor of the playground
    id_trofeis = {5805, 7370, 7371}, -- Bote os 3 id dos trofeis, separados por vírgula. Tem que ser em order (primeiro o de ouro, dps prata e dps bronze)
    quant_points = {{10, 14}, {8, 10}, {6, 8}} 
    
    }
 
function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(cid) and isMonster(attacker) then
        if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
            if getGlobalStorageValue(config.playerCount) >= 4 then
                doBroadcastMessage(getPlayerName(cid) .. " have been eated by Zombies!", MESSAGE_STATUS_CONSOLE_RED)
                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")..".")
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
                doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)-1)
            elseif getGlobalStorageValue(config.playerCount) <= 3 then
                if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
                    doBroadcastMessage(getPlayerName(cid) .. " won the Zombie event! Congratulations!", MESSAGE_STATUS_WARNING)
                    local desc_ = getGlobalStorageValue(config.playerCount) == 3 and 2 or 3
                    if getGlobalStorageValue(config.playerCount) == 1 then
                        local goblet = doPlayerAddItem(cid, config.id_trofeis[1], 1)
                        doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
                    else
                        local goblet = doPlayerAddItem(cid, config.id_trofeis[desc_], 1)
                        local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
                        doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
                    end
                    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")..".")
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
                    doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
                    doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
                    for _,items in ipairs(config.rewards) do
                        doPlayerAddItem(cid, items, 1)
                    end
                    if getGlobalStorageValue(config.playerCount) == 1 then
                        doPlayerAddItem(cid, config.moneyReward[1], math.random(config.quant_points[1][1], config.quant_points[1][2]))
                    else
                        local quant = getGlobalStorageValue(config.playerCount) == 3 and math.random(config.quant_ponts[3][1], config.quant_ponts[3][2]) or math.random(config.quant_ponts[2][1], config.quant_ponts[2][2])
                        doPlayerAddItem(cid, config.moneyReward[1], quant)
                    end
                end
                        
                for x = config.fromPosition.x, config.toPosition.x do
                    for y = config.fromPosition.y, config.toPosition.y do
                        for z = config.fromPosition.z, config.toPosition.z do
                            areapos = {x = x, y = y, z = z, stackpos = 253}
                            getMonsters = getThingfromPos(areapos)
                            if isMonster(getMonsters.uid) then
                                doRemoveCreature(getMonsters.uid)
                            end
                        end
                    end
                end
            end
            return false
        end
    end
return true
end

na tabela quant_points vc vai por, o tanto {minimo, maximo} de points que os vencedores podem ganhar. Em ordem, primeiro o q fica em primeiro lugar, depois em segundo etc

Link para o comentário
Compartilhar em outros sites

  • 0

Situação agora é a seguinte: Quando os players vão morrendo e chega na parte dos 3 ultimos, os que iriam ganhar os premios, eles ganham (1 coin e um troféu de prata [sempre esses items e valores]) e o evento não acaba, por mais que o player tenha morrido e ganhado os 1 coin~troféu, se eu puxa ele pra area do evento denovo, ele vai ganha o 1 coin e troféu denovo.. aifushfiiah

 

Erro:

[15/03/2014 17:46:00] [Error - CreatureScript Interface]
[15/03/2014 17:46:00] data/creaturescripts/scripts/zombieevent.lua:onStatsChange
[15/03/2014 17:46:00] Description:
[15/03/2014 17:46:00] data/creaturescripts/scripts/zombieevent.lua:51: attempt to index field 'quant_ponts' (a nil value)
[15/03/2014 17:46:00] stack traceback:
[15/03/2014 17:46:00] data/creaturescripts/scripts/zombieevent.lua:51: in function <data/creaturescripts/scripts/zombieevent.lua:18>
Script

local config = {
playerCount = 2001, -- Global storage for counting the players left/entered in the event
goblet = 5805, -- id of the gold goblet you'll get when finishing the event.
rewards = {2159}, -- You will get this + a gold goblet with your name on.
-- {moneyId, count, using? 1 for using moneyReward, 0 for not using.}
moneyReward = {2159, 10, 1},
-- Should be same as in the globalevent!
-- The zombies will spawn randomly inside this area
fromPosition = {x = 1150, y = 1024, z = 7}, -- top left cornor of the playground
toPosition = {x = 1178, y = 1040, z = 7}, -- bottom right cornor of the playground
id_trofeis = {5805, 7370, 7371}, -- Bote os 3 id dos trofeis, separados por vírgula. Tem que ser em order (primeiro o de ouro, dps prata e dps bronze)
quant_points = {{10, 14}, {5, 9}, {1, 5}}
}
function onStatsChange(cid, attacker, type, combat, value)
if isPlayer(cid) and isMonster(attacker) then
if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
if getGlobalStorageValue(config.playerCount) >= 4 then
doBroadcastMessage(getPlayerName(cid) .. " have been eated by Zombies!", MESSAGE_STATUS_CONSOLE_RED)
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")..".")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
setGlobalStorageValue(config.playerCount, getGlobalStorageValue(config.playerCount)-1)
elseif getGlobalStorageValue(config.playerCount) <= 3 then
if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then
doBroadcastMessage(getPlayerName(cid) .. " won the Zombie event! Congratulations!", MESSAGE_STATUS_WARNING)
local desc_ = getGlobalStorageValue(config.playerCount) == 3 and 2 or 3
if getGlobalStorageValue(config.playerCount) == 1 then
local goblet = doPlayerAddItem(cid, config.id_trofeis[1], 1)
doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
else
local goblet = doPlayerAddItem(cid, config.id_trofeis[desc_], 1)
local corpse = doCreateItem(3058, 1, getPlayerPosition(cid))
doItemSetAttribute(goblet, "description", "Awarded to " .. getPlayerName(cid) .. " for winning the Zombie event.")
end
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")..".")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), false)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_TELEPORT)
for _,items in ipairs(config.rewards) do
doPlayerAddItem(cid, items, 1)
end
if getGlobalStorageValue(config.playerCount) == 1 then
doPlayerAddItem(cid, config.moneyReward[1], math.random(config.quant_points[1][1], config.quant_points[1][2]))
else
local quant = getGlobalStorageValue(config.playerCount) == 3 and math.random(config.quant_ponts[3][1], config.quant_ponts[3][2]) or math.random(config.quant_ponts[2][1], config.quant_ponts[2][2])
doPlayerAddItem(cid, config.moneyReward[1], quant)
end
end
for x = config.fromPosition.x, config.toPosition.x do
for y = config.fromPosition.y, config.toPosition.y do
for z = config.fromPosition.z, config.toPosition.z do
areapos = {x = x, y = y, z = z, stackpos = 253}
getMonsters = getThingfromPos(areapos)
if isMonster(getMonsters.uid) then
doRemoveCreature(getMonsters.uid)
end
end
end
end
end
return false
end
end
return true
end

Desculpa tar enchendo tanto o teu saco com esse script, mas ta dificil viu.. fiuashfiu
Editado por Chaos666
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...