How to add text when you advance on skill

LordVissie

( ͡°( ͡° ͜ʖ( ͡° ͜ʖ ͡°) ͜ʖ ͡°) ͡°)
Joined
Aug 4, 2015
Messages
1,624
Reaction score
573
Location
The Earth
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:
OP
SixNine

SixNine

Member
Joined
Dec 12, 2018
Messages
175
Reaction score
8
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
 
OP
SixNine

SixNine

Member
Joined
Dec 12, 2018
Messages
175
Reaction score
8
Change "&&" to "and", did change the script in quite a rush haha
Doesnt send any text above player. SendTextMessage doesnt make sense how it should send text above player shouldnt it be
addAnimatedText("Axe Fighting", getPosition(), TEXTCOLOR_LIGHTGREEN);
so that way it would be possible to add colors too.
 

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,587
Reaction score
2,147
If you're not on a pre-9.7 client (or not using OTC) you can't use animated text.
player:say(text, TALKTYPE_MONSTER_SAY, false, nil, player:getPosition())
 
OP
SixNine

SixNine

Member
Joined
Dec 12, 2018
Messages
175
Reaction score
8
If you're not on a pre-9.7 client (or not using OTC) you can't use animated text.
player:say(text, TALKTYPE_MONSTER_SAY, false, nil, player:getPosition())
But you can use addAnimatedText("Axe Fighting", getPosition(), TEXTCOLOR_LIGHTGREEN); since im using it in source. And my client is 8.6
 

J.Dre

ClapSoft®
Joined
May 18, 2011
Messages
2,586
Reaction score
543
Location
United States
@SixNine I created this script back in 2013. It uses a custom animated text function (posted below). You may be able to use this within your script to send text as it was deprecated in TFS.

Lua:
local function doSendAnimatedText(pos, text, color, cid) -- by J.Dre
    if tonumber(text) then
        text = tonumber(text)
        if cid and isPlayer(cid) then
            doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
        else
            local t = getSpectators(pos, 7, 5, false)
            if t then
                for _, cid in ipairs(t) do
                    if isPlayer(cid) then
                        doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
                    end
                end
            end
        end
    else
        if cid and isCreature(cid) then
            doCreatureSay(cid, text, TALKTYPE_MONSTER)
        else
            local t = getSpectators(pos, 7, 5, false)
            if t then
                for _, cid in ipairs(t) do
                    if isPlayer(cid) then
                        doCreatureSay(cid, text, TALKTYPE_MONSTER, false, cid, pos)
                    end
                end
            end
        end
    end
end
 
OP
SixNine

SixNine

Member
Joined
Dec 12, 2018
Messages
175
Reaction score
8
@SixNine I created this script back in 2013. It uses a custom animated text function (posted below). You may be able to use this within your script to send text as it was deprecated in TFS.

Lua:
local function doSendAnimatedText(pos, text, color, cid) -- by J.Dre
    if tonumber(text) then
        text = tonumber(text)
        if cid and isPlayer(cid) then
            doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
        else
            local t = getSpectators(pos, 7, 5, false)
            if t then
                for _, cid in ipairs(t) do
                    if isPlayer(cid) then
                        doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
                    end
                end
            end
        end
    else
        if cid and isCreature(cid) then
            doCreatureSay(cid, text, TALKTYPE_MONSTER)
        else
            local t = getSpectators(pos, 7, 5, false)
            if t then
                for _, cid in ipairs(t) do
                    if isPlayer(cid) then
                        doCreatureSay(cid, text, TALKTYPE_MONSTER, false, cid, pos)
                    end
                end
            end
        end
    end
end
So this code goes in compact, but by using doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, TEXTCOLOR_LIGHTGREEN, pos) in code nothing happens
 
Top