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

How to add text when you advance on skill

SixNine

Active Member
Joined
Dec 12, 2018
Messages
442
Reaction score
40
Hello,
so i need something like this, when you advance on level or magic level or any axe fighting, sword fighting etc it would send text above player something like this i will fully explain
(Skill) (whats the text and colors)
Level up - Level (in green)
Magic Level - Magic Level (in random colors)
Axe Fighting - Axe Fighting (in green)
Sword Fighting - Sword Fighting (in green)
Club Fighting - Club Fighting (in green)
And etc with all those skills

TFS 1.2
 
Hello,
so i need something like this, when you advance on level or magic level or any axe fighting, sword fighting etc it would send text above player something like this i will fully explain
(Skill) (whats the text and colors)
Level up - Level (in green)
Magic Level - Magic Level (in random colors)
Axe Fighting - Axe Fighting (in green)
Sword Fighting - Sword Fighting (in green)
Club Fighting - Club Fighting (in green)
And etc with all those skills

TFS 1.2
Fastest way is by extendedopcodes, via server you must rebuild code...
 
by the way, its not possible to have colored text since client 9. something
9.7

Hello,
so i need something like this, when you advance on level or magic level or any axe fighting, sword fighting etc it would send text above player something like this i will fully explain
(Skill) (whats the text and colors)
Level up - Level (in green)
Magic Level - Magic Level (in random colors)
Axe Fighting - Axe Fighting (in green)
Sword Fighting - Sword Fighting (in green)
Club Fighting - Club Fighting (in green)
And etc with all those skills

TFS 1.2
Just use an onAdvance creaturescript and look at skill ids here and just send different text to player based on the skill id
 
9.7


Just use an onAdvance creaturescript and look at skill ids here and just send different text to player based on the skill id
Table index is nil
Lua:
local area, data = 
{
    {0, 1, 1, 1, 0},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {0, 1, 1, 1, 0}
},
{
    [SKILL_FIST] = 'FISTUP!',
    [SKILL_CLUB] = 'CLUBUP!',
    [SKILL_SWORD] = 'SWORDUP!',
    [SKILL_AXE] = 'AXEUP!',
    [SKILL_DISTANCE] = 'DISTANCEUP!',
    [SKILL_SHIELD] = 'SHIELDUP!',
    [SKILL_FISHING] = 'FISHINGUP!',
    [SKILL__MAGLEVEL] = 'MAGICUP!',
    [SKILL__LEVEL] = 'LEVELUP!'
}
  
function onAdvance(cid, skill, oldLevel, newLevel)
    doPlayerSave(cid)
    local center, data = {}, data[skill] --function doSendMagicEffectInArea of Mock
    center.y = math.floor(table.getn(area)/2)+1
    for y = 1, table.getn(area) do
        for x = 1, table.getn(area[y]) do
            if area[y][x] > 0 then
                center.x = math.floor(table.getn(area[y])/2)+1
                doSendMagicEffect({x=getThingPos(cid).x+x-center.x,y=getThingPos(cid).y+y-center.y,z= getThingPos(cid).z},math.random(28,30),cid)
            end
        end
    end    
    for i = 1, #data do
        addEvent(doSendAnimatedText, i*150, getThingPos(cid), data:sub(i,i), i%2 == 0 and TEXTCOLOR_RED or TEXTCOLOR_ORANGE)
    end
    return true
end
 
You can't get colored text in TFS 1.2 without extendedopcodes. You can use player:sendTextMessage('...') for just orange text above the player.
why don't you do something like this (This is without text just effects for different advance type):
Lua:
local skillTypes = {
    [SKILL_LEVEL] = 37,
    [SKILL_MAGLEVEL] = 12,
    [SKILL_FIST] = CONST_ME_BLOCKHIT,
    [SKILL_CLUB] = CONST_ME_GROUNDSHAKER,
    [SKILL_SWORD] = 4,
    [SKILL_AXE] = CONST_ME_DRAWBLOOD,
    [SKILL_DISTANCE] = CONST_ME_HOLYDAMAGE,
    [SKILL_SHIELD] = 35,
    [SKILL_FISHING] = CONST_ME_WATERSPLASH
}

local dirs = {
    {x = -1, y = -1}, -- Northwest
    {x = 1,  y = -1},   -- Northeast
    {x = 1,  y = 1},   -- Southeast
    {x = -1, y = 1},  -- Southwest
}

