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

TFS 1.X+ onEquip Script [read item actionid] TFS 1.5

mano368

Senior Support Team Member
Staff member
Support Team
Joined
Sep 2, 2011
Messages
646
Solutions
46
Reaction score
296
Location
Brazil
I have a script that give actionid to an item, and i create that "movements" to read the actionid and send a magic effect when equip the weapon, but, idk how to read the weapon actionid, tried with the same item:getAttribute(ITEM_ATTRIBUTE_ACTIONID) and item.actionid but nothing happens, when i write one actionid works fine!

someone can help me?

Lua:
local effects = {
[57000] = {effect = CONST_ME_MAGIC_BLUE},
[57001] = {effect = CONST_ME_MAGIC_RED},
[57002] = {effect = CONST_ME_MAGIC_GREEN},
[57003] = {effect = CONST_ME_MAGIC_BLUE},
[57004] = {effect = CONST_ME_MAGIC_BLUE},
[57005] = {effect = CONST_ME_GREEN_RINGS},
[57006] = {effect = CONST_ME_FIREAREA}
}


function onEquip(player, item, slot)
local Effects = effects[item:getAttribute(ITEM_ATTRIBUTE_ACTIONID)]

    if item:getAttribute(ITEM_ATTRIBUTE_ACTIONID) == Effects then
        player:getPosition():sendMagicEffect(Effects.effect)
    end
    return true
end
 
Last edited:
Solution
Lua:
local effects = {
[57000] = {effect = CONST_ME_MAGIC_BLUE},
[57001] = {effect = CONST_ME_MAGIC_RED},
[57002] = {effect = CONST_ME_MAGIC_GREEN},
[57003] = {effect = CONST_ME_MAGIC_BLUE},
[57004] = {effect = CONST_ME_MAGIC_BLUE},
[57005] = {effect = CONST_ME_GREEN_RINGS},
[57006] = {effect = CONST_ME_FIREAREA}
}


function onEquip(player, item, slot)
local Effects = effects[item:getAttribute(ITEM_ATTRIBUTE_ACTIONID)]

    --if item:getAttribute(ITEM_ATTRIBUTE_ACTIONID) == Effects then
    if Effects then
        player:getPosition():sendMagicEffect(Effects.effect)
    end
    return true
end
Lua:
local effects = {
[57000] = {effect = CONST_ME_MAGIC_BLUE},
[57001] = {effect = CONST_ME_MAGIC_RED},
[57002] = {effect = CONST_ME_MAGIC_GREEN},
[57003] = {effect = CONST_ME_MAGIC_BLUE},
[57004] = {effect = CONST_ME_MAGIC_BLUE},
[57005] = {effect = CONST_ME_GREEN_RINGS},
[57006] = {effect = CONST_ME_FIREAREA}
}


function onEquip(player, item, slot)
local Effects = effects[item:getAttribute(ITEM_ATTRIBUTE_ACTIONID)]

    --if item:getAttribute(ITEM_ATTRIBUTE_ACTIONID) == Effects then
    if Effects then
        player:getPosition():sendMagicEffect(Effects.effect)
    end
    return true
end
 
Solution
Lua:
local effects = {
[57000] = {effect = CONST_ME_MAGIC_BLUE},
[57001] = {effect = CONST_ME_MAGIC_RED},
[57002] = {effect = CONST_ME_MAGIC_GREEN},
[57003] = {effect = CONST_ME_MAGIC_BLUE},
[57004] = {effect = CONST_ME_MAGIC_BLUE},
[57005] = {effect = CONST_ME_GREEN_RINGS},
[57006] = {effect = CONST_ME_FIREAREA}
}


function onEquip(player, item, slot)
local Effects = effects[item:getAttribute(ITEM_ATTRIBUTE_ACTIONID)]

    --if item:getAttribute(ITEM_ATTRIBUTE_ACTIONID) == Effects then
    if Effects then
        player:getPosition():sendMagicEffect(Effects.effect)
    end
    return true
end
holy shit, only that? thanks bro, by the way, you know how i can give charges or time to an item to lose the actionid using decayto?

with:
Lua:
ITEM_ATTRIBUTE_DECAYTO
ITEM_ATTRIBUTE_DURATION
ITEM_ATTRIBUTE_DECAYSTATE
ITEM_ATTRIBUTE_CHARGES

or other function without using items.xml
 
Back
Top