• 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.2 add Cap on item

lazarus321

Member
Joined
May 8, 2017
Messages
222
Reaction score
23
How do I add cap on the item. Ex. When equipping a backpack the player gains 200 cap. and when you remove backpack the cap it goes back to normal. I tried using the "weapons" script

HTML:
player:setCapacity(player:getCapacity() + 200)
but dont work. I think because it is not a weapon itself

I would like to put this function to be faster when configuring "<attribute key="skillSword" value="2" />"
 
Solution
How do I add cap on the item. Ex. When equipping a backpack the player gains 200 cap. and when you remove backpack the cap it goes back to normal. I tried using the "weapons" script

HTML:
player:setCapacity(player:getCapacity() + 200)
but dont work. I think because it is not a weapon itself

I would like to put this function to be faster when configuring "<attribute key="skillSword" value="2" />"
Movements
<movevent event="Equip" itemid="xxxx" slot="x" script="x.lua" />
<movevent event="DeEquip" itemid="xxxx" slot="x" script="x.lua" />
How do I add cap on the item. Ex. When equipping a backpack the player gains 200 cap. and when you remove backpack the cap it goes back to normal. I tried using the "weapons" script

HTML:
player:setCapacity(player:getCapacity() + 200)
but dont work. I think because it is not a weapon itself

I would like to put this function to be faster when configuring "<attribute key="skillSword" value="2" />"
Movements
<movevent event="Equip" itemid="xxxx" slot="x" script="x.lua" />
<movevent event="DeEquip" itemid="xxxx" slot="x" script="x.lua" />
 
Solution
Is it. Thanks Ascuas Funkeln.
Post automatically merged:

@Ascuas Funkeln I add in movements

HTML:
    <movevent event="Equip" itemid="26506" slot="backpack" script="Mochila_Aventureiro.lua" function="onEquipItem">
    </movevent>
    <movevent event="DeEquip" itemid="26506" slot="backpack" function="onDeEquipItem" />

and this script

HTML:
function onEquip(player, item, slot) 
  
   player:setCapacity(player:getCapacity() + (5 * 100))
  
    return true
end


dont work, need more anything?
 
Last edited:
Is it. Thanks Ascuas Funkeln.
Post automatically merged:

@Ascuas Funkeln I add in movements

HTML:
    <movevent event="Equip" itemid="26506" slot="backpack" script="Mochila_Aventureiro.lua" function="onEquipItem">
    </movevent>
    <movevent event="DeEquip" itemid="26506" slot="backpack" function="onDeEquipItem" />

and this script

HTML:
function onEquip(player, item, slot)

   player:setCapacity(player:getCapacity() + (5 * 100))

    return true
end


dont work, need more anything?
Code:
    <movevent event="Equip" itemid="26506" slot="backpack" script="Mochila_Aventureiro.lua">
    </movevent>
    <movevent event="DeEquip" itemid="26506" slot="backpack" function="onDeEquipItem" />
 
nice work now. But this cumulative add cap, I need to see now how to do it when unpacking back to the initial cap
Code:
function onEquip(player, item, slot)

   player:setCapacity(player:getCapacity() + (5 * 100))

    return true
end
function onDeEquip(player, item, slot)

   player:setCapacity(player:getCapacity())

    return true
end
Code:
    <movevent event="Equip" itemid="26506" slot="backpack" script="Mochila_Aventureiro.lua">
    </movevent>
    <movevent event="DeEquip" itemid="26506" slot="backpack" script="Mochila_Aventureiro.lua"/>

Anyway check, cuz there will be i think problem if u add cap bonus to other items
 
Use is..
Script is Revscript for tfs 1.2 10.98
add in data/scripts/movements/Name_Script.lua


LUA:
local config = {
    itemId = 26538, -- ID do item que concede capacidade
    capacityBonus = 500, -- Quantidade de capacidade a ser concedida
    storageKey = 102300 -- Storage key para controlar o bônus
}

