wafuboe
Active Member
- Joined
- Dec 24, 2010
- Messages
- 884
- Solutions
- 2
- Reaction score
- 26
Hello i got this problem from a action script that upgrade items
this appears in console
any help ill appreciate it
Script:
Also i got this mining script and i have this problem
Im using TFS 1.3
thank you
this appears in console
any help ill appreciate it
Script:
Code:
local conf = {
["level"] = {
-- [item_level] = {successPercent= CHANCE TO UPGRADE ITEM, downgradeLevel = ITEM GETS THIS LEVEL IF UPGRADE FAILS}
[1] = {successPercent = 85, downgradeLevel = 0},
[2] = {successPercent = 80, downgradeLevel = 1},
[3] = {successPercent = 75, downgradeLevel = 2},
[4] = {successPercent = 70, downgradeLevel = 3},
[5] = {successPercent = 65, downgradeLevel = 4},
[6] = {successPercent = 60, downgradeLevel = 5},
[7] = {successPercent = 55, downgradeLevel = 0},
[8] = {successPercent = 50, downgradeLevel = 0},
[9] = {successPercent = 45, downgradeLevel = 0}
},
["upgrade"] = { -- how many percent attributes are rised?
attack = 5, -- attack %
defense = 5, -- defense %
extraDefense = 10, -- extra defense %
armor = 5, -- armor %
hitChance = 5, -- hit chance %
}
}
-- // do not touch // --
-- Upgrading system by Azi [Ersiu] --
-- Edited for TFS 1.1 by Zbizu --
local upgrading = {
upValue = function (value, level, percent)
if value < 0 then return 0 end
if level == 0 then return value end
local nVal = value
for i = 1, level do
nVal = nVal + (math.ceil((nVal / 100 * percent)))
end
return nVal > 0 and nVal or value
end,
getLevel = function (item)
local name = Item(item):getName():split('+')
if (#name == 1) then
return 0
end
return math.abs(name[2])
end,
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local it, itx = ItemType(itemEx.itemid), itemEx.uid
if ((it:getWeaponType() > 0 or itemEx.uid:getAttribute(ITEM_ATTRIBUTE_ARMOR) > 0) and not it:isStackable()) then
local level = upgrading.getLevel(itx)
if(level < #conf["level"])then
local nLevel = (conf["level"][(level + 1)].successPercent >= math.random(1, 100)) and (level + 1) or conf["level"][level].downgradeLevel
if(nLevel > level)then
toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Upgrade to level " .. nLevel .. " successful!")
else
toPosition:sendMagicEffect(CONST_ME_BLOCKHIT)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Upgrade failed. Your " .. it:getName() .. " is now on level " .. nLevel .. "")
end
itx:setAttribute(ITEM_ATTRIBUTE_NAME, it:getName()..((nLevel>0) and "+"..nLevel or ""))
itx:setAttribute(ITEM_ATTRIBUTE_ATTACK, upgrading.upValue(it:getAttack(), nLevel, conf["upgrade"].attack))
itx:setAttribute(ITEM_ATTRIBUTE_DEFENSE, upgrading.upValue(it:getDefense(), nLevel, conf["upgrade"].defense))
itx:setAttribute(ITEM_ATTRIBUTE_EXTRADEFENSE, upgrading.upValue(it:getExtraDefense(), nLevel, conf["upgrade"].extraDefense)
itx:setAttribute(ITEM_ATTRIBUTE_ARMOR, upgrading.upValue(it:getArmor(), nLevel, conf["upgrade"].armor))
itx:setAttribute(ITEM_ATTRIBUTE_HITCHANCE, upgrading.upValue(it:getHitChance(), nLevel, conf["upgrade"].hitChance))
item.uid:remove(1)
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "Your " .. it:getName() .. " is on max level alredy.")
end
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "You cannot upgrade this item.")
end
end
Code:
terra = {351,352,353,354,355}
levels = {
[-1] = 2229, ---- skull
[0] = 1294, --- small stone
[1] = 3976, --- worm
[10] = 2149, -- Small Emerald
[12] = 2146, -- Small Sapphire
[15] = 2145, -- Small Diamond
[17] = 2150, -- Small Amethyst
[20] = 2147, -- Small Ruby
[25] = 2144, -- Black Pearls
[27] = 2143, -- White Pearls
[30] = 2157, -- Gold Nuggets
[35] = 2156, --- red gem
[36] = 2158, -- blue gem
[37] = 2155, -- green gem
[38] = 2153, -- violet gem
[39] = 2154, -- yellow gem
[40] = 7761, -- small enchanted emerald
[42] = 7759, -- Small Enchanted Sapphiire
[45] = 7762, -- Small Enchanted Amethyst
[50] = 7760, -- Small Enchanted Ruby
[70] = 2177 -- Life Crystal
}
local config = {
storage = 19333,
chance = 40, --- chance de achar um item ou não
k = 2, --- constante de level.. quanto maior, mais fácil é upar. (a fórmula é level ao quadrado dividido pela constante)
experience = 19334
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local drops = {}
function getDrops(cid)
for i= -1,getPlayerStorageValue(cid, config.storage) do
if levels[i] then
table.insert(drops, levels[i])
end
end
return true
end
if isInArray(terra, itemEx.itemid) then
getDrops(cid)
doPlayerSetStorageValue(cid, config.experience, getPlayerStorageValue(cid, config.experience)+1)
local experience = getPlayerStorageValue(cid, config.experience)
if experience >= (8+(getPlayerStorageValue(cid, config.storage)^2))/config.k then
doPlayerSetStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage)+1)
doPlayerSendTextMessage(cid, 27, "Congratulations, you have leveled! Your currect level is "..getPlayerStorageValue(cid, config.storage) ..".")
if getPlayerStorageValue(cid, config.storage) == 50 then
doPlayerSendTextMessage(cid, 20, "For reaching level "..getPlayerStorageValue(cid, config.storage) .." you have been awarded with Mining Helmet.")
doPlayerAddItem(cid, 7497, 1, true)
end
end
if config.chance >= math.random(1,100) then
if #drops >= 1 then
local item = drops[math.random(1,#drops)]
doPlayerSendTextMessage(cid, 27, "You have found a "..getItemNameById(item)..".")
doPlayerAddItem(cid, item, 1, true)
end
doSendMagicEffect(toPosition, 3)
else
doSendMagicEffect(toPosition, 2)
return true
end
elseif itemEx.itemid == item.itemid then
doPlayerSendTextMessage(cid, 27, "You're currenctly level "..getPlayerStorageValue(cid, config.storage)..".")
else
return false
end
return true
end
Im using TFS 1.3
thank you
Last edited: