• 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+ Block use item on items with decay like aol, life ring, soft boots

damian00912

New Member
Joined
Sep 11, 2009
Messages
86
Reaction score
4
Hei! I have problem, i have this script CreatureEvent - [TFS 1.1] Ultimate item stat system (elements, skills, exp, loot and more) (https://otland.net/threads/tfs-1-1-ultimate-item-stat-system-elements-skills-exp-loot-and-more.229771/)

And is problem because when I use rare, epic, and legendary upgrade item on items with decay, it a lot of rings, amulets, and some boots, thats is automatic crash server. Someone can fix mi this script please?

Here is action

Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
return stat_onUse(player, item, fromPosition, itemEx, toPosition)
end

Here is stats.lua in folder data

STATS_SYSTEM_CONFIG = { -- BASIC CONFIG STARTS HERE -- enable/disable - Pastebin.com (https://pastebin.com/BRCjQJXH)


Please Help!
 
Last edited:
Solution
Try this. Not sure what else might need to be checked.
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
    if not itemEx or not itemEx:isItem() then return false end

    local it = itemEx:getType()
    
    if it:getDecayId() > 0 or it:getTransformEquipId() > 0 or it:getCharges() > 0 or it:isGroundTile() or it:isCorpse() then
        return false
    end
   
    return stat_onUse(player, item, fromPosition, itemEx, toPosition)
end

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,809
Solutions
432
Reaction score
3,945
pastebin has a character limit of 500 kb.
Looks like you hit that limit, as the code appears to cut-off in the middle of a function.
 

Azakelis

Advanced OT User
Joined
Feb 17, 2014
Messages
164
Solutions
15
Reaction score
225
Ok so you can't use it on items that are stackable and are transforming (every equipment item that has duration should be transforming).
Just use the bannedItemIds for the rest of them.
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
    if item:isStackable() then return false end
    if self:getTransformEquipId() == 0 then return false end
    
    local bannedItemIds = {1234,1235,1236,1237}
    if isInArray(bannedItemIds, item:getId()) then
        return false
    end

    return stat_onUse(player, item, fromPosition, itemEx, toPosition)
end
 
OP
OP
damian00912

damian00912

New Member
Joined
Sep 11, 2009
Messages
86
Reaction score
4
thanks you :)
Post automatically merged:

it;s not working :(


Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/slot.lua:onUse
data/actions/scripts/slot.lua:2: attempt to call method 'isStackable' (a nil value)
stack traceback:
        [C]: in function 'isStackable'
        data/actions/scripts/slot.lua:2: in function <data/actions/scripts/slot.lua:1>

tfs 1.2
 
Last edited:
OP
OP
damian00912

damian00912

New Member
Joined
Sep 11, 2009
Messages
86
Reaction score
4
And I don't need for stackable items, becauee this is blocked in script, only for decayto, and also with charges i blocked with all id
Post automatically merged:

Please helppppp
 
Last edited:
OP
OP
damian00912

damian00912

New Member
Joined
Sep 11, 2009
Messages
86
Reaction score
4
So Now i have blokec ID of amulets with charges and ring with harges and decayto like thtat

Lua:
local blockId = {
    2173, 2161, 2164, 2170, 2172, 2173, 2197, 2198, 2199, 2200, 2201, 2261, 2262, 2265, 2266, 2268, 2269, 2271, 2273, 2396, 7887, 7888, 7889, 7890, 10218, 10219, 10220, 10221, 15401, 18402, 18407, 23554, 28555,
    28555, 28556, 28557, 28558, 28559, 28565, 28566, 28567, 28568, 28569, 28575, 28576, 28577, 28578, 28579, 28580, 28581, 28582, 28583, 28584, 28585, 28586, 28587, 28588, 28589, 28590, 32124, 32125, 32126, 32127, 32128, 32129, 32384, 32385, 32386, 32386, 32388, 32389,
    14327, 2164, 2209, 2208, 2168, 2169, 2165, 13826, 2167, 14327, 6300, 2214, 18408, 2213, 2207, 26190, 26187, 26186, 2166, 6132, 2640, 9932, 9933, 10309, 10311, 10314, 12541, 13580, 22646, 24790, 26131, 26132, 26182, 26183, 26184,
    }

function onUse(player, item, fromPosition, itemEx, toPosition)
if not (Item(itemEx.uid) or not Creature(itemEx.uid)) or (isInArray(blockId, itemEx.itemid)) then return false end
stat_onUse(player, item, fromPosition, itemEx, toPosition)
return true
end

But when I use upgrade item on corpes of monsters, or with holes for shovel etc (with atribute decayto and transform) that's i have in console:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/slot.lua:onUse
data/lib/stats.lua:2657: bad argument #2 to 'random' (interval is empty)
stack traceback:
        [C]: in ?
        [C]: in function 'random'
        data/lib/stats.lua:2657: in function 'generateStats'
        data/lib/stats.lua:1445: in function 'stat_onUse'
        data/actions/scripts/slot.lua:9: in function <data/actions/scripts/slot.lua:7>
Post automatically merged:

i try sometihink like thats in actions/scripts/slot.lua

Code:
if not (Item(itemEx.uid) or not Creature(itemEx.uid) or (itemEx.uid:isAttribute(ITEM_ATTRIBUTE_DURATION)) > 0) or (isInArray(blockId, itemEx.itemid)) then return false end

But not working :(
 

forgee

Veteran OT User
Joined
May 9, 2011
Messages
321
Solutions
16
Reaction score
270
Location
Sweden
GitHub
forgee
Try this. Not sure what else might need to be checked.
Lua:
function onUse(player, item, fromPosition, itemEx, toPosition)
    if not itemEx or not itemEx:isItem() then return false end

    local it = itemEx:getType()
    
    if it:getDecayId() > 0 or it:getTransformEquipId() > 0 or it:getCharges() > 0 or it:isGroundTile() or it:isCorpse() then
        return false
    end
   
    return stat_onUse(player, item, fromPosition, itemEx, toPosition)
end
 
Last edited:
Solution

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
5,809
Solutions
432
Reaction score
3,945
You'd have to check for something all armors, or all weapons have.

I think all weapons have a weaponType and all armors have a slotType + armor (even if the value is 0)

So if you confirm one or another of those things.. and then cherry-pick attributes you don't want to upgrade, such as stackable objects.. or decayable objects you'd probably be able to find 99-100% of enchantable items that way.
 

forgee

Veteran OT User
Joined
May 9, 2011
Messages
321
Solutions
16
Reaction score
270
Location
Sweden
GitHub
forgee
You'd have to check for something all armors, or all weapons have.

I think all weapons have a weaponType and all armors have a slotType + armor (even if the value is 0)

So if you confirm one or another of those things.. and then cherry-pick attributes you don't want to upgrade, such as stackable objects.. or decayable objects you'd probably be able to find 99-100% of enchantable items that way.
I assumed stats_onUse handled most of that and we just needed to filter out a few additional (overlooked?) item types that we didn't want to be enchantable.
 
OP
OP
damian00912

damian00912

New Member
Joined
Sep 11, 2009
Messages
86
Reaction score
4
I check this when I comeback to home, but can you also fix me this script for have acces only upgrade items with id from list? Like I have up this blockitems?
 
Top