• 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!

TFS 1.X+ Help Creature Event Storage

snuckles

New Member
Joined
Apr 4, 2009
Messages
37
Reaction score
2
Location
Hong Kong
Hello, need help to fix this script of "Creaturescripts", The script work perfectly, the problem is the next, When team-killing these creatures on the list, the storage count does not always count, since sometimes one player does more damage than another, I was investigating and the solution is to add the "Damage Type Map" function or something else for him. style and I have seen different scripts but I don't know how to add that function to this script, if you could help me thanks! I give REP and more ++

Lua:
local monsters = {
    --name = storage
    ["rotworm"] = 35001,
    ["zombies"] = 35002,
    ["the abomination"] = 35003,
    ["death priest shargon"] = 35004,
    ["the ravager"] = 35005,
    ["terofar"] = 35006,
    ["furyosa"] = 35007,
    ["deep protector"] = 35008,
    ["yakchal"] = 35009,
    ["horror tormentor"] = 35010,
    ["the keeper"] = 35011,
    ["devovorga"] = 35012,
    ["malthael"] = 35013,
      ["omrafir"] = 35014,
      ["cursed machine"] = 35015,
      ["battlemaster zunzu"] = 35016,
      ["demon oak"] = 35017,
      ["the devil [6]"] = 35018,
      ["king ferumbras"] = 35019,
      ["darkseid"] = 35020,
      ["tree of life"] = 35021,
      ["eclipse knight"] = 35022,
      ["triton"] = 35023,
      ["lord voldemort"] = 35024,
      ["darakan the executioner"] = 35025,
      ["valakas"] = 35026,
      ["prince drazzak"] = 35027,
    ["the gleam eyes"] = 35028,
    ["versperoth"] = 35029,
    ["obujos"] = 35030,
    ["tanjis"] = 35031,
    ["jaul"] = 35032,
    ["zushuka"] = 35033,
    ["enraged mother nature"] = 35034,
    ["micerinos"] = 35035,
    ["horestis"] = 35036,
    ["gloombringer"] = 35037,
    ["the frog prince"] = 35038,
    ["osama bin laden"] = 35039,
    ["ramses"] = 35040,
    ["osiris"] = 35041,
    ["mouldpincer"] = 35042,
    ["abyssal horror"] = 35043,
    ["grodd"] = 35044,
    ["isis"] = 35045,
}

function onKill(cid, target)
    if(isMonster(target) == TRUE) then
        local name = getCreatureName(target)
        local monster = monsters[string.lower(name)]
        if(monster) then
            local killedMonsters = getPlayerStorageValue(cid, monster)
            if(killedMonsters == -1) then
                killedMonsters = 1
            end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You Killed " .. killedMonsters .. " " .. name .. "s.")
            setPlayerStorageValue(cid, monster, killedMonsters + 1)
        end
    end
    return TRUE
end
 
Solution
something like this should work
Lua:
function onKill(cid, target)
    if(isMonster(target) == TRUE) then
        local name = getCreatureName(target)
        local monster = monsters[string.lower(name)]
        if(monster) then
for i,child in pairs(target:getDamageMap()) do
if isPlayer(i) then
            local killedMonsters = getPlayerStorageValue(i, monster)
            if(killedMonsters == -1) then
                killedMonsters = 0
            end
            setPlayerStorageValue(i, monster, killedMonsters + 1)
            doPlayerSendTextMessage(i, MESSAGE_STATUS_CONSOLE_BLUE, "You Killed " .. killedMonsters + 1.. " " .. name .. "s.")
end
end
        end
    end
    return TRUE
end
but if onKill is triggered on few players...
OP
OP
snuckles

snuckles

New Member
Joined
Apr 4, 2009
Messages
37
Reaction score
2
Location
Hong Kong
If that's the solution, the problem is that I don't know how to add it to this script, I need to know where I need to add it to make it work good.
 

Pawcio6

Member
Joined
Sep 26, 2009
Messages
143
Solutions
4
Reaction score
15
something like this should work
Lua:
function onKill(cid, target)
    if(isMonster(target) == TRUE) then
        local name = getCreatureName(target)
        local monster = monsters[string.lower(name)]
        if(monster) then
for i,child in pairs(target:getDamageMap()) do
if isPlayer(i) then
            local killedMonsters = getPlayerStorageValue(i, monster)
            if(killedMonsters == -1) then
                killedMonsters = 0
            end
            setPlayerStorageValue(i, monster, killedMonsters + 1)
            doPlayerSendTextMessage(i, MESSAGE_STATUS_CONSOLE_BLUE, "You Killed " .. killedMonsters + 1.. " " .. name .. "s.")
end
end
        end
    end
    return TRUE
end
but if onKill is triggered on few players upon single monster death it will be buged better would be to use
Code:
function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
but it will need additional event registration added in every monster.xml you specify in table
 
Last edited:
Solution
Top