• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

How to add charges to item in movements?

devimake

Active Member
Joined
Sep 25, 2018
Messages
60
Reaction score
39
hi otland! im trying to add charges to an paralyze item, the way item works is that you drop the item on player to paralyze them. No matter what I try, I cant seem to add charges to the item, meaning if you drop it on a player, it just disappears. I want to be able to drop item on player to paralyze, and then still have it in backpack with 9 charges left.

I tried doing it as an action script but then item does not work properly, the item just drops onto the ground.

Im using TFS 1.5 downgrade by nekiro 8.6.

Any help/tips is much appreciated!

thanks
 

Attachments

Last edited:
Solution
Try this.


LUA:
local ec = EventCallback

local PARALYZE_TIME = 2000 -- ms
local PARALYZE_ITEM = 11115

local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, PARALYZE_TIME)

function ec.onMoveItem(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if not player then
        return true
    end
    if item:getId() ~= PARALYZE_ITEM then
        return true
    end
    local tile = Tile(toPosition)
    if not tile then
        return true
    end
    local playerFound = tile:getTopCreature()
    if not playerFound or not playerFound:isPlayer() then
        return true
    end
    local charges = item:getAttribute(ITEM_ATTRIBUTE_CHARGES)
    if charges and charges > 0 then...
Try this.


LUA:
local ec = EventCallback

local PARALYZE_TIME = 2000 -- ms
local PARALYZE_ITEM = 11115

local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, PARALYZE_TIME)

function ec.onMoveItem(player, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
    if not player then
        return true
    end
    if item:getId() ~= PARALYZE_ITEM then
        return true
    end
    local tile = Tile(toPosition)
    if not tile then
        return true
    end
    local playerFound = tile:getTopCreature()
    if not playerFound or not playerFound:isPlayer() then
        return true
    end
    local charges = item:getAttribute(ITEM_ATTRIBUTE_CHARGES)
    if charges and charges > 0 then
        item:setAttribute(ITEM_ATTRIBUTE_CHARGES, charges - 1)
    else
        item:remove(1)
    end
    Game.sendAnimatedText('Paralyzed!', playerFound:getPosition(), TEXTCOLOR_RED)
    playerFound:addCondition(condition)
    return false
end

ec:register()
 
Solution
Hey marko, I tested your script and it looks like it has 2 charges now, how would I increase it?

I have this defined in items.xml,
<item id="2346" article="a" name="tear of daraman">
<attribute key="weight" value="30" />
<attribute key="charges" value="20" />
<attribute key="description" value="Drop it on the ground from backpack and you will paralyze opponent." />
</item>

thank you for helping!
 
item disappears after I used it twice on a player. I want to increase charges to 10 so you would have to drop item on player 10 times before item disappears
 
Last edited:
Back
Top