• 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 Need changes in onAdvance script LUA

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
873
Solutions
2
Reaction score
49
TFS 1.2
I found this code in otland and im trying to do some changes but all i get is crach when i do something.
It uses these ones. Which one of them is green? Or it would be good to know which color they contain
C++:
enum SpeakClasses : uint8_t {
    TALKTYPE_SAY = 1,
    TALKTYPE_WHISPER = 2,
    TALKTYPE_YELL = 3,
    TALKTYPE_PRIVATE_PN = 4,
    TALKTYPE_PRIVATE_NP = 5,
    TALKTYPE_PRIVATE = 6,
    TALKTYPE_CHANNEL_Y = 7,
    TALKTYPE_CHANNEL_W = 8,
    TALKTYPE_RVR_CHANNEL = 9,
    TALKTYPE_RVR_ANSWER = 10,
    TALKTYPE_RVR_CONTINUE = 11,
    TALKTYPE_BROADCAST = 12,
    TALKTYPE_CHANNEL_R1 = 13, //red - #c text
    TALKTYPE_PRIVATE_RED = 14, //@name@text
    TALKTYPE_CHANNEL_O = 15, //@name@text
    TALKTYPE_CHANNEL_R2 = 17, //#d
    TALKTYPE_MONSTER_SAY = 19,
    TALKTYPE_MONSTER_YELL = 20,
};
Tried using these \/ but it crashed my server
C++:
enum MessageClasses : uint8_t {
    MESSAGE_STATUS_CONSOLE_RED = 18, /*Red message in the console*/
    MESSAGE_EVENT_ORANGE = 19, /*Orange message in the console*/
    MESSAGE_STATUS_CONSOLE_ORANGE = 20,  /*Orange message in the console*/
    MESSAGE_STATUS_WARNING = 21, /*Red message in game window and in the console*/
    MESSAGE_EVENT_ADVANCE = 22, /*White message in game window and in the console*/
    MESSAGE_EVENT_DEFAULT = 23, /*White message at the bottom of the game window and in the console*/
    MESSAGE_STATUS_DEFAULT = 24, /*White message at the bottom of the game window and in the console*/
    MESSAGE_INFO_DESCR = 25, /*Green message in game window and in the console*/
    MESSAGE_STATUS_SMALL = 26, /*White message at the bottom of the game window"*/
    MESSAGE_STATUS_CONSOLE_BLUE = 27, /*FIXME Blue message in the console*/
};

The original code
Lua:
local config = {
    [SKILL_LEVEL] = { "Level Up!", CONST_ME_CAKE },
    [SKILL_CLUB] = { "Club Up!", CONST_ME_FIREWORK_BLUE },
    [SKILL_AXE] = { "Axe Up!", CONST_ME_FIREWORK_RED },
    [SKILL_SWORD] = { "Sword Up!", CONST_ME_FIREWORK_YELLOW },
    [SKILL_DISTANCE] = { "Distance Up!", CONST_ME_ASSASSIN },
    [SKILL_SHIELD] = { "Shield Up!", CONST_ME_BLOCKHIT },
    [SKILL_FISHING] = { "Fishing Up!", CONST_ME_WATERSPLASH },
    [SKILL_FIST] = { "Fist Up!", CONST_ME_HITAREA },
    [SKILL_MAGLEVEL] = { "Magic Level Up!", CONST_ME_HEARTS }
}

local imageEffect = {
    {0, 0, 1, 0, 1, 0, 0},
    {0, 1, 0, 1, 0, 1, 0},
    {1, 0, 0, 0, 0, 0, 1},
    {1, 0, 0, 0, 0, 0, 1},
    {0, 1, 0, 0, 0, 1, 0},
    {0, 0, 1, 0, 1, 0, 0},
    {0, 0, 0, 1, 0, 0, 0}
}

