I would like to add the attribute of HP plus it counts several times being that you had + 1 in it, could someone help?
Code:
local conf = {
maxSlotCount = 10,
perecent = {min = 1, max = 20}, -- od ile % do ilu % ma dawac bonusu
ignoredIds = {}
}
function choose(...) --- Function by mock.
local arg = {...}
return arg[math.random(1,#arg)]
end
function isArmor(uid) -- Function by Mock the bear.
if getItemInfo(uid.itemid).armor ~= 0 and getItemWeaponType(uid.uid) == 0 then
return true
end
return false
end
function getSlotCount(nam)
local c = 0
for _ in nam:gmatch('%[(.-)%]') do
c = c + 1
end
return c
end
function onUse(cid, item, fromPosition, itemEx, toPosition) -- Script by mock the bear (MTB)
if not checkExhausted(cid, 429, 1) then
return true
elseif item.uid == 0 or item.itemid == 0 then
return false
elseif isInArray(conf.ignoredIds, itemEx.itemid) or (not getItemWeaponType(itemEx.uid) or getItemWeaponType(itemEx.uid) > 5)
or (getItemWeaponType(itemEx.uid) == 0 and not isArmor(itemEx))
or itemEx.itemid == 0 or itemEx.type > 1 or isItemStackable(itemEx.uid) then
doPlayerSendTextMessage(cid, 24, "You can\'t open a slot on this item.")
return true
elseif isCreature(itemEx.uid) then
return false
end
local nam = getItemName(itemEx.uid)
if getSlotCount(nam) < conf.maxSlotCount then
local l = choose('hp')
-- local fist = getPlayerSkill(cid, SKILL_FIST)
-- local l = choose('hp', 'mp', 'ml', 'cas')
local p = 1
doSendMagicEffect(toPosition, 30)
nam = nam..' ['..l..'.+'..p..'%]'
doSendAnimatedText(toPosition, l..' '..p..'%', 120)
doItemSetAttribute(itemEx.uid, 'name', nam)
-- gainArmor='&p+1',loseArmor='&p-1',
-- doRemoveItem(item.uid, 1)
else
doPlayerSendTextMessage(cid, 24, "You cant open a slot on this item.")
end
return true
end