• 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 0.X Auto recharge small stone

samandriel

Active Member
Joined
Oct 19, 2016
Messages
242
Solutions
1
Reaction score
46
How to auto recharge small stone in a ot 8.6? using 0.4 https://github.com/Fir3element/3777/blob/master/src/luascript.cpp

I've tried this:
Code:
    <distance id="1294" unproperly="1" swing="true" event="script" value="distance_weapons/hands_autorecharge/small_stone.lua" />

small_stone.lua
Code:
local itemID = 1294
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 9)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
 
local function autoRechargeDistanceHandWeapon(cid)
    -- check hands to refill
    local hand_to_check = 0
    local left_hand = getPlayerSlotItem(cid, CONST_SLOT_LEFT)
    local right_hand = getPlayerSlotItem(cid, CONST_SLOT_RIGHT)
    if left_hand.uid ~= 0 and left_hand.itemid == itemID then
        hand_to_check = CONST_SLOT_LEFT
    elseif right_hand.uid ~= 0 and right_hand.itemid == itemID then
        hand_to_check = CONST_SLOT_RIGHT
    end
    local ammo_in_slot = getPlayerSlotItem(cid, hand_to_check).type
    if ammo_in_slot > 3 then
        return false
    end
    local ammo_count = getPlayerItemCount(cid, itemID) - 1
    ammo_count = ammo_count >= 100 and 100 or ammo_count
    addEvent (
        function ()
            doPlayerRemoveItem(cid, itemID, ammo_count)
        end, 1
    )
    addEvent (
        function ()
            doPlayerAddItem(cid, itemID, ammo_count)
        end, 1
    )
end

function onGetFormulaValues(cid, level, skill, attack, factor)
    min = ((0.005) * (attack * 9) * (skill * 6)) * -0.10
    max = ((0.015) * (attack * 9) * (skill * 6)) * -1.00
    return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")


function onUseWeapon(cid, var)
    autoRechargeDistanceHandWeapon(cid)
    return doCombat(cid, combat, var)
end

when it is working?
with 150 stones it is working

when it is NOT working?
if i have only 84 small stones
80 in bag
4 on hands
when the hands become 3, the small stones from hands are deleted
and are added to the bag amount

idk works with more then 150, but less then 100 not works

what should i do?
 
why less then 100 is not working and more then 100 is working?
there is a way to recharge only when broke the last one?
 
Back
Top