samandriel
Active Member
- Joined
- Oct 19, 2016
- Messages
- 242
- Solutions
- 1
- Reaction score
- 46
How to recharge weapon with charges?
I did this:
But i got 2 problems
1- the items that is adding on hands has not 600 charges, has 100... why?
2- how to get an specific item on backpack, get it charges, remove it, and then add other with the same charges?
I did this:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
local function autoRechargeHandWeapon(cid)
local itemID = 7424
-- 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
-- check charges in hand
local wepon_hand_charges = getPlayerSlotItem(cid, hand_to_check).type
print("wepon_hand_charges: " .. wepon_hand_charges)
if wepon_hand_charges <= 2 then
-- check if there is more in backpack
local weapon_in_backpack = getPlayerItemCount(cid, itemID)
print("weapon_in_backpack: " .. weapon_in_backpack)
if weapon_in_backpack > 1 then
-- over charges weapon on hands, refil:
addEvent (
function ()
doPlayerAddItem(cid, itemID, 600)
end, 100
)
addEvent (
function ()
doPlayerRemoveItem(cid, itemID, 600)
end, 150
)
end
end
end
function onGetFormulaValues(cid, level, skill, attack, factor)
min = -1
max = -2
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
autoRechargeHandWeapon(cid)
return doCombat(cid, combat, var)
end
But i got 2 problems
1- the items that is adding on hands has not 600 charges, has 100... why?
2- how to get an specific item on backpack, get it charges, remove it, and then add other with the same charges?