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

Most Creature

lopez65

Member
Joined
May 10, 2012
Messages
289
Solutions
1
Reaction score
14
Location
Barcelona
SOLVED

hello outlanders
could someone help me convert this script and the TFS version 1.2, it is that this does not work, and I'm really bad when it refers to scripts: D

Code:
--[[ Script by slawkens, modified by Zonet]]--

local monsters = {
["dragon"] = 9541,
["dragon lord"] = 9542,
["frost dragon"] = 9543,
["wyrm"] = 9544,
["demon"] = 9545,
["troll"] = 9546,
["troll champion"] = 9547,
["swamp troll"] = 9548,
["frost troll"] = 9549,
["rotworm"] = 9550,
["carrion worm"] = 9551,
}

function onKill(cid, target)
if(isPlayer(target) ~= true and isPlayer(cid)) then
local name = getCreatureName(target)
local monster = monsters[string.lower(name)]
if(monster) then
local killedMonsters = getPlayerStorageValue(cid, monster)
if(killedMonsters < 0) then
killedMonsters = 1
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " " .. name .. "'s.")
setPlayerStorageValue(cid, monster, killedMonsters + 1)
end
end
return true
end

thanx
 
Last edited:
Code:
local monsters = {
    ["dragon"] = 9541,
    ["dragon lord"] = 9542,
    ["frost dragon"] = 9543,
    ["wyrm"] = 9544,
    ["demon"] = 9545,
    ["troll"] = 9546,
    ["troll champion"] = 9547,
    ["swamp troll"] = 9548,
    ["frost troll"] = 9549,
    ["rotworm"] = 9550,
    ["carrion worm"] = 9551,
}

function onKill(creature, target)
    if target:isMonster() and creature:isPlayer() then
        local monster = monsters[target:getName():lower()]
        if monster then
            local killedMonsters = creature:getStorageValue(monster)
            if(killedMonsters < 0) then
                killedMonsters = 1
            end
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " " .. name .. "'s.")
            creature:setStorageValue(monster, killedMonsters + 1)
        end
    end
    return true
end
 
Code:
local monsters = {
    ["dragon"] = 9541,
    ["dragon lord"] = 9542,
    ["frost dragon"] = 9543,
    ["wyrm"] = 9544,
    ["demon"] = 9545,
    ["troll"] = 9546,
    ["troll champion"] = 9547,
    ["swamp troll"] = 9548,
    ["frost troll"] = 9549,
    ["rotworm"] = 9550,
    ["carrion worm"] = 9551,
}

function onKill(creature, target)
    if target:isMonster() and creature:isPlayer() then
        local monster = monsters[target:getName():lower()]
        if monster then
            local killedMonsters = creature:getStorageValue(monster)
            if(killedMonsters < 0) then
                killedMonsters = 1
            end
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " " .. name .. "'s.")
            creature:setStorageValue(monster, killedMonsters + 1)
        end
    end
    return true
end
Thanks for your help, but I have not tried out the text in orange when I kill monsters, and besides, you could put me in the code that will creaturescripts.xml and login.lua ?.
Greetings and thanks again
 
would it be possible to add all your monsters in a table like this somehow?
would make it lots easier to use and better :p
 
