• 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 mw timer for tfs 1.4/1.5

johnsamir

Advanced OT User
Joined
Oct 13, 2009
Messages
967
Solutions
6
Reaction score
166
Location
Nowhere
I have been looking for this the whole day have researched several threads with the scripts but none of them seems to be working, i commented an old thread and my post was deleted

can somebody script this for me please?
 
yup tested it and it's not working
i can use mwall normally but i get no timer. as i've stated i have tested many scripts from many threads none of the scripts seems to be working
 
Lua:
--[[SevuEntertainment(c)]]--
local recAnimateText = false
local startSeconds = 20

local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
combat:setParameter(COMBAT_PARAM_CREATEITEM, ITEM_MAGICWALL)

mwCountDownStart = function(position, seconds)
    local spectators = Game.getSpectators(position, false, true, 7, 7, 7, 7)
    if #spectators > 0 then
        if not recAnimateText then
            Creature.say(spectators[1], seconds, TALKTYPE_MONSTER_SAY, false, nil, position)
        else
            Player.sendTextMessage(spectators[1], MESSAGE_EXPERIENCE_OTHERS, nil, position, seconds, TEXTCOLOR_MAYABLUE)
        end
    end
    if seconds > 0 then
        addEvent(mwCountDownStart, 1000, position, seconds -1)
    end
end

function onCastSpell(creature, variant, isHotkey)
    if combat:execute(creature, variant) then
        mwCountDownStart(Variant.getPosition(variant), startSeconds)
        return true
    end
    return false
end

XML:
<rune name="Magic Wall" id="2294" allowfaruse="1" charges="3" lvl="16" maglv="9" exhaustion="0" blocktype="all" script="support/magic wall rune.lua"/>
1706833545475.png
 
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
combat:setParameter(COMBAT_PARAM_CREATEITEM, ITEM_MAGICWALL)


local time = 20

local function countDown(cid, position, time)
    local player = Player(cid)
    if not player or time == 0 then
        return
    end
    
    player:say(time, TALKTYPE_MONSTER_SAY, false, 0, position)
    addEvent(countDown, 1000, cid, position, time - 1)
end

function onCastSpell(creature, variant, isHotkey)
    countDown(creature.uid, Variant.getPosition(variant), 20)
    return combat:execute(creature, variant)
end
 
tested both, none of them seems to be working :/ what might be wrong

something seems to be wrong in const.h?
Lua:
/};
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,
};

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*/
    MESSAGE_MARKET = 42, // Window "Market Message" + "Ok" button
};
i use tfs 1.4 /1.5 it was 7.72 i upgraded it to 8.6
got this error in client console
ERROR: Unable to send extended opcode 201, extended opcodes are not enabled on this server.
but i have opcodes enabled
something might be missing?
have this at compat.lua
function doSendAnimatedText(message, position, color) return Game.sendAnimatedText(message, position, color) end
and im sure i added sendanimatedtext seems it's working

edit: nvm i was editing the wrong file LMFAO
 
Last edited:
show me your xml, how did you register?
bro nvm i was editing worng file. omg how can i be so stupid, it works thank you
Post automatically merged:

@Mateus Robeerto how do i change the message to red /purple sky but ?
i tried for example to change it to yellow using TALKTYPE_SAY but it displays the player name as it were talking
 
Last edited:
This is
local recAnimateText = false
local startSeconds = 20

local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
combat:setParameter(COMBAT_PARAM_CREATEITEM, ITEM_MAGICWALL)

mwCountDownStart = function(position, seconds)
local spectators = Game.getSpectators(position, false, true, 7, 7, 7, 7)
if #spectators > 0 then
if not recAnimateText then
Creature.say(spectators[1], seconds, TALKTYPE_MONSTER_SAY, false, nil, position)
else
Player.sendTextMessage(spectators[1], MESSAGE_EXPERIENCE_OTHERS, nil, position, seconds, TEXTCOLOR_MAYABLUE)
end
end
if seconds > 0 then
addEvent(mwCountDownStart, 1000, position, seconds -1)
end
end