-- Função para calcular o bônus real de capacidade
local function calculateRealBonus(bonus)
    return bonus * 100 -- Multiplica por 100 para obter o valor real
end

-- Evento para equipar o item
local equipEvent = MoveEvent()

function equipEvent.onEquip(player, item, slot, isCheck)
    if not isCheck and slot == CONST_SLOT_AMMO and item:getId() == config.itemId then
        -- Verifica se o bônus já foi aplicado
        if player:getStorageValue(config.storageKey) ~= 1 then
            local realBonus = calculateRealBonus(config.capacityBonus)
            player:setCapacity(player:getCapacity() + realBonus)
            player:setStorageValue(config.storageKey, 1) -- Marca que o bônus foi aplicado
        end
    end
    return true
end

equipEvent:type("equip")
equipEvent:slot("ammo")
equipEvent:id(config.itemId)
equipEvent:register()

-- Evento para desequipar o item
local deEquipEvent = MoveEvent()

function deEquipEvent.onDeEquip(player, item, slot)
    if slot == CONST_SLOT_AMMO and item:getId() == config.itemId then
        -- Verifica se o bônus foi aplicado
        if player:getStorageValue(config.storageKey) == 1 then
            local realBonus = calculateRealBonus(config.capacityBonus)
            player:setCapacity(player:getCapacity() - realBonus)
            player:setStorageValue(config.storageKey, -1) -- Remove a marca do bônus
        end
    end
    return true
end

deEquipEvent:type("deequip")
deEquipEvent:slot("ammo")
deEquipEvent:id(config.itemId)
deEquipEvent:register()
 
Last edited:
Use is..
Script is Revscript for tfs 1.2 10.98
add in data/scripts/movements/Name_Script.lua


LUA:
local config = {
    itemId = 26538, -- ID do item que concede capacidade
    capacityBonus = 500, -- Quantidade de capacidade a ser concedida
    storageKey = 102300 -- Storage key para controlar o bônus
}

-- Função para calcular o bônus real de capacidade
local function calculateRealBonus(bonus)
    return bonus * 100 -- Multiplica por 100 para obter o valor real
end

-- Evento para equipar o item
local equipEvent = MoveEvent()

function equipEvent.onEquip(player, item, slot, isCheck)
    if not isCheck and slot == CONST_SLOT_AMMO and item:getId() == config.itemId then
        -- Verifica se o bônus já foi aplicado
        if player:getStorageValue(config.storageKey) ~= 1 then
            local realBonus = calculateRealBonus(config.capacityBonus)
            player:setCapacity(player:getCapacity() + realBonus)
            player:setStorageValue(config.storageKey, 1) -- Marca que o bônus foi aplicado
        end
    end
    return true
end

equipEvent:type("equip")
equipEvent:slot("ammo")
equipEvent:id(config.itemId)
equipEvent:register()

-- Evento para desequipar o item
local deEquipEvent = MoveEvent()

function deEquipEvent.onDeEquip(player, item, slot)
    if slot == CONST_SLOT_AMMO and item:getId() == config.itemId then
        -- Verifica se o bônus foi aplicado
        if player:getStorageValue(config.storageKey) == 1 then
            local realBonus = calculateRealBonus(config.capacityBonus)
            player:setCapacity(player:getCapacity() - realBonus)
            player:setStorageValue(config.storageKey, -1) -- Remove a marca do bônus
        end
    end
    return true
end

deEquipEvent:type("deequip")
deEquipEvent:slot("ammo")
deEquipEvent:id(config.itemId)
deEquipEvent:register()

1749376709125.webp
 
Just a question, what do you mean by 1.2? As far as I know, Revscript only exists from TFS 1.3 and up, I don't think it works on 1.2. You might want to change the title to 1.3 instead.
You're right, it's actually TFS 1.4.2. I must have hit the wrong key when typing the title. Thanks for pointing it out!
 

Similar threads

  • Question Question
Replies
5
Views
304
Back
Top