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

Solved tfs 1.0 setAttribute ITEM_ATTRIBUTE_ATK not working

miens

Combos and Freedom
Joined
Nov 6, 2016
Messages
61
Reaction score
8
Hey
I had a spell modifying item attribute in tfs 1.2 and everything worked fine. I had to switch to older version and now when I call the same method (setAttribute) its not changing anything and even returns null. I tried debugging it for hours with no effect. Any ideas what might be wrong here?

Code:
function onCastSpell(creature, variant)
    local player = Player(creature)
    local wpn = player:getSlotItem(CONST_SLOT_LEFT)
    local atk = getAttackValue(wpn)
    if atk >0 then
        local parameters = {weapon = wpn, attack = atk, pl = player}
        --addEvent(UndoStatMod,15000,parameters)
       
        player:setStorageValue(1690, wpn:getUniqueId()+1)
        --print(wpn.uid)
        player:setStorageValue(1691, atk)
        print(wpn:setAttribute(ITEM_ATTRIBUTE_ATTACK, atk+50))
        --print(wpn.uid)
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
        return true;
    else
        player:sendCancelMessage('You must be holding a weapon.')
        return false
    end
end
 
Solution
ah yes forgot to mention it in post but it is in topic. Im currently using 1.0.
Code:
local function getAttackValue(item)
    if item ~= nil then
        return ItemType(item:getId()):getAttack()
    else
        return 0
    end
end

but I think the error is not in here. i even tried a line like:
Code:
print(Item(player:getSlotItem(CONST_SLOT_LEFT):getUniqueId()):setAttribute(ITEM_ATTRIBUTE_ATK, atk+50))
and it still returned null and nothing changed.
The reason is there is no ITEM_ATTRIBUTE_ATTACK or ATK in tfs 1.0, your only choice is to use something newer or change the source to add this attribute.

https://github.com/otland/forgottenserver/blob/1.0/src/luascript.cpp#L1500-L1513
Hey
I had a spell modifying item attribute in tfs 1.2 and everything worked fine. I had to switch to older version and now when I call the same method (setAttribute) its not changing anything and even returns null. I tried debugging it for hours with no effect. Any ideas what might be wrong here?

Code:
function onCastSpell(creature, variant)
    local player = Player(creature)
    local wpn = player:getSlotItem(CONST_SLOT_LEFT)
    local atk = getAttackValue(wpn)
    if atk >0 then
        local parameters = {weapon = wpn, attack = atk, pl = player}
        --addEvent(UndoStatMod,15000,parameters)
     
        player:setStorageValue(1690, wpn:getUniqueId()+1)
        --print(wpn.uid)
        player:setStorageValue(1691, atk)
        print(wpn:setAttribute(ITEM_ATTRIBUTE_ATTACK, atk+50))
        --print(wpn.uid)
        player:getPosition():sendMagicEffect(CONST_ME_HOLYDAMAGE)
        return true;
    else
        player:sendCancelMessage('You must be holding a weapon.')
        return false
    end
end

Post getAttackValue function and which "old version" did you switch for?
 
ah yes forgot to mention it in post but it is in topic. Im currently using 1.0.
Code:
local function getAttackValue(item)
    if item ~= nil then
        return ItemType(item:getId()):getAttack()
    else
        return 0
    end
end

but I think the error is not in here. i even tried a line like:
Code:
print(Item(player:getSlotItem(CONST_SLOT_LEFT):getUniqueId()):setAttribute(ITEM_ATTRIBUTE_ATK, 50))
and it still returned null and nothing changed.
 
Last edited:
ah yes forgot to mention it in post but it is in topic. Im currently using 1.0.
Code:
local function getAttackValue(item)
    if item ~= nil then
        return ItemType(item:getId()):getAttack()
    else
        return 0
    end
end

but I think the error is not in here. i even tried a line like:
Code:
print(Item(player:getSlotItem(CONST_SLOT_LEFT):getUniqueId()):setAttribute(ITEM_ATTRIBUTE_ATK, atk+50))
and it still returned null and nothing changed.
The reason is there is no ITEM_ATTRIBUTE_ATTACK or ATK in tfs 1.0, your only choice is to use something newer or change the source to add this attribute.

https://github.com/otland/forgottenserver/blob/1.0/src/luascript.cpp#L1500-L1513
 
Solution
Back
Top