function onCastSpell(creature, variant, isHotkey)
if combat:execute(creature, variant) then
mwCountDownStart(Variant.getPosition(variant), startSeconds)
return true
end
return false
end
 
look for this line;
Lua:
mwCountDownStart = function(position, seconds)
    local spectators = Game.getSpectators(position, false, true, 7, 7, 7, 7)
    if #spectators > 0 then
        if not recAnimateText then
            Creature.say(spectators[1], seconds, TALKTYPE_MONSTER_SAY, false, nil, position)
        else
            Player.sendTextMessage(spectators[1], MESSAGE_EXPERIENCE_OTHERS, nil, position, seconds, TEXTCOLOR_MAYABLUE)
        end
    end
    if seconds > 0 then
        addEvent(mwCountDownStart, 1000, position, seconds -1)
    end
end
change to.
Lua:
mwCountDownStart = function(position, seconds)
    local spectators = Game.getSpectators(position, false, true, 7, 7, 7, 7)
    if #spectators > 0 then
        for _, spectator in ipairs(spectators) do
            local animatedText = tostring(seconds)
            Game.sendAnimatedText(animatedText, position, 180) --- color red here
        end
    end
    if seconds > 0 then
        addEvent(mwCountDownStart, 1000, position, seconds - 1)
    end
end

the colors are available: I put 180 which is red.. if you want purple and just try putting a number or name both work well.
Lua:
COLOR_BLACK = 0
COLOR_BLUE = 5
COLOR_BROWN = 120
COLOR_CADETBLUE = 100
COLOR_CORAL = 200
COLOR_CRIMSON = 188
COLOR_CYAN = 35
COLOR_DARKBLUE = 3
COLOR_DARKBROWN = 78
COLOR_DARKCYAN = 21
COLOR_DARKGOLD = 163
COLOR_DARKGREEN = 12
COLOR_DARKKHAKI = 171
COLOR_DARKMAGENTA = 75
COLOR_DARKOLIVEGREEN = 91
COLOR_DARKORANGE = 156
COLOR_DARKORCHID = 118
COLOR_DARKPINK = 152
COLOR_DARKPURPLE = 112
COLOR_DARKRED = 108
COLOR_DARKSEAGREEN = 135
COLOR_DARKSLATEBLUE = 87
COLOR_DARKSLATEGREY = 50
COLOR_DARKVIOLET = 113
COLOR_DEEPPINK = 189
COLOR_DEEPSKYBLUE = 29
COLOR_DODGERBLUE = 59
COLOR_FIREBRICK = 151
COLOR_FORESTGREEN = 55
COLOR_FUCHSIA = 185
COLOR_GOLD = 205
COLOR_GREY = 129
COLOR_GREEN = 18
COLOR_HOTPINK = 202
COLOR_KHAKI = 213
COLOR_LAWNGREEN = 138
COLOR_LIGHTAQUA = 64
COLOR_LIGHTBLUE = 89
COLOR_LIGHTGREEN = 66
COLOR_LIGHTORANGE = 204
COLOR_LIGHTSLATEGREY = 129
COLOR_LIGHTSTEELBLUE = 173
COLOR_LIME = 30
COLOR_LIMEGREEN = 67
COLOR_MEDIUMAQUAMARINE = 106
COLOR_MEDIUMORCHID = 161
COLOR_MEDIUMSEAGREEN = 99
COLOR_MEDIUMSLATEBLUE = 131
COLOR_MEDIUMSPRINGGREEN = 34
COLOR_MEDIUMVIOLET = 153
COLOR_MIDNIGHTBLUE = 45
COLOR_OLIVE = 126
COLOR_ORANGE = 198
COLOR_ORANGERED = 192
COLOR_ORCHID = 203
COLOR_PALEGREEN = 141
COLOR_PALEPINK = 208
COLOR_PINK = 190
COLOR_PURPLE = 154
COLOR_RED = 180
COLOR_ROSYBROWN = 165
COLOR_ROYALBLUE = 95
COLOR_SADDLEBROWN = 121
COLOR_SALMON = 201
COLOR_SANDYBROWN = 206
COLOR_SEAGREEN = 56
COLOR_SIENNA = 157
COLOR_SILVER = 172
COLOR_SKYBLUE = 21
COLOR_SLATEBLUE = 125
COLOR_SLATEGREY = 129
COLOR_SPRINGGREEN = 33
COLOR_STEELBLUE = 94
COLOR_TAN = 207
COLOR_TEAL = 143
COLOR_THISTLE = 209
COLOR_TOMATO = 194
COLOR_TURQUOISE = 107
COLOR_VIOLET = 119
COLOR_WHITE = 215
COLOR_YELLOW = 210
COLOR_YELLOWGREEN = 175
COLOR_NONE = 255
1707061095609.png
 
