• 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 When equipping an item an effect appears on the player

Guerra

Member
Joined
May 1, 2018
Messages
69
Reaction score
9
Location
Natal/RN - Brasil
Hello Guys,

I would like to ask for help for a system, it would be something like this. A Script of Movements that when equipping an item, an effect of my choice would be shown on the player and when unequipping the item the effect would stop.

I use TFS 1.3!!
 
Try this one add to your globalevents and change the id or CONST_SLOT_HEAD to different items.
LUA:
local helmetID = 2474
function onThink(interval)
for _, player in ipairs(Game.getPlayers()) do
local helmet = player:getSlotItem(CONST_SLOT_HEAD)
            if helmet and helmet:getId() == helmetID then
                player:getPosition():sendMagicEffect(40)
            end
            end
            return true
end
XML:
<globalevent name="scriptname" interval="10000" script="scriptname.lua"/>
 
Try this one add to your globalevents and change the id or CONST_SLOT_HEAD to different items.
LUA:
local helmetID = 2474
function onThink(interval)
for _, player in ipairs(Game.getPlayers()) do
local helmet = player:getSlotItem(CONST_SLOT_HEAD)
            if helmet and helmet:getId() == helmetID then
                player:getPosition():sendMagicEffect(40)
            end
            end
            return true
end
XML:
<globalevent name="scriptname" interval="10000" script="scriptname.lua"/>
uoooow !! it worked 100% man .. could I add more than one effect so I could combine them?
 
You mean random effects show on player? not only one specific effect?
 
Something like this
LUA:
local helmetID = 2474
function onThink(interval)
for _, player in ipairs(Game.getPlayers()) do
local helmet = player:getSlotItem(CONST_SLOT_HEAD)
            if helmet and helmet:getId() == helmetID then
                player:getPosition():sendMagicEffect(math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
            end
            end
            return true
end
Post automatically merged:

or this try both.
LUA:
local helmetID = 2474
local animatedeffects = {5,30}
function onThink(interval)
local effects = math.random(#animatedeffects)
for _, player in ipairs(Game.getPlayers()) do
local helmet = player:getSlotItem(CONST_SLOT_HEAD)
            if helmet and helmet:getId() == helmetID then
            player:getPosition():sendMagicEffect(effects)
            end
            end
            return true
end
 
Second one works like this, Add your effect numbers to animatedeffects and it will show them.
 
Something like this
LUA:
local helmetID = 2474
function onThink(interval)
for _, player in ipairs(Game.getPlayers()) do
local helmet = player:getSlotItem(CONST_SLOT_HEAD)
            if helmet and helmet:getId() == helmetID then
                player:getPosition():sendMagicEffect(math.random(CONST_ME_FIREWORK_YELLOW, CONST_ME_FIREWORK_BLUE))
            end
            end
            return true
end
Post automatically merged:

or this try both.
LUA:
local helmetID = 2474
local animatedeffects = {5,30}
function onThink(interval)
local effects = math.random(#animatedeffects)
for _, player in ipairs(Game.getPlayers()) do
local helmet = player:getSlotItem(CONST_SLOT_HEAD)
            if helmet and helmet:getId() == helmetID then
            player:getPosition():sendMagicEffect(effects)
            end
            end
            return true
end
in fact, you are not recognizing my client's effects ... I would like you to pull straight from the effects
 
Last edited:
I don't understand but I tested in-game, This one will work for you, Try it.
LUA:
local helmetID = 2474
local effects = {10, 11}
function onThink(interval)
for _, player in ipairs(Game.getPlayers()) do
local helmet = player:getSlotItem(CONST_SLOT_HEAD)
            if helmet and helmet:getId() == helmetID then
            player:getPosition():sendMagicEffect(effects[math.random(1,#effects)])
            end
            end
            return true
end
 
I don't understand but I tested in-game, This one will work for you, Try it.
LUA:
local helmetID = 2474
local effects = {10, 11}
function onThink(interval)
for _, player in ipairs(Game.getPlayers()) do
local helmet = player:getSlotItem(CONST_SLOT_HEAD)
            if helmet and helmet:getId() == helmetID then
            player:getPosition():sendMagicEffect(effects[math.random(1,#effects)])
            end
            end
            return true
end
it worked friend !! thank you very much
 
Try this and next time create your own thread instead of BUMPing solved ones.
LUA:
local helmetID = 2474
local effects = {10, 11}

function onThink(interval)
    local helmet = getPlayerSlotItem(cid, CONST_SLOT_HEAD)
    for _, cid in ipairs(getPlayersOnline()) do
        if helmet and helmet.itemid == helmetID then
                doSendMagicEffect(getCreaturePosition(cid), effects[math.random(1,#effects)])
            end
    end
    return true
end
 

Similar threads

  • Question Question
Replies
5
Views
303
  • Question Question
C++ ring
Replies
0
Views
182
Back
Top