function onAdvance(player, skill, oldLevel, newLevel)
    if oldLevel < newLevel then
        local info = config[skill]
        if info then
            player:say(info[1], TALKTYPE_MONSTER_SAY)
            local diff = math.ceil(#imageEffect[1] / 2)
            local position = player:getPosition() + Position(-diff, -diff, 0)
            for k, v in pairs(imageEffect) do
                for l, b in pairs(v) do
                    if b ~= 0 then
                        (position + Position(l, k, 0)):sendMagicEffect(info[2])
                    end
                end
            end
        end
    end
    return true
end

I would love to change three thinks
  • Change player:say to green and it would be best if table would look like this
    Lua:
    [SKILL_LEVEL] = { "Level Up!", CONST_ME_CAKE, TALKTYPE_MONSTER_SAY },
  • The text onAdvance could be animated if its possible like you advance and TEXT goes like up a little bit and disappears example CLICK HERE to make it more clear
  • And if possible not needed if you gain like 20 levels at once it spams it 20 times so it could send just one time not 20
 
Solution

I saw this thread a few weeks earlier but didn't want to poach on others work...
But seems the thread was abandoned... so 🤷‍♀️

Using this colour. https://github.com/ninjalulz/forgottenserver/blob/8.6/src/luascript.cpp#L1498
Using this function. https://github.com/ninjalulz/forgottenserver/blob/8.6/src/luascript.cpp#L4336

Lua:
local config = {
    --[skillType] = { "text", textColour, animationEffect}
    [SKILL_LEVEL]    = { "Level Up!",       TEXTCOLOR_LIGHTGREEN, CONST_ME_CAKE },
    [SKILL_CLUB]     = { "Club Up!",        TEXTCOLOR_LIGHTGREEN, CONST_ME_FIREWORK_BLUE },
    [SKILL_AXE]      = { "Axe Up!",         TEXTCOLOR_LIGHTGREEN, CONST_ME_FIREWORK_RED },
    [SKILL_SWORD]    = { "Sword Up!",       TEXTCOLOR_LIGHTGREEN, CONST_ME_FIREWORK_YELLOW }...
You can try this to change the message. I don't have time to look in to the other parts at the moment.

Change
Lua:
player:say(info[1], TALKTYPE_MONSTER_SAY)

To
Lua:
player:sendTextMessage(MESSAGE_INFO_DESCR, info[1])
 
You can try this to change the message. I don't have time to look in to the other parts at the moment.

Change
Lua:
player:say(info[1], TALKTYPE_MONSTER_SAY)

To
Lua:
player:sendTextMessage(MESSAGE_INFO_DESCR, info[1])
Nice, now left animation of this player:sendTextMessage so it would move up and disappear
 

I saw this thread a few weeks earlier but didn't want to poach on others work...
But seems the thread was abandoned... so 🤷‍♀️

Using this colour. https://github.com/ninjalulz/forgottenserver/blob/8.6/src/luascript.cpp#L1498
Using this function. https://github.com/ninjalulz/forgottenserver/blob/8.6/src/luascript.cpp#L4336

Lua:
local config = {
    --[skillType] = { "text", textColour, animationEffect}
    [SKILL_LEVEL]    = { "Level Up!",       TEXTCOLOR_LIGHTGREEN, CONST_ME_CAKE },
    [SKILL_CLUB]     = { "Club Up!",        TEXTCOLOR_LIGHTGREEN, CONST_ME_FIREWORK_BLUE },
    [SKILL_AXE]      = { "Axe Up!",         TEXTCOLOR_LIGHTGREEN, CONST_ME_FIREWORK_RED },
    [SKILL_SWORD]    = { "Sword Up!",       TEXTCOLOR_LIGHTGREEN, CONST_ME_FIREWORK_YELLOW },
    [SKILL_DISTANCE] = { "Distance Up!",    TEXTCOLOR_LIGHTGREEN, CONST_ME_ASSASSIN },
    [SKILL_SHIELD]   = { "Shield Up!",      TEXTCOLOR_LIGHTGREEN, CONST_ME_BLOCKHIT },
    [SKILL_FISHING]  = { "Fishing Up!",     TEXTCOLOR_LIGHTGREEN, CONST_ME_WATERSPLASH },
    [SKILL_FIST]     = { "Fist Up!",        TEXTCOLOR_LIGHTGREEN, CONST_ME_HITAREA },
    [SKILL_MAGLEVEL] = { "Magic Level Up!", TEXTCOLOR_LIGHTGREEN, CONST_ME_HEARTS }
}

--[[
TEXTCOLOR_BLUE
TEXTCOLOR_LIGHTGREEN
TEXTCOLOR_LIGHTBLUE
TEXTCOLOR_MAYABLUE
TEXTCOLOR_DARKRED
TEXTCOLOR_LIGHTGREY
TEXTCOLOR_SKYBLUE
TEXTCOLOR_PURPLE
TEXTCOLOR_RED
TEXTCOLOR_ORANGE
TEXTCOLOR_YELLOW
TEXTCOLOR_WHITE_EXP
--]]

local imageEffect = {
    {0, 0, 1, 0, 1, 0, 0},
    {0, 1, 0, 1, 0, 1, 0},
    {1, 0, 0, 0, 0, 0, 1},
    {1, 0, 0, 0, 0, 0, 1},
    {0, 1, 0, 0, 0, 1, 0},
    {0, 0, 1, 0, 1, 0, 0},
    {0, 0, 0, 1, 0, 0, 0}
}

function onAdvance(player, skill, oldLevel, newLevel)
    if oldLevel < newLevel then
        local info = config[skill]
        if info then
            local position = player:getPosition()
            Game.sendAnimatedText(info[1], position, info[2])
            local diff = math.ceil(#imageEffect[1] / 2)
            position = position + Position(-diff, -diff, 0)
            for k, v in pairs(imageEffect) do
                for l, b in pairs(v) do
                    if b ~= 0 then
                        (position + Position(l, k, 0)):sendMagicEffect(info[3])
                    end
                end
            end
        end
    end
    return true
end
 
Solution
I saw this thread a few weeks earlier but didn't want to poach on others work...
But seems the thread was abandoned... so 🤷‍♀️

Using this colour. https://github.com/ninjalulz/forgottenserver/blob/8.6/src/luascript.cpp#L1498
Using this function. https://github.com/ninjalulz/forgottenserver/blob/8.6/src/luascript.cpp#L4336

Lua:
local config = {
    --[skillType] = { "text", textColour, animationEffect}
    [SKILL_LEVEL]    = { "Level Up!",       TEXTCOLOR_LIGHTGREEN, CONST_ME_CAKE },
    [SKILL_CLUB]     = { "Club Up!",        TEXTCOLOR_LIGHTGREEN, CONST_ME_FIREWORK_BLUE },
    [SKILL_AXE]      = { "Axe Up!",         TEXTCOLOR_LIGHTGREEN, CONST_ME_FIREWORK_RED },
    [SKILL_SWORD]    = { "Sword Up!",       TEXTCOLOR_LIGHTGREEN, CONST_ME_FIREWORK_YELLOW },
    [SKILL_DISTANCE] = { "Distance Up!",    TEXTCOLOR_LIGHTGREEN, CONST_ME_ASSASSIN },
    [SKILL_SHIELD]   = { "Shield Up!",      TEXTCOLOR_LIGHTGREEN, CONST_ME_BLOCKHIT },
    [SKILL_FISHING]  = { "Fishing Up!",     TEXTCOLOR_LIGHTGREEN, CONST_ME_WATERSPLASH },
    [SKILL_FIST]     = { "Fist Up!",        TEXTCOLOR_LIGHTGREEN, CONST_ME_HITAREA },
    [SKILL_MAGLEVEL] = { "Magic Level Up!", TEXTCOLOR_LIGHTGREEN, CONST_ME_HEARTS }
}

--[[
TEXTCOLOR_BLUE
TEXTCOLOR_LIGHTGREEN
TEXTCOLOR_LIGHTBLUE
TEXTCOLOR_MAYABLUE
TEXTCOLOR_DARKRED
TEXTCOLOR_LIGHTGREY
TEXTCOLOR_SKYBLUE
TEXTCOLOR_PURPLE
TEXTCOLOR_RED
TEXTCOLOR_ORANGE
TEXTCOLOR_YELLOW
TEXTCOLOR_WHITE_EXP
--]]

local imageEffect = {
    {0, 0, 1, 0, 1, 0, 0},
    {0, 1, 0, 1, 0, 1, 0},
    {1, 0, 0, 0, 0, 0, 1},
    {1, 0, 0, 0, 0, 0, 1},
    {0, 1, 0, 0, 0, 1, 0},
    {0, 0, 1, 0, 1, 0, 0},
    {0, 0, 0, 1, 0, 0, 0}
}

function onAdvance(player, skill, oldLevel, newLevel)
    if oldLevel < newLevel then
        local info = config[skill]
        if info then
            local position = player:getPosition()
            Game.sendAnimatedText(info[1], position, info[2])
            local diff = math.ceil(#imageEffect[1] / 2)
            position = position + Position(-diff, -diff, 0)
            for k, v in pairs(imageEffect) do
                for l, b in pairs(v) do
                    if b ~= 0 then
                        (position + Position(l, k, 0)):sendMagicEffect(info[3])
                    end
                end
            end
        end
    end
    return true
end
Everything just perfect, but found a one problem noticed that CONST_ME_NONE crashes the server and it says on the client value cant be 0
 
Everything just perfect, but found a one problem noticed that CONST_ME_NONE crashes the server and it says on the client value cant be 0
change
Lua:
position = position + Position(-diff, -diff, 0)
for k, v in pairs(imageEffect) do
to
Lua:
position = position + Position(-diff, -diff, 0)
if info[3] == CONST_ME_NONE then
    return true
end
for k, v in pairs(imageEffect) do
 
Last edited:
Back
Top