up would be possible to add the name of the player that used the mwall in animated text too?
and maybe add multiple color like changing? you made an script a time ago that does that
Code:
local globalevent = GlobalEvent("positionandtext")
local textcolors = {5, 30, 35, 95, 108, 129, 143, 155, 180, 198, 210, 215}

local effects = {
    {position = Position(32366, 32235, 7), text = 'Training Monks!', effect = CONST_ME_BATS},
    --{position = Position(723, 594, 8), text = 'Treiner!', effect = CONST_ME_GIANTICE},
    --{position = Position(305, 885, 8), text = 'Treinamento Offline!', effect = CONST_ME_BATS},
    --{position = Position(2030, 481, 5), text = 'Skills Up!', effect = CONST_ME_BATS},
   -- {position = Position(721, 593, 7), text = 'Clique!', effect = CONST_ME_GIANTICE},
}

function globalevent.onThink(interval)
    for i = 1, #effects do
        local settings = effects[i]
        local spectators = Game.getSpectators(settings.position, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            if settings.text then
                local textcolor = textcolors[math.random(#textcolors)]
                Game.sendAnimatedText(settings.text, settings.position, textcolor)
            end
            if settings.effect then
                settings.position:sendMagicEffect(settings.effect)
            end
            if settings.effect2 then
                settings.position:sendMagicEffect(settings.effect2)
            end
        end
    end
    return true
end

globalevent:interval(2000)
globalevent:register()

@Mateus Robeerto
thanks in advance
 
Last edited:
up would be possible to add the name of the player that used the mwall in animated text too?
and maybe add multiple color like changing? you made an script a time ago that does that
Code:
local globalevent = GlobalEvent("positionandtext")
local textcolors = {5, 30, 35, 95, 108, 129, 143, 155, 180, 198, 210, 215}

local effects = {
    {position = Position(32366, 32235, 7), text = 'Training Monks!', effect = CONST_ME_BATS},
    --{position = Position(723, 594, 8), text = 'Treiner!', effect = CONST_ME_GIANTICE},
    --{position = Position(305, 885, 8), text = 'Treinamento Offline!', effect = CONST_ME_BATS},
    --{position = Position(2030, 481, 5), text = 'Skills Up!', effect = CONST_ME_BATS},
   -- {position = Position(721, 593, 7), text = 'Clique!', effect = CONST_ME_GIANTICE},
}

function globalevent.onThink(interval)
    for i = 1, #effects do
        local settings = effects[i]
        local spectators = Game.getSpectators(settings.position, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            if settings.text then
                local textcolor = textcolors[math.random(#textcolors)]
                Game.sendAnimatedText(settings.text, settings.position, textcolor)
            end
            if settings.effect then
                settings.position:sendMagicEffect(settings.effect)
            end
            if settings.effect2 then
                settings.position:sendMagicEffect(settings.effect2)
            end
        end
    end
    return true
end

globalevent:interval(2000)
globalevent:register()

@Mateus Robeerto
thanks in advance
Open a new topic there, and we'll help you. Because the issue in this topic has already been resolved, specifically for your 'MV timer' problem.
 
Back
Top