• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Print killers

nanhuto

New Member
Joined
May 13, 2010
Messages
13
Reaction score
0
Hi guys, i'm trying to do script of a monster, and then i was wondering if it would be able to do a script who would print the names (like in deathList). Thing is, i probabily didn't wrote the code correctly (im newb in lua).
Basically, what i wanted to do is to give storage for all players who hitted the monster. The creaturescript comes with a kill event, i seted for death. When i tryed to print it, it didnt work, probably because i didnt wrote it correct.
Here is the script:

Code:
local bossForms = {
    ['snake god essence'] = {
        text = 'IT\'S NOT THAT EASY MORTALS! FEEL THE POWER OF THE GOD!',
        newForm = 'snake thing'
    },
    ['snake thing'] = {
        text = 'NOOO! NOW YOU HERETICS WILL FACE MY GODLY WRATH!',
        newForm = 'lizard abomination'
    },
    ['lizard abomination'] = {
        text = 'YOU ... WILL ... PAY WITH ETERNITY ... OF AGONY!',
        newForm = 'mutated zalamon'
    }
}

function onDeath(cid, target, deathList)

    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() == 'mutated zalamon' then
        player:say('texte', TALKTYPE_MONSTER_SAY)   
        return true
    end
   


   
   


end



function onKill(player, target)
    local targetMonster = target:getMonster()
    if not targetMonster then
        return true
    end

    if targetMonster:getName():lower() == 'mutated zalamon' then
        player:say('texte', TALKTYPE_MONSTER_SAY)
        Game.setStorageValue(Storage.WrathoftheEmperor.Mission11, -1)
        return true
    end

    local bossConfig  = bossForms[targetMonster:getName():lower()]
    if not bossConfig then
        player:say('texte', TALKTYPE_MONSTER_SAY)
        return true
    end

    Game.createMonster(bossConfig.newForm, targetMonster:getPosition(), false, true)
    player:say(bossConfig.text, TALKTYPE_MONSTER_SAY)
    return true
end
 
Game.setStorageValue is a global storage, which has nothing to do with the player, player:setStorageValue is used for the player.
 
You can use getDamageMap() to search through the attackers of the creature and give them a storage value:

Code:
for pid, damage in pairs(targetMonster:getDamageMap()) do
    local dude = Player(pid)
    if dude then
        dude:setStorageValue(12345, 1)
    end
end
 
Game.setStorageValue is a global storage, which has nothing to do with the player, player:setStorageValue is used for the player.
Thanks for the explanation, its already something. I wanna know if that part of the code is correct:

Code:
function onDeath(cid, target, deathList)

local targetMonster = target:getMonster()
if not targetMonster then
return true
end

if targetMonster:getName():lower() == 'mutated zalamon' then
player:say('texte', TALKTYPE_MONSTER_SAY)
return true
end







end
If not, what i can do to print whatever i wanna when it dies? Thanks.
 
You can use getDamageMap() to search through the attackers of the creature and give them a storage value:

Code:
for pid, damage in pairs(targetMonster:getDamageMap()) do
    local dude = Player(pid)
    if dude then
        dude:setStorageValue(12345, 1)
    end
end

That sounds good, could i really ask something dumb? I know for is a loop, but whas is PID?
 
The variable identifiers don't mean anything in particular, its the values they hold, cid could just as easily be labeled farfenugen.
Oh, thanks. Lets say i wanna make (when the monster days) that it print out something (like the list of the killers), how could i do it? Is onDeath the correct function for it?
 
Back
Top