• Congratulations to the OTLand January Mapping Competition Winner! The grand prize of Otland Premium goes to Andréew.
  • Sign up for February Mapping Competition! The prize includes Otland Premium time.
  • 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!

C++ [TFS 1.2] doSendMagicEffect and doSendAnimatedText

PRLOts

Member
Joined
Jun 24, 2017
Messages
116
Best answers
4
Reaction score
15
Hey Otland!

I have lil problem again with those crazy functions. In my previous TFS 0.3.6 there was a great function doSendMagicEffect and doSendAnimatedText. And I had sweet script, like this:

Lua:
local positions = {
[".VIP."] = {x = 1888, y = 1423, z = 5},
["Karmia"] = {x = 1104, y = 993, z = 6},
["Vip Arena"] = {x = 1069, y = 1096, z = 9},
["Facc Arena"] = {x = 1073, y = 1096, z = 9},
["Karmia"] = {x = 1081, y = 1093, z = 9},
["Heta"] = {x = 1082, y = 1093, z = 9},
["Premy"] = {x = 1083, y = 1093, z = 9},
["Desert"] = {x = 1084, y = 1093, z = 9},
["Inferno"] = {x = 1085, y = 1093, z = 9},
["Venore"] = {x = 1086, y = 1093, z = 9},
["Folda"] = {x = 1081, y = 1099, z = 9},
["Tiquanda"] = {x = 1081, y = 1100, z = 9},
["@[email protected]"] = {x = 1888, y = 1425, z = 8},
["*SHOP*"] = {x = 1891, y = 1424, z = 7},
["*BACK*"] = {x = 1721, y = 1553, z = 7},
["!BACK!"] = {x = 1780, y = 1547, z = 7},
["Amor"] = {x = 1081, y = 1101, z = 9},
["Trainers"] = {x = 1885, y = 1424, z = 7},
["Arena"] = {x = 1888, y = 1426, z = 6},
["Quests"] = {x = 1054, y = 1097, z = 9},
["Exp"] = {x = 1888, y = 1424, z = 7},
["!Quests!"] = {x = 1884, y = 1420, z = 7},
["TEST SERVER"] = {x = 1885, y = 1421, z = 8},
}
local effects = {39, 34}
function onThink(interval, lastExecution)
    for text, pos in pairs(positions) do
        doSendMagicEffect(pos, effects[math.random(1, #effects)])
        doSendAnimatedText(pos, text, math.random(1, 254))
    end
    return true
end
With this functions

doSendMagicEffect
doSendAnimatedText

And It looked like this:

magiceffect.png


When i copied this script in to my TFS I see this error:
errorrr.png

Question:

I saw answer in another thread but they fixed this only for numbers. What I did: I add into compact.lua this:

Lua:
function Player.sendMagicEffect(self, effect)
    self:getPosition():sendMagicEffect(effect)
    return true
end
And It seems to be fine with doSendMagicEffect but I still cant win with the doSendAnimatedText :( :( :( Anyone knows how to fix that?
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,342
Best answers
528
Reaction score
3,098
doSendAnimatedText is a deprecated (disapproved of) and cannot be used anymore due to client limitations (9.1+ clients can only send colored numbers, not text)
to do something similar to the old version (it will never be the same so you have to get used to this) you can use this function i made
Lua:
function Position.sendMessage(self, message, talktype)
    local specs = Game.getSpectators(self, false, true, 7, 7, 5, 5)
    if #specs > 0 then
        for i = 1, #specs do
            local player = specs[i]
            player:say(message, talktype or TALKTYPE_MONSTER_SAY, false, player, self)
        end
    end
end
put this in lib/core/position.lua
so now instead of calling doSendAnimatedText(pos, text, color), you do position:sendMessage(text, talktype)
here are the available talktypes for 1.x (found here: forgottenserver/const.h at master · otland/forgottenserver · GitHub)
Code:
TALKTYPE_SAY
TALKTYPE_WHISPER
TALKTYPE_YELL
TALKTYPE_PRIVATE_FROM
TALKTYPE_PRIVATE_TO
TALKTYPE_CHANNEL_Y
TALKTYPE_CHANNEL_O
TALKTYPE_PRIVATE_NP
TALKTYPE_PRIVATE_PN
TALKTYPE_BROADCAST
TALKTYPE_CHANNEL_R1
TALKTYPE_PRIVATE_RED_FROM
TALKTYPE_PRIVATE_RED_TO
TALKTYPE_MONSTER_SAY
TALKTYPE_MONSTER_YELL
TALKTYPE_CHANNEL_R2
TALKTYPE_CHANNEL_W
you will however also have to change the way your table works, using {} for positions is also deprecated, you have to use the Position(x, y, z) constructor to create a position object
here's an example:
Lua:
local positions = {
    [".VIP."] = Position(1888, 1423, 5),
    -- etc
}

local effects = {39, 34}

for text, position in pairs(positions) do
    position:sendMessage(text) -- default is TALKTYPE_MONSTER_SAY
    position:sendMagicEffect(effects[math.random(#effects)])
end
 

WibbenZ

Global Moderator
Staff member
Global Moderator
Joined
Oct 16, 2008
Messages
6,225
Best answers
224
Reaction score
1,182
Location
Sweden
doSendAnimatedText is a deprecated (disapproved of) and cannot be used anymore due to client limitations (9.1+ clients can only send colored numbers, not text)
to do something similar to the old version (it will never be the same so you have to get used to this) you can use this function i made
Lua:
function Position.sendMessage(self, message, talktype)
    local specs = Game.getSpectators(self, false, true, 7, 7, 5, 5)
    if #specs > 0 then
        for i = 1, #specs do
            local player = specs[i]
            player:say(message, talktype or TALKTYPE_MONSTER_SAY, false, player, self)
        end
    end
end
put this in lib/core/position.lua
so now instead of calling doSendAnimatedText(pos, text, color), you do position:sendMessage(text, talktype)
here are the available talktypes for 1.x (found here: forgottenserver/const.h at master · otland/forgottenserver · GitHub)
Code:
TALKTYPE_SAY
TALKTYPE_WHISPER
TALKTYPE_YELL
TALKTYPE_PRIVATE_FROM
TALKTYPE_PRIVATE_TO
TALKTYPE_CHANNEL_Y
TALKTYPE_CHANNEL_O
TALKTYPE_PRIVATE_NP
TALKTYPE_PRIVATE_PN
TALKTYPE_BROADCAST
TALKTYPE_CHANNEL_R1
TALKTYPE_PRIVATE_RED_FROM
TALKTYPE_PRIVATE_RED_TO
TALKTYPE_MONSTER_SAY
TALKTYPE_MONSTER_YELL
TALKTYPE_CHANNEL_R2
TALKTYPE_CHANNEL_W
you will however also have to change the way your table works, using {} for positions is also deprecated, you have to use the Position(x, y, z) constructor to create a position object
here's an example:
Lua:
local positions = {
    [".VIP."] = Position(1888, 1423, 5),
    -- etc
}

local effects = {39, 34}

for text, position in pairs(positions) do
    position:sendMessage(text) -- default is TALKTYPE_MONSTER_SAY
    position:sendMagicEffect(effects[math.random(#effects)])
end
Just remember that the Creature:say will remove w/e a player says, so avoid having a tp room full of effects, since players won't be able to talk in there.
 
OP
P

PRLOts

Member
Joined
Jun 24, 2017
Messages
116
Best answers
4
Reaction score
15
doSendAnimatedText is a deprecated (disapproved of) and cannot be used anymore due to client limitations (9.1+ clients can only send colored numbers, not text)
to do something similar to the old version (it will never be the same so you have to get used to this) you can use this function i made
Lua:
function Position.sendMessage(self, message, talktype)
    local specs = Game.getSpectators(self, false, true, 7, 7, 5, 5)
    if #specs > 0 then
        for i = 1, #specs do
            local player = specs[i]
            player:say(message, talktype or TALKTYPE_MONSTER_SAY, false, player, self)
        end
    end
end
put this in lib/core/position.lua
so now instead of calling doSendAnimatedText(pos, text, color), you do position:sendMessage(text, talktype)
here are the available talktypes for 1.x (found here: forgottenserver/const.h at master · otland/forgottenserver · GitHub)
Code:
TALKTYPE_SAY
TALKTYPE_WHISPER
TALKTYPE_YELL
TALKTYPE_PRIVATE_FROM
TALKTYPE_PRIVATE_TO
TALKTYPE_CHANNEL_Y
TALKTYPE_CHANNEL_O
TALKTYPE_PRIVATE_NP
TALKTYPE_PRIVATE_PN
TALKTYPE_BROADCAST
TALKTYPE_CHANNEL_R1
TALKTYPE_PRIVATE_RED_FROM
TALKTYPE_PRIVATE_RED_TO
TALKTYPE_MONSTER_SAY
TALKTYPE_MONSTER_YELL
TALKTYPE_CHANNEL_R2
TALKTYPE_CHANNEL_W
you will however also have to change the way your table works, using {} for positions is also deprecated, you have to use the Position(x, y, z) constructor to create a position object
here's an example:
Lua:
local positions = {
    [".VIP."] = Position(1888, 1423, 5),
    -- etc
}

local effects = {39, 34}

for text, position in pairs(positions) do
    position:sendMessage(text) -- default is TALKTYPE_MONSTER_SAY
    position:sendMagicEffect(effects[math.random(#effects)])
end

Thanks for reply, I add this:

Lua:
function Position.sendMessage(self, message, talktype)
    local specs = Game.getSpectators(self, false, true, 7, 7, 5, 5)
    if #specs > 0 then
        for i = 1, #specs do
            local player = specs[i]
            player:say(message, talktype or TALKTYPE_MONSTER_SAY, false, player, self)
        end
    end
end
into my lib/core/position.lua

and script look like this now:

Lua:
local positions = {

[".VIP."] = Position(1888, 1423, 5),
["Karmia"] = Position(1104,993,6),
["Vip Arena"] = Position(1069,1096,9),
["Facc Arena"] = Position(1073,1096,9),
["Karmia"] = Position(1081,1093,9),
["Heta"] = Position(1082,1093,9),
["Premy"] = Position(1083,1093,9),
["Desert"] = Position(1084,1093,9),
["Inferno"] = Position(1085,1093,9),
["Venore"] = Position(1086,1093,9),
["Folda"] = Position(1081,1099,9),
["Tiquanda"] = Position(1081,1100,9),
["@[email protected]"] = Position(1888,1425,8),
["*SHOP*"] = Position(1891,1424,7),
["*BACK*"] = Position(1721,1553,7),
["!BACK!"] = Position(1780,1547,7),
["Amor"] = Position(1081,1101,9),
["Trainers"] = Position(1885,1424,7),
["Arena"] = Position(1888,1426,6),
["Quests"] = Position(1054,1097,9),
["Exp"] = Position(1888,1424,7),
["!Quests!"] = Position(1884,1420,7),
["TEST SERVER"] = Position(1885,1421,8),

}
local effects = {39, 34}
for text, position in pairs(positions) do
    position:sendMessage(text) -- default is TALKTYPE_MONSTER_SAY
    position:sendMagicEffect(effects[math.random(#effects)])
end

But In console there is an error:

conmsollle.png
 

WibbenZ

Global Moderator
Staff member
Global Moderator
Joined
Oct 16, 2008
Messages
6,225
Best answers
224
Reaction score
1,182
Location
Sweden
Thanks for reply, I add this:

Lua:
function Position.sendMessage(self, message, talktype)
    local specs = Game.getSpectators(self, false, true, 7, 7, 5, 5)
    if #specs > 0 then
        for i = 1, #specs do
            local player = specs[i]
            player:say(message, talktype or TALKTYPE_MONSTER_SAY, false, player, self)
        end
    end
end
into my lib/core/position.lua

and script look like this now:

Lua:
local positions = {

[".VIP."] = Position(1888, 1423, 5),
["Karmia"] = Position(1104,993,6),
["Vip Arena"] = Position(1069,1096,9),
["Facc Arena"] = Position(1073,1096,9),
["Karmia"] = Position(1081,1093,9),
["Heta"] = Position(1082,1093,9),
["Premy"] = Position(1083,1093,9),
["Desert"] = Position(1084,1093,9),
["Inferno"] = Position(1085,1093,9),
["Venore"] = Position(1086,1093,9),
["Folda"] = Position(1081,1099,9),
["Tiquanda"] = Position(1081,1100,9),
["@[email protected]"] = Position(1888,1425,8),
["*SHOP*"] = Position(1891,1424,7),
["*BACK*"] = Position(1721,1553,7),
["!BACK!"] = Position(1780,1547,7),
["Amor"] = Position(1081,1101,9),
["Trainers"] = Position(1885,1424,7),
["Arena"] = Position(1888,1426,6),
["Quests"] = Position(1054,1097,9),
["Exp"] = Position(1888,1424,7),
["!Quests!"] = Position(1884,1420,7),
["TEST SERVER"] = Position(1885,1421,8),

}
local effects = {39, 34}
for text, position in pairs(positions) do
    position:sendMessage(text) -- default is TALKTYPE_MONSTER_SAY
    position:sendMagicEffect(effects[math.random(#effects)])
end

But In console there is an error:

View attachment 30460
You still have to add the function :p
Lua:
local positions = {
    [".VIP."] = Position(1888, 1423, 5),
    ["Karmia"] = Position(1104,993,6),
    ["Vip Arena"] = Position(1069,1096,9),
    ["Facc Arena"] = Position(1073,1096,9),
    ["Karmia"] = Position(1081,1093,9),
    ["Heta"] = Position(1082,1093,9),
    ["Premy"] = Position(1083,1093,9),
    ["Desert"] = Position(1084,1093,9),
    ["Inferno"] = Position(1085,1093,9),
    ["Venore"] = Position(1086,1093,9),
    ["Folda"] = Position(1081,1099,9),
    ["Tiquanda"] = Position(1081,1100,9),
    ["@[email protected]"] = Position(1888,1425,8),
    ["*SHOP*"] = Position(1891,1424,7),
    ["*BACK*"] = Position(1721,1553,7),
    ["!BACK!"] = Position(1780,1547,7),
    ["Amor"] = Position(1081,1101,9),
    ["Trainers"] = Position(1885,1424,7),
    ["Arena"] = Position(1888,1426,6),
    ["Quests"] = Position(1054,1097,9),
    ["Exp"] = Position(1888,1424,7),
    ["!Quests!"] = Position(1884,1420,7),
    ["TEST SERVER"] = Position(1885,1421,8),
}

function onThink(interval, lastExecution)
    local effects = {39, 34}
    for text, position in pairs(positions) do
        position:sendMessage(text) -- default is TALKTYPE_MONSTER_SAY
        position:sendMagicEffect(effects[math.random(#effects)])
    end

    return true
end
 
OP
P

PRLOts

Member
Joined
Jun 24, 2017
Messages
116
Best answers
4
Reaction score
15
You still have to add the function :p
Lua:
local positions = {
    [".VIP."] = Position(1888, 1423, 5),
    ["Karmia"] = Position(1104,993,6),
    ["Vip Arena"] = Position(1069,1096,9),
    ["Facc Arena"] = Position(1073,1096,9),
    ["Karmia"] = Position(1081,1093,9),
    ["Heta"] = Position(1082,1093,9),
    ["Premy"] = Position(1083,1093,9),
    ["Desert"] = Position(1084,1093,9),
    ["Inferno"] = Position(1085,1093,9),
    ["Venore"] = Position(1086,1093,9),
    ["Folda"] = Position(1081,1099,9),
    ["Tiquanda"] = Position(1081,1100,9),
    ["@[email protected]"] = Position(1888,1425,8),
    ["*SHOP*"] = Position(1891,1424,7),
    ["*BACK*"] = Position(1721,1553,7),
    ["!BACK!"] = Position(1780,1547,7),
    ["Amor"] = Position(1081,1101,9),
    ["Trainers"] = Position(1885,1424,7),
    ["Arena"] = Position(1888,1426,6),
    ["Quests"] = Position(1054,1097,9),
    ["Exp"] = Position(1888,1424,7),
    ["!Quests!"] = Position(1884,1420,7),
    ["TEST SERVER"] = Position(1885,1421,8),
}

function onThink(interval, lastExecution)
    local effects = {39, 34}
    for text, position in pairs(positions) do
        position:sendMessage(text) -- default is TALKTYPE_MONSTER_SAY
        position:sendMagicEffect(effects[math.random(#effects)])
    end

    return true
end
Haha, yee my bad sryyy im exhausted. Guys so far so good, it seems to be nice but XD

conmsollle.png
 
OP
P

PRLOts

Member
Joined
Jun 24, 2017
Messages
116
Best answers
4
Reaction score
15
that's what you'll have to deal with from now on
this is the only way to get the closest to doSendAnimatedText

Okk I will post when i will try to get similar effect to previous! Thanks for help and good night guys !
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,342
Best answers
528
Reaction score
3,098
Just remember that the Creature:say will remove w/e a player says, so avoid having a tp room full of effects, since players won't be able to talk in there.
huh?
 

WibbenZ

Global Moderator
Staff member
Global Moderator
Joined
Oct 16, 2008
Messages
6,225
Best answers
224
Reaction score
1,182
Location
Sweden
Spam it, atlest 5-6 effects then have 2 ppl trying to chat xD
The messages they send will be removed from the screen, just like if alot of ppl are spamming only the "latest" messages are shown.

It's works fine if no one is talking tho.
 
Top