• 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 [TFS 1.2] Charges on amulets

Kuzyn

Excellent OT User
Joined
Dec 19, 2009
Messages
1,732
Solutions
3
Reaction score
883
Location
pl?
I've got problem on TFS 1.2, amulets do not have charges. I've got a script for quest chests, in RME amulet has 200 charges but in game it's 1.
Another script, NPC gives amulet but only with 1 charge.

I saw old thread on otland about this problem but no one solved this, please help.
Greets
 
change the charges of the item in items.xml
Code:
  <item id="2201" article="a" name="dragon necklace">
        <attribute key="weight" value="630" />
        <attribute key="slotType" value="necklace" />
        <attribute key="charges" value="200" />
        <attribute key="showcharges" value="1" />
        <attribute key="absorbPercentFire" value="8" />
        <attribute key="showattributes" value="1" />
    </item>
o_O
 
Code:
  <item id="2201" article="a" name="dragon necklace">
        <attribute key="weight" value="630" />
        <attribute key="slotType" value="necklace" />
        <attribute key="charges" value="200" />
        <attribute key="showcharges" value="1" />
        <attribute key="absorbPercentFire" value="8" />
        <attribute key="showattributes" value="1" />
    </item>
o_O

<attribute key="showcharges" value="1" /> <-- and whats that? o_O

Example :

PHP:
<item id="2197" article="a" name="stone skin amulet">
        <attribute key="weight" value="700" />
        <attribute key="slotType" value="necklace" />
        <attribute key="charges" value="5" />
        <attribute key="showcharges" value="5" />
        <attribute key="absorbPercentPhysical" value="80" />
        <attribute key="absorbPercentDeath" value="80" />
        <attribute key="showattributes" value="1" />
    </item>
 
<attribute key="showcharges" value="1" /> <-- and whats that? o_O

Example :

PHP:
<item id="2197" article="a" name="stone skin amulet">
        <attribute key="weight" value="700" />
        <attribute key="slotType" value="necklace" />
        <attribute key="charges" value="5" />
        <attribute key="showcharges" value="5" />
        <attribute key="absorbPercentPhysical" value="80" />
        <attribute key="absorbPercentDeath" value="80" />
        <attribute key="showattributes" value="1" />
    </item>
Now I don't see any value.
https://otland.net/threads/amulet-charge-problem.202224/

And he get the same error.

1.
Code:
<item id="2197" article="a" name="stone skin amulet">
        <attribute key="weight" value="700" />
        <attribute key="slotType" value="necklace" />
        <attribute key="charges" value="5" />
        <attribute key="showcharges" value="5" />
        <attribute key="absorbPercentPhysical" value="80" />
        <attribute key="absorbPercentDeath" value="80" />
        <attribute key="showattributes" value="1" />
    </item>

Try this

2.
nothing change, and now it doesnt show charges left more
 
Try
PHP:
 <item id="2201" article="a" name="dragon necklace">
        <attribute key="weight" value="630" />
        <attribute key="slotType" value="necklace" />
        <attribute key="charges" value="200" />
        <attribute key="showcharges" value="200" />
        <attribute key="absorbPercentFire" value="8" />
        <attribute key="showattributes" value="1" />
    </item>
:D I told you that I tried this :)
8B5GFnF.png
 
<attribute key="showcharges" value="1" /> <-- and whats that? o_O

Example :

PHP:
<item id="2197" article="a" name="stone skin amulet">
        <attribute key="weight" value="700" />
        <attribute key="slotType" value="necklace" />
        <attribute key="charges" value="5" />
        <attribute key="showcharges" value="5" />
        <attribute key="absorbPercentPhysical" value="80" />
        <attribute key="absorbPercentDeath" value="80" />
        <attribute key="showattributes" value="1" />
    </item>
HAHAAHA

"showcharges" means you want to make charges visible on item not how many charges this item has XD

To make this work just insert to npc like this:
Code:
stone skin amulet,2197,5000,5
Ex. You are buying stone skin amulet with 5 charges.

:)
 
HAHAAHA

"showcharges" means you want to make charges visible on item not how many charges this item has XD

To make this work just insert to npc like this:
Code:
stone skin amulet,2197,5000,5
Ex. You are buying stone skin amulet with 5 charges.

:)
Okay but what about chest quest? And npc in lua? I want to give a dragon necklace as a reward:
Code:
   ["Dragon Hatchlings"] = {storage = 27001, mstorage = 28001, amount = 100, exp = 15000, items = {{id = 2152, count = 15}, {id = 2201, count = 1}}},

And this is reward system (chests):
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local chest = Container(item.uid)

    if not chest then
        return true
    end

    local uniqueid = chest:getUniqueId()
    if player:getStorageValue(uniqueid) == -2 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
        return true
    end

    local reward = nil
    local start = player:getStorageValue(uniqueid) == -1 and 0 or player:getStorageValue(uniqueid)

    for i = start, chest:getSize() do
        reward = chest:getItem(i)
        if not reward then
            break
        end

        if reward:getWeight() > player:getFreeCapacity() then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found a ' .. reward:getName() .. ' weighing ' .. reward:getWeight()/100 .. ' oz it\'s too heavy.')
            player:setStorageValue(uniqueid, i)
            break
        else
            local reward_container = Container(reward:getUniqueId())
            if reward_container then
                reward_container = reward_container:clone()
                reward_container:moveTo(player)
            else
                player:addItem(reward:getId(), reward:getCount())
            end
            local reward_msg = reward:getArticle() .. ' ' .. reward:getName()
            if reward:getCount() > 1 then
                reward_msg = reward:getCount() .. ' ' .. reward:getPluralName()
            end

            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found ' .. reward_msg .. '.')

            player:setStorageValue(uniqueid, -2)
        end
    end

    return true
end
 
You could try something like this:

Code:
if reward:getId() == amulet_itemid then
reward:setAttribute('charges', 200)
end

If you are giving multiple amulets then:

Code:
if reward:getId() == amulet_itemid then
for i = 1, #reward:getCount() do
AMULET = player:addItem(amulet_itemid, 1)
AMULET:setAttribute('charges', 200)
end
end
 
Back
Top