• 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!

Working Upgrade System

Extort

New Member
Joined
Apr 14, 2011
Messages
31
Reaction score
0
Can someone direct me to a working upgrade system? Or tell me how to set up my server so it works with the system? I do not know how to add functions really, that is why i am asking.

I am using OTServ (0.6.3) r.5795. For an 8.6 server and every upgrade system i try fails.
It isn't recognizing the functions. Can someone please help me fix this issues because i really liked the upgrade system Mock made. If i can't use that at all maybe someone can show me one i can use? I have used Mocks before on a different 8.6 server so i am confused as to why it isn't working on this one.
 
Yeah i used Mocks, and that is the one i have on my server.
As i said in the first post, Mocks is the one i liked a lot and it didn't work. >.< it is starting to piss me off cuz i really liked mocks.

[EDIT] I removed the wrong error.
 
Last edited:
Seems like i posted the wrong error msg, sorry.
This is the right msg.


I was also asked to post the script i was using, this is it.
Code:
--- Perfect refine system by Mock the bear (MTB).
--- Email: [email][email protected][/email]
local gain = {
gainArmor='&p+1',loseArmor='&p-1',
gainShield='&s+#',loseShield='&s-(#+1)',
gainAttack='&a+#+1',loseAttack='&a-(#+1)-1',
gainDefense='&d+#+2',loseDefense='&d-(#+1)-2',
chance='100/((#*(1/(@/2)))*(@/2))',  -- This equation its good to use items 0-7.
--- This equation must need return chance in % (0-100) 100 = always, 0 = never.
maxlvl = 7,
blocked_ids = {2488,8881}
}
-- &a = weapon attack
-- &d = weapon defense
-- &s = shield defense
-- &p = armor defense
-- # = weapon curr level
-- @ = max level
function isArmor(uid) -- Function by Mock the bear.
         uid = uid or 0
         if getItemArmor(uid) > 0 and getItemAttack(uid) == 0 and getItemDefense(uid) == 0 and getItemWeaponType(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.find(name,'+(%d)')
   return tonumber(lvl) or 0
end
function doTransform(s,uid) -- Function by Mock the bear.
    local c = string.gsub(s,'@',gain.maxlvl)
    local c = string.gsub(c,'&a',getItemAttack(uid))
    local c = string.gsub(c,'&d',getItemDefense(uid))
    local c = string.gsub(c,'&s',getItemDefense(uid))
    local c = string.gsub(c,'&p',getItemArmor(uid))
    local c = string.gsub(c,'#',getWeaponLevel(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.uid) == 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.uid)
        if chance >= math.random(0,100) or item.actionid >= 1000 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.uid) == TRUE then
                 local get = doTransform(gain.gainArmor,itemEx.uid)
                 setItemArmor(itemEx.uid,get)
              elseif isWeapon(itemEx.uid) == TRUE then
                  setItemAttack(itemEx.uid, doTransform(gain.gainAttack,itemEx.uid))
                  setItemDefense(itemEx.uid, doTransform(gain.gainDefense,itemEx.uid))              
              elseif isShield(itemEx.uid) == TRUE then
                  setItemDefense(itemEx.uid, doTransform(gain.gainShield,itemEx.uid))  
              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.uid) == TRUE then
                 setItemArmor(itemEx.uid,doTransform(gain.loseArmor,itemEx.uid))
              elseif isWeapon(itemEx.uid) == TRUE then
                  setItemAttack(itemEx.uid, doTransform(gain.loseAttack,itemEx.uid))
                  setItemDefense(itemEx.uid, doTransform(gain.loseDefense,itemEx.uid))              
              elseif isShield(itemEx.uid) == TRUE then
                  setItemDefense(itemEx.uid, doTransform(gain.loseShield,itemEx.uid))  
              end 
           end
           doSendMagicEffect(toPosition, 9)
        end
     doRemoveItem(item.uid,1)   
     return TRUE
end
 
Last edited:


update ur script to this one:
if return some erros, post here.




Lua:
--- Perfect refine system by Mock the bear (MTB).
--- Email: [email][email protected][/email]
local gain = {
gainArmor='&p+1',loseArmor='&p-1',
gainShield='&s+#',loseShield='&s-(#+1)',
gainAttack='&a+(2*(#))',loseAttack='&a-(2*(#+1))',
gainDefense='&d+(2*(#))',loseDefense='&d-(2*(#+1))',
chance='100/((#*(1/(@/2)))*(@/2))',  -- 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 = 7,
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
 
Just tested it, got the same error just on different lines, if you want me to post it i can.
Untitled-2.png


[EDIT] Added error
 
Nope, i tried on 2 different items. Same error for each. Maybe its the server i am using, OTServ (0.6.3) r.5795?
 
Oh? So far it is one of the better servers i have found. But i am a mapper my roommate is the scripter. Hes just taking a break and being lazy. Then should i ask you, can Mocks upgrade system be used on the server? If so, can you give me a hand and point out what i am doing wrong? Also, yes i am not the best scripter, but i CAN learn. Most people wouldn't give a thought about helping some in-experienced person like me tho in this kind of situation.
 
Back
Top