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

OTClient OTClient - show image during 30 seconds

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,210
Solutions
35
Reaction score
206
LUA:
function Creature:onGiveIcon(Id)
    local imagePath = "/images/game/shield_icon"

    if imagePath then
        self:setGiveIcon(imagePath)
    end
end

I see this code in one server, when player use spell, it generete a img (shield icon), next to the character's head for 30 seconds and then disappears.
I don't know what the other part of the code is, how can I do that?
I need a code in OTC that will generate an image (shield icon) on the side of the player's head for 5 seconds, after carrying out the action (utana vid spell)
 
Redemption:

Option A (easy way))

LUA:
AttachedEffectManager.register(111, 'icon', '/images/game/shield_icon', ThingExternalTexture, {
    duration = 5000, -- "5 seconds and then disappears"
    offset = { 215, 230 } -- "on the side of the player's head"
})
Local Client :
LUA:
g_game.getLocalPlayer():attachEffect(g_attachedEffects.getById(111))
or
server comunication :
LUA:
creature:attachEffectById(11)  -- in utana vid.lua (spell)
1732669057932.gif
Option B) Widget (attachWidget)

after 5 seconds destroy the widget
LUA:
-- fast example
local tile = g_map.getTile(g_game.getLocalPlayer():getPosition())
local widget = g_ui.createWidget('Panel')
widget:setSize({width = 90, height = 22})
widget:setText("time left 5")
widget:setFont("terminus-10px")
widget:setBackgroundColor('#111111cc')
widget:setMarginBottom(40) -- "on the side of the player's head"
widget:setTextAutoResize(true)
widget:setPhantom(true)
tile:attachWidget(widget)

local remainingTime = 5.0 -- "5 seconds and then disappears"

local function updateWidget()
    remainingTime = remainingTime - 0.1
    if remainingTime <= 0 then
        remainingTime = 0
        widget:destroy()
        return
    end
    widget:setText(string.format("time left %.1f", remainingTime))
    scheduleEvent(updateWidget, 100)
end

scheduleEvent(updateWidget, 100)

1732668940691.gif

V8:
lua:
Code:
 g_lua.bindClassMemberFunction<Creature>("addTopWidget", &Creature::addTopWidget);
    g_lua.bindClassMemberFunction<Creature>("addBottomWidget", &Creature::addBottomWidget);
    g_lua.bindClassMemberFunction<Creature>("addDirectionalWidget", &Creature::addDirectionalWidget);
    g_lua.bindClassMemberFunction<Creature>("removeTopWidget", &Creature::removeTopWidget);
    g_lua.bindClassMemberFunction<Creature>("removeBottomWidget", &Creature::removeBottomWidget);
    g_lua.bindClassMemberFunction<Creature>("removeDirectionalWidget", &Creature::removeDirectionalWidget);
    g_lua.bindClassMemberFunction<Creature>("getTopWidgets", &Creature::getTopWidgets);
    g_lua.bindClassMemberFunction<Creature>("getBottomWidgets", &Creature::getBottomWidgets);
    g_lua.bindClassMemberFunction<Creature>("getDirectionalWdigets", &Creature::getDirectionalWdigets);
    g_lua.bindClassMemberFunction<Creature>("clearWidgets", &Creature::clearWidgets);
    g_lua.bindClassMemberFunction<Creature>("clearTopWidgets", &Creature::clearTopWidgets);
    g_lua.bindClassMemberFunction<Creature>("clearBottomWidgets", &Creature::clearBottomWidgets);
    g_lua.bindClassMemberFunction<Creature>("clearDirectionalWidgets", &Creature::clearDirectionalWidgets);

c++


Code:
g_drawQueue->addTexturedRect(Rect, m_Texture, Rect(0, 0, m_Texture->getSize()));
 
Last edited:
Back
Top