would it be possible to add all your monsters in a table like this somehow?
would make it lots easier to use and better :p
Simply modify this parser I made.
https://otland.net/threads/parsers-for-1-2.238198/
Something like this,
Code:
    local data = {
        ['monster'] = {'name', 'nameDescription', 'race', 'experience', 'speed', 'manacost', 'skull', 'script'},
        ['health'] = {'min', 'max'},
        ['look'] =  { 'type', 'head', 'body', 'legs', 'feet', 'corpse', 'addons', 'typeex', 'mount'},
        ['targethange'] = { 'interval', 'chance', 'speed'},
        ['flag'] = {'summonable', 'attackable', 'hostile', 'illusionable', 'convinceable', 'pushable', 'canpushitems',
        'canpushcreatures', 'staticattack', 'lightlevel', 'lightcolor', 'targetdistance', 'runonhealth', 'hidehealth'},
        ['attack'] = {'name', 'interval', 'min', 'max', 'range', 'chance'},
        ['attribute'] = {'key', 'value'},
        ['defenses'] ={'armor', 'defense'},
        ['element'] = {'physicalPercent', 'icePercent', 'poisonPercent', 'earthPercent', 'firePercent', 'energyPercent',
        'holyPercent', 'deathPercent', 'drownPercent', 'lifedrainPercent', 'manadrainPercent'},
        ['immunity'] = {'name', 'physical', 'energy', 'fire', 'poison', 'earth', 'drown', 'ice', 'holy', 'death',
        'lifedrain', 'manadrain', 'paralyze', 'outfit', 'drunk', 'invisible', 'invisibility', 'bleed'},
        ['voices'] = {'speed', 'interval', 'chance', 'sentence', 'yell'},
        ['voice'] = {'speed', 'interval', 'chance', 'sentence', 'yell'},
        ['summons'] = {'maxSummons'},
        ['summon'] = {'name','interval','chance','speed'},
        ['script'] = {'name'},
        ['item'] = {'id','countmax','chance', 'chance1', 'subtype', 'actionId', 'text'}
    }


    local dir = 'data/monster/'
    local file = 'monsters.xml'

    local counter = 9540

    local lookfor = 'name'
    for line in io.lines(dir..file) do
        if string.match(line, '<(%a-)%s* ') ~= nil then
           for lines in io.lines(dir..line:match('file="(.-)"') ) do
                if string.match(lines, '<(%a-)%s* ') ~= nil then
                    local p = data[string.match(lines, '<(%a-)%s* ')]
                    if p ~= nil then
                        for i = 1, #p do
                            if lookfor == p[i] and string.match(lines, '<(%a-)%s* ') == 'monster' then
                                local t = lines:match(p[i]..'="(.-)"')
                                if t ~= nil then
                                    counter = counter + 1
                                    print('["'..t..'"] = '..counter..',')
                                end
                            end
                        end
                    end
                end
           end
        end
    end
Output:
http://pastebin.com/fqa8QNEX
 
Simply modify this parser I made.
https://otland.net/threads/parsers-for-1-2.238198/
Something like this,
Code:
    local data = {
        ['monster'] = {'name', 'nameDescription', 'race', 'experience', 'speed', 'manacost', 'skull', 'script'},
        ['health'] = {'min', 'max'},
        ['look'] =  { 'type', 'head', 'body', 'legs', 'feet', 'corpse', 'addons', 'typeex', 'mount'},
        ['targethange'] = { 'interval', 'chance', 'speed'},
        ['flag'] = {'summonable', 'attackable', 'hostile', 'illusionable', 'convinceable', 'pushable', 'canpushitems',
        'canpushcreatures', 'staticattack', 'lightlevel', 'lightcolor', 'targetdistance', 'runonhealth', 'hidehealth'},
        ['attack'] = {'name', 'interval', 'min', 'max', 'range', 'chance'},
        ['attribute'] = {'key', 'value'},
        ['defenses'] ={'armor', 'defense'},
        ['element'] = {'physicalPercent', 'icePercent', 'poisonPercent', 'earthPercent', 'firePercent', 'energyPercent',
        'holyPercent', 'deathPercent', 'drownPercent', 'lifedrainPercent', 'manadrainPercent'},
        ['immunity'] = {'name', 'physical', 'energy', 'fire', 'poison', 'earth', 'drown', 'ice', 'holy', 'death',
        'lifedrain', 'manadrain', 'paralyze', 'outfit', 'drunk', 'invisible', 'invisibility', 'bleed'},
        ['voices'] = {'speed', 'interval', 'chance', 'sentence', 'yell'},
        ['voice'] = {'speed', 'interval', 'chance', 'sentence', 'yell'},
        ['summons'] = {'maxSummons'},
        ['summon'] = {'name','interval','chance','speed'},
        ['script'] = {'name'},
        ['item'] = {'id','countmax','chance', 'chance1', 'subtype', 'actionId', 'text'}
    }


    local dir = 'data/monster/'
    local file = 'monsters.xml'

    local counter = 9540

    local lookfor = 'name'
    for line in io.lines(dir..file) do
        if string.match(line, '<(%a-)%s* ') ~= nil then
           for lines in io.lines(dir..line:match('file="(.-)"') ) do
                if string.match(lines, '<(%a-)%s* ') ~= nil then
                    local p = data[string.match(lines, '<(%a-)%s* ')]
                    if p ~= nil then
                        for i = 1, #p do
                            if lookfor == p[i] and string.match(lines, '<(%a-)%s* ') == 'monster' then
                                local t = lines:match(p[i]..'="(.-)"')
                                if t ~= nil then
                                    counter = counter + 1
                                    print('["'..t..'"] = '..counter..',')
                                end
                            end
                        end
                    end
                end
           end
        end
    end
Output:
http://pastebin.com/fqa8QNEX

nice man! ill use this for now :p
 
Last edited:
Back
Top