function onAdvance(player, skill, oldLevel, newLevel)
    local getSkill = skillTypes[skill]
    if getSkill then
        for i = 1, #dirs do
            local pos = player:getPosition()
            pos:sendMagicEffect(32)
            pos.y = pos.y + dirs[i].y
            pos.x = pos.x + dirs[i].x
            pos:sendMagicEffect(getSkill)
        end
    end
    return true
end

The code you posted isn't for TFS 1.2.
 
Last edited:
You can't get colored text in TFS 1.2 without extendedopcodes. You can use player:sendTextMessage('...') for just orange text above the player.
why don't you do something like this (This is without text just effects for different advance type):
Lua:
local skillTypes = {
    [SKILL_LEVEL] = 37,
    [SKILL_MAGLEVEL] = 12,
    [SKILL_FIST] = CONST_ME_BLOCKHIT,
    [SKILL_CLUB] = CONST_ME_GROUNDSHAKER,
    [SKILL_SWORD] = 4,
    [SKILL_AXE] = CONST_ME_DRAWBLOOD,
    [SKILL_DISTANCE] = CONST_ME_HOLYDAMAGE,
    [SKILL_SHIELD] = 35,
    [SKILL_FISHING] = CONST_ME_WATERSPLASH
}

local dirs = {
    {x = -1, y = -1}, -- Northwest
    {x = 1,  y = -1},   -- Northeast
    {x = 1,  y = 1},   -- Southeast
    {x = -1, y = 1},  -- Southwest
}

function onAdvance(player, skill, oldLevel, newLevel)
    local getSkill = skillTypes[skill]
    if getSkill then
        for i = 1, #dirs do
            local pos = player:getPosition()
            pos:sendMagicEffect(32)
            pos.y = pos.y + dirs[i].y
            pos.x = pos.x + dirs[i].x
            pos:sendMagicEffect(getSkill)
        end
    end
    return true
end

The code you posted isn't for TFS 1.2.
So something like this
Lua:
local skillTypes = {
    [SKILL_LEVEL] = 37,
    [SKILL_MAGLEVEL] = 12,
    [SKILL_FIST] = CONST_ME_BLOCKHIT,
    [SKILL_CLUB] = CONST_ME_GROUNDSHAKER,
    [SKILL_SWORD] = 4,
    [SKILL_AXE] = CONST_ME_DRAWBLOOD,
    [SKILL_DISTANCE] = CONST_ME_HOLYDAMAGE,
    [SKILL_SHIELD] = 35,
    [SKILL_FISHING] = CONST_ME_WATERSPLASH
}

local skillText = {
    [SKILL_FIST] = 'FISTUP!',
    [SKILL_CLUB] = 'CLUBUP!',
    [SKILL_SWORD] = 'SWORDUP!',
    [SKILL_AXE] = 'AXEUP!',
    [SKILL_DISTANCE] = 'DISTANCEUP!',
    [SKILL_SHIELD] = 'SHIELDUP!',
    [SKILL_FISHING] = 'FISHINGUP!',
    [SKILL__MAGLEVEL] = 'MAGICUP!',
    [SKILL__LEVEL] = 'LEVELUP!'
}

local dirs = {
    {x = -1, y = -1}, -- Northwest
    {x = 1,  y = -1},   -- Northeast
    {x = 1,  y = 1},   -- Southeast
    {x = -1, y = 1},  -- Southwest
}

function onAdvance(player, skill, oldLevel, newLevel)
    local getSkill = skillTypes[skill]
    if getSkill then
        for i = 1, #dirs do
            local pos = player:getPosition()
            pos:sendMagicEffect(32)
            pos.y = pos.y + dirs[i].y
            pos.x = pos.x + dirs[i].x
            pos:sendMagicEffect(getSkill)
            player:sendTextMessage("".. skillText ..""))
        end
    end
    return true
end
?
 
So something like this
Lua:
local skillTypes = {
    [SKILL_LEVEL] = 37,
    [SKILL_MAGLEVEL] = 12,
    [SKILL_FIST] = CONST_ME_BLOCKHIT,
    [SKILL_CLUB] = CONST_ME_GROUNDSHAKER,
    [SKILL_SWORD] = 4,
    [SKILL_AXE] = CONST_ME_DRAWBLOOD,
    [SKILL_DISTANCE] = CONST_ME_HOLYDAMAGE,
    [SKILL_SHIELD] = 35,
    [SKILL_FISHING] = CONST_ME_WATERSPLASH
}

