Postado Maio 12, 2017 8 anos Boa Tarde Galera estou com um probleminha, tenho um sistema de scripts no meu ot onde ele sempre funcionou nunca tive problema! ontem o servidor auto-desligo e agora ele não funciona mais, está dando erro erro: [12/5/2017 13:11:1] [Error - Action Interface] [12/5/2017 13:11:1] data/actions/scripts/upsgra.lua:onUse [12/5/2017 13:11:1] Description: [12/5/2017 13:11:1] data/lib/upgradesystem.lua:111: attempt to index field '?' (a nil value) [12/5/2017 13:11:1] stack traceback: [12/5/2017 13:11:1] data/lib/upgradesystem.lua:111: in function 'chance' [12/5/2017 13:11:1] data/lib/upgradesystem.lua:223: in function 'refine' [12/5/2017 13:11:1] data/actions/scripts/upsgra.lua:20: in function <data/actions/scripts/upsgra.lua:1> actions/upgrade Mostrar conteúdo oculto function onUse(cid, item, fromPosition, itemEx, toPosition) if isCreature(itemEx.uid) then return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE) end local obj = UpgradeHandler:new(itemEx) if(obj == false) then return doPlayerSendCancel(cid, UpgradeHandler.message.notupgradeable) end local status = obj:refine(cid, item) if status == "success" then --doSendAnimatedText(toPosition, "Success!", COLOR_GREEN) doSendMagicEffect(toPosition, CONST_ME_MAGIC_GREEN) elseif status == "fail" then --doSendAnimatedText(toPosition, "Fail!", COLOR_RED) doSendMagicEffect(toPosition, CONST_ME_POFF) else doSendMagicEffect(toPosition, CONST_ME_POFF) end return true end lib/upgrade Mostrar conteúdo oculto --[[ PERFECT UPGRADE SYSTEM 2.0 Criado por Oneshot É proibido a venda ou a cópia sem os devidos créditos desse script. ]]-- UpgradeHandler = { levels = { [1] = {100, false, false}, [2] = {90, false, false}, [3] = {75, false, false}, [4] = {60, true, false}, [5] = {45, true, false}, [6] = {30, true, false}, [7] = {25, true, false}, [8] = {20, true, true}, [9] = {15, true, true}, [10] = {10, true, true}, [11] = {10, true, true}, [12] = {5, true, true} }, broadcast = 10, attributes = { ["attack"] = 2, ["defense"] = 1, ["armor"] = 1 }, message = { console = "Trying to refine %s to level +%s with %s%% success rate.", success = "You have upgraded %s to level +%s", fail = "You have failed in upgrade of %s to level +%s", downgrade = "The upgrade level of %s has downgraded to +%s", erase = "The upgrade level of %s has been erased.", maxlevel = "The targeted %s is already on max upgrade level.", notupgradeable = "This item is not upgradeable.", broadcast = "The player %s was successful in upgrading %s to level +%s.\nCongratulations!!", invalidtool = "This is not a valid upgrade tool.", toolrange = "This upgrade tool can only be used in items with level between +%s and +%s" }, tools = { [8310] = {range = {0, 10}, info = {chance = 100, removeable = true}}, }, isEquipment = function(self) local weaponType = self:getItemWeaponType() return ((weaponType > 0 and weaponType < 10) or self.item.armor ~= 0) end, setItemName = function(self, name) return doItemSetAttribute(self.item.uid, "name", name) end, chance = function(self) local chances = {} chances.upgrade = (self.levels[self.item.level + 1][1] or 100) chances.downgrade = (self.item.level * 5) chances.erase = (self.item.level * 3) return chances end } function UpgradeHandler:new(item) local obj, ret = {} obj.item = {} obj.item.level = 0 obj.item.uid = item.uid for key, value in pairs(getItemInfo(item.itemid)) do obj.item[key] = value end ret = setmetatable(obj, {__index = function(self, index) if _G[index] then return (setmetatable({callback = _G[index]}, {__call = function(self, ...) return self.callback(item.uid, ...) end})) else return UpgradeHandler[index] end end}) if ret:isEquipment() then ret:update() return ret end return false end function UpgradeHandler:update() self.item.level = (tonumber(self:getItemName():match("%+(%d+)")) or 0) end function UpgradeHandler:refine(uid, item) if not self.item then doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.notupgradeable) return "miss" end local tool = self.tools[item.itemid] if(tool == nil) then doPlayerSendTextMessage(uid, MESSAGE_EVENT_DEFAULT, self.message.invalidtool) return "miss" end if(self.item.level > #self.levels) then doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.maxlevel:format(self.item.name)) return "miss" end if(self.item.level < tool.range[1] or self.item.level >= tool.range[2]) then doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.toolrange:format(unpack(tool.range))) return "miss" end local chance = (self:chance().upgrade + tool.info.chance) doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_BLUE, self.message.console:format(self.item.name, (self.item.level + 1), math.min(100, chance))) if(tool.info.removeable == true) then doRemoveItem(item.uid, 1) end if chance * 100 > math.random(1, 10000) then doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_ORANGE, self.message.success:format(self.item.name, (self.item.level + 1))) if (self.item.level + 1) >= self.broadcast then doBroadcastMessage(self.message.broadcast:format(getCreatureName(uid), self.item.name, (self.item.level + 1))) end self:setItemName((self.item.level > 0 and self:getItemName():gsub("%+(%d+)", "+".. (self.item.level + 1)) or (self:getItemName() .." +1"))) for key, value in pairs(self.attributes) do if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then doItemSetAttribute(self.item.uid, key, (self.item.level > 0 and getItemAttribute(self.item.uid, key) or self.item[key]) + value) end end return "success" else if(self.levels[self.item.level][3] == true and (self:chance().erase * 100) > math.random(1, 10000)) then doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.erase:format(self.item.name)) self:setItemName(self.item.name) for key, value in pairs(self.attributes) do if self.item[key] > 0 then doItemSetAttribute(self.item.uid, key, self.item[key]) end end elseif(self.levels[self.item.level][2] == true and (self:chance().downgrade * 100) > math.random(1, 10000)) then doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.downgrade:format(self.item.name, (self.item.level - 1))) self:setItemName((self.item.level == 1 and self.item.name or self:getItemName():gsub("%+(%d+)", "+".. (self.item.level - 1)))) for key, value in pairs(self.attributes) do if getItemAttribute(self.item.uid, key) ~= nil or self.item[key] ~= 0 then doItemSetAttribute(self.item.uid, key, (self.item[key] + value * (self.item.level - 1))) end end else doPlayerSendTextMessage(uid, MESSAGE_STATUS_CONSOLE_RED, self.message.fail:format(self.item.name, (self.item.level + 1))) end return "fail" end end
Postado Maio 16, 2017 8 anos Seja mais especifico, qual sua TFS? Talvez voce esteja usando uma versão de script incompativel com a versão do TFS. Tenta... By Mock --- Perfect refine system by Mock the bear (MTB). --- Email: [email]mock_otnet@hotmail.com[/email] local gain = { gainArmor='&p+1',loseArmor='&p-1', gainShield='&s+#',loseShield='&s-(#+1)', gainAttack='&a+(1*(#))',loseAttack='&a-(1*(#+1))', gainDefense='&d+(1*(#))',loseDefense='&d-(1*(#+1))', chance='100', --chance='100/((#*(0/(@/0)))*(@/0))', -- Eu fiz essa equação para variar de +0 a +7 o item --- Essa equação deve retornar em % a chance do item se refinar (0-100) 100 = sempre, 0 = nunca maxlvl = 9, blocked_ids = {2488,8881} } -- &a = weapon attack -- &d = weapon defense -- &s = shield defense -- &p = armor defense -- # = nivel do item -- @ = max level if not setItemName then function setItemName(uid,name) return doItemSetAttribute(uid,'name',name) end function setItemArmor(uid,name) return doItemSetAttribute(uid,'armor',name) end function setItemDefense(uid,name) return doItemSetAttribute(uid,'defense',name) end function setItemAttack(uid,name) return doItemSetAttribute(uid,'attack',name) end function getItemAttack(uid) return getItemAttribute(uid,'attack') end function getItemDefense(uid) return getItemAttribute(uid,'defense') end function getItemArmor(uid) if type(uid) == 'number' then return getItemAttribute(uid,'armor') else return getItemInfo(uid.itemid).armor end end end function isArmor(uid) -- Function by Mock the bear. if (getItemArmor(uid) and getItemArmor(uid) ~= 0 and not getItemInfo(uid.itemid,'attack') and not getItemInfo(uid.itemid,'defense') and getItemWeaponType(uid.uid) == 0) then return true end return false end function isWeapon(uid) -- Function by Mock the bear. uid = uid or 0 local f = getItemWeaponType(uid) if f == 1 or f == 2 or f == 3 then return TRUE end return FALSE end function isShield(uid) -- Function by Mock the bear. uid = uid or 0 if getItemWeaponType(uid) == 4 then return TRUE end return FALSE end function getWeaponLevel(uid) -- Function by Mock the bear. uid = uid or 0 local name = getItemName(uid) local lvl = string.match(name,'+(%d)') return tonumber(lvl) or 0 end function doTransform(s,i) -- Function by Mock the bear. local c = string.gsub(s,'@',gain.maxlvl) local c = string.gsub(c,'&a',getItemAttack(i.uid) or getItemInfo(i.itemid).attack) local c = string.gsub(c,'&d',getItemDefense(i.uid) or getItemInfo(i.itemid).defense) local c = string.gsub(c,'&s',getItemDefense(i.uid) or getItemInfo(i.itemid).defense) local c = string.gsub(c,'&p',getItemArmor(i.uid) or getItemInfo(i.itemid).armor) local c = string.gsub(c,'#',getWeaponLevel(i.uid)) local q,err = loadstring('return '..c) assert(q,err) return assert(q()) end function onUse(cid, item, fromPosition, itemEx, toPosition) toPosition.stackpos = 255 if isInArray(gain.blocked_ids, itemEx.itemid) == TRUE or getItemWeaponType(itemEx.uid) > 4 or (getItemWeaponType(itemEx.uid) == 0 and isArmor(itemEx) == FALSE) or itemEx.itemid == 0 then doPlayerSendTextMessage(cid, 24,"You cant refine this item.") return TRUE end if isCreature(itemEx.uid) == TRUE then return FALSE end local level = getWeaponLevel(itemEx.uid) local chance = doTransform(gain.chance,itemEx) if chance >= math.random(0,100) or item.actionid >= 1000 or (item.actionid == 500 and math.random(0,100) <= 25) then if level+1 > gain.maxlvl then doSendMagicEffect(toPosition, 2) return doPlayerSendTextMessage(cid, 24,"Your item is on max level, you can't upgrade it.") else setItemName(itemEx.uid, getItemNameById(itemEx.itemid)..' +'..(level+1)) doPlayerSendTextMessage(cid, 24,"Your item has been upgrated to +"..(level+1)..".") doSendMagicEffect(toPosition, 12) if isArmor(itemEx) == TRUE then local get = doTransform(gain.gainArmor,itemEx) setItemArmor(itemEx.uid,get) elseif isWeapon(itemEx.uid) == TRUE then setItemAttack(itemEx.uid, doTransform(gain.gainAttack,itemEx)) setItemDefense(itemEx.uid, doTransform(gain.gainDefense,itemEx)) elseif isShield(itemEx.uid) == TRUE then setItemDefense(itemEx.uid, doTransform(gain.gainShield,itemEx)) end end else if level == 0 then doPlayerSendTextMessage(cid, 24,"No effect.") doSendMagicEffect(toPosition, 2) elseif level == gain.maxlvl then doSendMagicEffect(toPosition, 2) return doPlayerSendTextMessage(cid, 24,"Your item is on max level, you can't upgrade it.") elseif level > 0 then if level == 1 then setItemName(itemEx.uid, getItemNameById(itemEx.itemid)) doPlayerSendTextMessage(cid, 24,"Your item back to normal.") else setItemName(itemEx.uid, getItemNameById(itemEx.itemid)..' +'..(level-1)) doPlayerSendTextMessage(cid, 24,"Your item back to +"..(level-1)..".") end if isArmor(itemEx) == TRUE then setItemArmor(itemEx.uid,doTransform(gain.loseArmor ,itemEx)) elseif isWeapon(itemEx.uid) == TRUE then setItemAttack(itemEx.uid, doTransform(gain.loseAttack,itemEx)) setItemDefense(itemEx.uid, doTransform(gain.loseDefense,itemEx)) elseif isShield(itemEx.uid) == TRUE then setItemDefense(itemEx.uid, doTransform(gain.loseShield,itemEx)) end end doSendMagicEffect(toPosition, 9) end doRemoveItem(item.uid,1) return TRUE end
Postado Maio 16, 2017 8 anos Autor Em 16/05/2017 em 09:48, Mirkaan disse: Seja mais especifico, qual sua TFS? Talvez voce esteja usando uma versão de script incompativel com a versão do TFS. Tenta... By Mock --- Perfect refine system by Mock the bear (MTB). --- Email: [email]mock_otnet@hotmail.com[/email] local gain = { gainArmor='&p+1',loseArmor='&p-1', gainShield='&s+#',loseShield='&s-(#+1)', gainAttack='&a+(1*(#))',loseAttack='&a-(1*(#+1))', gainDefense='&d+(1*(#))',loseDefense='&d-(1*(#+1))', chance='100', --chance='100/((#*(0/(@/0)))*(@/0))', -- Eu fiz essa equação para variar de +0 a +7 o item --- Essa equação deve retornar em % a chance do item se refinar (0-100) 100 = sempre, 0 = nunca maxlvl = 9, blocked_ids = {2488,8881} } -- &a = weapon attack -- &d = weapon defense -- &s = shield defense -- &p = armor defense -- # = nivel do item -- @ = max level if not setItemName then function setItemName(uid,name) return doItemSetAttribute(uid,'name',name) end function setItemArmor(uid,name) return doItemSetAttribute(uid,'armor',name) end function setItemDefense(uid,name) return doItemSetAttribute(uid,'defense',name) end function setItemAttack(uid,name) return doItemSetAttribute(uid,'attack',name) end function getItemAttack(uid) return getItemAttribute(uid,'attack') end function getItemDefense(uid) return getItemAttribute(uid,'defense') end function getItemArmor(uid) if type(uid) == 'number' then return getItemAttribute(uid,'armor') else return getItemInfo(uid.itemid).armor end end end function isArmor(uid) -- Function by Mock the bear. if (getItemArmor(uid) and getItemArmor(uid) ~= 0 and not getItemInfo(uid.itemid,'attack') and not getItemInfo(uid.itemid,'defense') and getItemWeaponType(uid.uid) == 0) then return true end return false end function isWeapon(uid) -- Function by Mock the bear. uid = uid or 0 local f = getItemWeaponType(uid) if f == 1 or f == 2 or f == 3 then return TRUE end return FALSE end function isShield(uid) -- Function by Mock the bear. uid = uid or 0 if getItemWeaponType(uid) == 4 then return TRUE end return FALSE end function getWeaponLevel(uid) -- Function by Mock the bear. uid = uid or 0 local name = getItemName(uid) local lvl = string.match(name,'+(%d)') return tonumber(lvl) or 0 end function doTransform(s,i) -- Function by Mock the bear. local c = string.gsub(s,'@',gain.maxlvl) local c = string.gsub(c,'&a',getItemAttack(i.uid) or getItemInfo(i.itemid).attack) local c = string.gsub(c,'&d',getItemDefense(i.uid) or getItemInfo(i.itemid).defense) local c = string.gsub(c,'&s',getItemDefense(i.uid) or getItemInfo(i.itemid).defense) local c = string.gsub(c,'&p',getItemArmor(i.uid) or getItemInfo(i.itemid).armor) local c = string.gsub(c,'#',getWeaponLevel(i.uid)) local q,err = loadstring('return '..c) assert(q,err) return assert(q()) end function onUse(cid, item, fromPosition, itemEx, toPosition) toPosition.stackpos = 255 if isInArray(gain.blocked_ids, itemEx.itemid) == TRUE or getItemWeaponType(itemEx.uid) > 4 or (getItemWeaponType(itemEx.uid) == 0 and isArmor(itemEx) == FALSE) or itemEx.itemid == 0 then doPlayerSendTextMessage(cid, 24,"You cant refine this item.") return TRUE end if isCreature(itemEx.uid) == TRUE then return FALSE end local level = getWeaponLevel(itemEx.uid) local chance = doTransform(gain.chance,itemEx) if chance >= math.random(0,100) or item.actionid >= 1000 or (item.actionid == 500 and math.random(0,100) <= 25) then if level+1 > gain.maxlvl then doSendMagicEffect(toPosition, 2) return doPlayerSendTextMessage(cid, 24,"Your item is on max level, you can't upgrade it.") else setItemName(itemEx.uid, getItemNameById(itemEx.itemid)..' +'..(level+1)) doPlayerSendTextMessage(cid, 24,"Your item has been upgrated to +"..(level+1)..".") doSendMagicEffect(toPosition, 12) if isArmor(itemEx) == TRUE then local get = doTransform(gain.gainArmor,itemEx) setItemArmor(itemEx.uid,get) elseif isWeapon(itemEx.uid) == TRUE then setItemAttack(itemEx.uid, doTransform(gain.gainAttack,itemEx)) setItemDefense(itemEx.uid, doTransform(gain.gainDefense,itemEx)) elseif isShield(itemEx.uid) == TRUE then setItemDefense(itemEx.uid, doTransform(gain.gainShield,itemEx)) end end else if level == 0 then doPlayerSendTextMessage(cid, 24,"No effect.") doSendMagicEffect(toPosition, 2) elseif level == gain.maxlvl then doSendMagicEffect(toPosition, 2) return doPlayerSendTextMessage(cid, 24,"Your item is on max level, you can't upgrade it.") elseif level > 0 then if level == 1 then setItemName(itemEx.uid, getItemNameById(itemEx.itemid)) doPlayerSendTextMessage(cid, 24,"Your item back to normal.") else setItemName(itemEx.uid, getItemNameById(itemEx.itemid)..' +'..(level-1)) doPlayerSendTextMessage(cid, 24,"Your item back to +"..(level-1)..".") end if isArmor(itemEx) == TRUE then setItemArmor(itemEx.uid,doTransform(gain.loseArmor ,itemEx)) elseif isWeapon(itemEx.uid) == TRUE then setItemAttack(itemEx.uid, doTransform(gain.loseAttack,itemEx)) setItemDefense(itemEx.uid, doTransform(gain.loseDefense,itemEx)) elseif isShield(itemEx.uid) == TRUE then setItemDefense(itemEx.uid, doTransform(gain.loseShield,itemEx)) end end doSendMagicEffect(toPosition, 9) end doRemoveItem(item.uid,1) return TRUE end Esse scripts ja testei, porém ele e mais bugado, não tem como voce por limitenos upgrade! mais irei testar, minha tfs 0.3.6
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.