local skillText = {
    [SKILL_FIST] = 'FISTUP!',
    [SKILL_CLUB] = 'CLUBUP!',
    [SKILL_SWORD] = 'SWORDUP!',
    [SKILL_AXE] = 'AXEUP!',
    [SKILL_DISTANCE] = 'DISTANCEUP!',
    [SKILL_SHIELD] = 'SHIELDUP!',
    [SKILL_FISHING] = 'FISHINGUP!',
    [SKILL__MAGLEVEL] = 'MAGICUP!',
    [SKILL__LEVEL] = 'LEVELUP!'
}

local dirs = {
    {x = -1, y = -1}, -- Northwest
    {x = 1,  y = -1},   -- Northeast
    {x = 1,  y = 1},   -- Southeast
    {x = -1, y = 1},  -- Southwest
}

function onAdvance(player, skill, oldLevel, newLevel)
    local getSkill = skillTypes[skill]
    if getSkill then
        for i = 1, #dirs do
            local pos = player:getPosition()
            pos:sendMagicEffect(32)
            pos.y = pos.y + dirs[i].y
            pos.x = pos.x + dirs[i].x
            pos:sendMagicEffect(getSkill)
            player:sendTextMessage("".. skillText ..""))
        end
    end
    return true
end
?
If it works, then yes.
 
it says that its too much ) but it doesnt matter i tried removing them and adding them.
You should do something like this:
Lua:
local skillTypes = {
    [SKILL_LEVEL] = [37, 'LEVELUP!'],
    [SKILL_MAGLEVEL] = [12, 'MAGICUP!'],
    [SKILL_FIST] = [CONST_ME_BLOCKHIT, 'FISTUP!'],
    [SKILL_CLUB] = [CONST_ME_GROUNDSHAKER, 'CLUBUP!'],
    [SKILL_SWORD] = [4, 'SWORDUP!'],
    [SKILL_AXE] = [CONST_ME_DRAWBLOOD, 'AXEUP!'],
    [SKILL_DISTANCE] = [CONST_ME_HOLYDAMAGE, 'DISTANCEUP!'],
    [SKILL_SHIELD] = [35, 'SHIELDUP!'],
    [SKILL_FISHING] = [CONST_ME_WATERSPLASH, 'FISHINGUP!']
}

local dirs = {
    {x = -1, y = -1}, -- Northwest
    {x = 1,  y = -1},   -- Northeast
    {x = 1,  y = 1},   -- Southeast
    {x = -1, y = 1},  -- Southwest
}

function onAdvance(player, skill, oldLevel, newLevel)
    local effect = skillTypes[skill][0]
    local text = skillTypes[skill][1]

    if effect && text then
        for i = 1, #dirs do
            local pos = player:getPosition()
            pos:sendMagicEffect(32)
            pos.y = pos.y + dirs[i].y
            pos.x = pos.x + dirs[i].x
            pos:sendMagicEffect(effect)
            player:sendTextMessage(text)
        end
    end
    return true
end

Didn't test it.
 
Last edited:
You should do something like this:
Lua:
local skillTypes = {
    [SKILL_LEVEL] = [37, 'LEVELUP!'],
    [SKILL_MAGLEVEL] = [12, 'MAGICUP!'],
    [SKILL_FIST] = [CONST_ME_BLOCKHIT, 'FISTUP!'],
    [SKILL_CLUB] = [CONST_ME_GROUNDSHAKER, 'CLUBUP!'],
    [SKILL_SWORD] = [4, 'SWORDUP!'],
    [SKILL_AXE] = [CONST_ME_DRAWBLOOD, 'AXEUP!'],
    [SKILL_DISTANCE] = [CONST_ME_HOLYDAMAGE, 'DISTANCEUP!'],
    [SKILL_SHIELD] = [35, 'SHIELDUP!'],
    [SKILL_FISHING] = [CONST_ME_WATERSPLASH, 'FISHINGUP!']
}

local dirs = {
    {x = -1, y = -1}, -- Northwest
    {x = 1,  y = -1},   -- Northeast
    {x = 1,  y = 1},   -- Southeast
    {x = -1, y = 1},  -- Southwest
}

function onAdvance(player, skill, oldLevel, newLevel)
    local effect = skillTypes[skill][0]
    local text = skillTypes[skill][1]

    if effect && text then
        for i = 1, #dirs do
            local pos = player:getPosition()
            pos:sendMagicEffect(32)
            pos.y = pos.y + dirs[i].y
            pos.x = pos.x + dirs[i].x
            pos:sendMagicEffect(effect)
            player:sendTextMessage(text)
        end
    end
    return true
end

Didn't test it.
Your code is having same error like mine
unexpected symbol near [ at line 2
 
Back
Top