Action [TFS 1.1] - Slot system

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
Here it is - first way to make your items better on TFS 1.0.
It took me entire night and a lot of work to find different way for functions so I expect your comment here.

Original thread: http://otland.net/threads/slot-system-multi-slot-no-crashes.90387/
Original author: @Mock

Script updated to 1.1. It may not work on older TFS.

Examples:
07:39 You see a mastermind shield (Def:37).
It weighs 57.00 oz.
[shield.+5%] [mp.+10%] [melee.+2%]


07:40 You see a crossbow (Range:5).
It weighs 40.00 oz.
[shield.+2%] [mp.+14%] [hp.+4%]


Installation:
No support with installation. If you can't install this script, you didn't read with understanding.

add this to global.lua:
Code:
  function getItemAttack(uid) return ItemType(getThing(uid).itemid):getAttack() end
   function getItemDefense(uid) return ItemType(getThing(uid).itemid):getDefense() end
   function getItemArmor(uid) return ItemType(getThing(uid).itemid):getArmor() end
   function getItemWeaponType(uid) return ItemType(getThing(uid).itemid):getWeaponType() end
   function isArmor(uid) if (getItemArmor(uid) ~= 0 and getItemWeaponType(uid) == 0) then return true else return false end end
   function isWeapon(uid) return (getItemWeaponType(uid) > 0 and getItemWeaponType(uid) ~= 4) end
   function isShield(uid) return getItemWeaponType(uid) == 4 end
   function isBow(uid) return (getItemWeaponType(uid) == 5 and (not ItemType(getThing(uid).itemid):isStackable())) end
add this to actions.xml:
Code:
<action itemid="8300" script="slot.lua"/>
slot.lua action
Code:
local conf = {
maxSlotCount=3,
ignoredIds={}
}

function choose(...)
  local arg = {...}
  return arg[math.random(1,#arg)]
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
  if item.uid == 0 or item.itemid == 0 then return false end
  toPosition.stackpos = 255
  if isInArray(conf.ignoredIds, itemEx.itemid) or
  isItemStackable(itemEx.uid) or
  itemEx.itemid == 0 or
  itemEx.type > 1 or
  not(isArmor(itemEx.uid) or isWeapon(itemEx.uid) or isShield(itemEx.uid)) then
  return false
  end
  if isCreature(itemEx.uid) then
  return false
  end
  local nam = Item(itemEx.uid):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
  function getper()
  local n = 1
  for i=1,10 do
  n = n+math.random(0,10)
  if n < 8*i then
  break
  end
  end
  return n
  end
  function getSlotCount(nam)
  local c = 0
  for _ in nam:gmatch('%[(.-)%]') do
  c = c+1
  end
  return c
  end
  if getSlotCount(nam) < conf.maxSlotCount then
  local l = choose('hp','mp','ml','melee','shield','dist')
  local p = getper()
  doSendMagicEffect(toPosition,30)
  nam = nam..' ['..l..'.+'..p..'%]'
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,l..'.+'..p..'%')
  doSetItemSpecialDescription(itemEx.uid, nam)
  doRemoveItem(item.uid,1)
  else
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Slot limit reached.")
  end
  return true
end
add this to creaturescripts.xml:
Code:
<event type="login" name="SlotLogin" script="slot.lua"/>
slot.lua creaturescript
Code:
local conditionMP,conditionHP,conditionML,conditionCLUB,conditionSHI,conditionDIST,conditionAMP = {},{},{},{},{},{},{}
for i=1,300 do
  conditionHP[i] = createConditionObject(CONDITION_ATTRIBUTES)
  setConditionParam(conditionHP[i], CONDITION_PARAM_SUBID, 50)
  setConditionParam(conditionHP[i], CONDITION_PARAM_BUFF_SPELL, 1)
  setConditionParam(conditionHP[i], CONDITION_PARAM_TICKS, -1)
  setConditionParam(conditionHP[i], CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, 100+i)

  conditionMP[i] = createConditionObject(CONDITION_ATTRIBUTES)
  setConditionParam(conditionMP[i], CONDITION_PARAM_SUBID, 51)
  setConditionParam(conditionMP[i], CONDITION_PARAM_BUFF_SPELL, 1)
  setConditionParam(conditionMP[i], CONDITION_PARAM_TICKS, -1)
  setConditionParam(conditionMP[i], CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, 100+i)

  conditionML[i] = createConditionObject(CONDITION_ATTRIBUTES)
  setConditionParam(conditionML[i], CONDITION_PARAM_SUBID, 52)
  setConditionParam(conditionML[i], CONDITION_PARAM_BUFF_SPELL, 1)
  setConditionParam(conditionML[i], CONDITION_PARAM_TICKS, -1)
  setConditionParam(conditionML[i], CONDITION_PARAM_STAT_MAGICPOINTSPERCENT, 100+i)


  conditionCLUB[i] = createConditionObject(CONDITION_ATTRIBUTES)
  setConditionParam(conditionCLUB[i], CONDITION_PARAM_SUBID, 53)
  setConditionParam(conditionCLUB[i], CONDITION_PARAM_BUFF_SPELL, 1)
  setConditionParam(conditionCLUB[i], CONDITION_PARAM_TICKS, -1)
  setConditionParam(conditionCLUB[i], CONDITION_PARAM_SKILL_MELEEPERCENT, 100+i)


  conditionSHI[i] = createConditionObject(CONDITION_ATTRIBUTES)
  setConditionParam(conditionSHI[i], CONDITION_PARAM_SUBID, 54)
  setConditionParam(conditionSHI[i], CONDITION_PARAM_BUFF_SPELL, 1)
  setConditionParam(conditionSHI[i], CONDITION_PARAM_TICKS, -1)
  setConditionParam(conditionSHI[i], CONDITION_PARAM_SKILL_SHIELDPERCENT, 100+i)

  conditionDIST[i] = createConditionObject(CONDITION_ATTRIBUTES)
  setConditionParam(conditionDIST[i], CONDITION_PARAM_SUBID, 55)
  setConditionParam(conditionDIST[i], CONDITION_PARAM_BUFF_SPELL, 1)
  setConditionParam(conditionDIST[i], CONDITION_PARAM_TICKS, -1)
  setConditionParam(conditionDIST[i], CONDITION_PARAM_SKILL_DISTANCEPERCENT, 100+i)
end

function getSlotType(n)
  if not n then
  return false
  end
  if n:match('%[(.+)%]') then
  n = n:match('%[(.+)%]')
  if n == '?' then
  return 0,n
  else
  return n:match('(.-)%.([+-])(%d+)%%')
  end
  else
  return false
  end
end

local function loadSet(cid)
local player = Player(cid)
if not player then return false end
  local t = {}
  for slot=1,9 do
  t[slot] = ''
  local s = getPlayerSlotItem(player,slot).uid
  if s ~= 0 then
  t[slot] = Item(s):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
  end
  end
  return t
end

function chk(cid,f)
  if not Player(cid) then return false end
  local t = loadSet(cid)
  if not t then return false end
 
  for i=1,#f do
  if f[i] ~= t[i] then
  equip(player,nil,slot)
  break
  end
  end
  addEvent(chk,2000,cid,t)
end

function check_slot(aab, i)
  if i == 5 or i == 6 then
  if isWeapon(aab) or isShield(aab) or isBow(aab) then
  return true
  end
  else
  return true
  end
return false
end

function equip(player,item,slot)
  local t = {}
  if item then
  local mm,sinal,qto = getSlotType(Item(item.uid):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION))
  t[mm] = tonumber(qto)
  end
  for i=1,9 do
  if i ~= slot then
  if getPlayerSlotItem(player,i).itemid ~= 0 then
  local aab = getPlayerSlotItem(player,i).uid
  if aab and check_slot(aab,i) then
  for _ in Item(aab):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION):gmatch('(%[.-%])') do
  local mm,sinal,qto2 = getSlotType(_)
  if mm then
  if not t[mm] then
  t[mm] = 0
  end
  t[mm] = t[mm]+tonumber(qto2)
  t[mm] = t[mm] > 300 and 300 or t[mm]
  end
  end
  end
  end
  end
  end
  local fu = 0
  local ca = {}
  local s = ''
  for sl,n in pairs(t) do
  fu = fu+1
  s = s..''..n..'% more of '..sl..'\n'
  if sl == 'hp' then
  player:addCondition(conditionHP[tonumber(n)])
  ca[50] = 1
  doSendTutorial(player,19)
  elseif sl == 'mp' then
  player:addCondition(conditionMP[tonumber(n)])
  ca[51] = 1
  doSendTutorial(player,19)
  elseif sl == 'ml' then
  player:addCondition(conditionML[tonumber(n)])
  ca[52] = 1
  elseif sl == 'melee' then
  player:addCondition(conditionCLUB[tonumber(n)])
  ca[53] = 1
  elseif sl == 'shield' then
  player:addCondition(conditionSHI[tonumber(n)])
  ca[54] = 1
  elseif sl == 'dist' then
  player:addCondition(conditionDIST[tonumber(n)])
  ca[55] = 1
  end
  end
  if fu > 0 then
  for i=50,55 do
  if not ca[i] then
  doRemoveCondition(player:getId(),CONDITION_ATTRIBUTES,i)
  end
  end
  else
  for i=50,55 do
  doRemoveCondition(player:getId(),CONDITION_ATTRIBUTES,i)
  end
  end
  return true
end

function onLogin(player)
  equip(player,nil,slot)
local cid = player:getId()
  addEvent(chk,2000,cid,loadSet(cid))
  return true
end
 
Last edited:
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
most recent slot remover:

actions.xml
Code:
<action itemid="8299" script="slotremove.lua"/>
slotremove.lua
Code:
function getSlotType_full(n)
   if not n then
     return false
   end
   if n:match('%[(.+)%]') then
     n = n:match('%[(.+)%]')
     if n == '?' then
       return 0,n
     else
       return n
     end
   else
     return false
   end
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
item_slots_a = 0
item_slots_n = ""
item_slots_t = {}
   for _ in Item(itemEx.uid):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION):gmatch('(%[.-%])') do
     item_slots_a = item_slots_a + 1
     item_slots_t[item_slots_a] = getSlotType_full(_)
   end
   
   if item_slots_t[1] == nil then
     return false
   end

   for i = 1, #item_slots_t - 1 do
   item_slots_n = item_slots_n .. "[" .. item_slots_t[i] .. "]"
   end
   
   doRemoveItem(item.uid,1)
   doSendMagicEffect(toPosition,CONST_ME_MAGIC_RED)
   doSetItemSpecialDescription(itemEx.uid, item_slots_n)
   doPlayerSendTextMessage(cid,20,"Attribute removed.")
return true
end
 

poii

Excellent OT User
Joined
Nov 11, 2008
Messages
184
Reaction score
8
Im the first to say I love it .. Ill be testing it a little bit more :)
 

poii

Excellent OT User
Joined
Nov 11, 2008
Messages
184
Reaction score
8
Finished testing.. Working 100% no bugs... everyone likes it
 

medanny77

Member
Joined
Dec 25, 2013
Messages
37
Reaction score
3
Thank you all :). It wasnt exactly what i was looking for but i modefied it a little to get it to do what i wanted, here is the script if anyone whats it.
PHP:
local conf = {
maxSlotCount=3,
ignoredIds={}
}

function choose(...)
  local arg = {...}
  return arg[math.random(1,#arg)]
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
  if item.uid == 0 or item.itemid == 0 then return false end
  toPosition.stackpos = 255
  if isInArray(conf.ignoredIds, itemEx.itemid)
  or (getItemWeaponType(itemEx.uid) == 0 and not isArmor(itemEx.uid))
  or itemEx.itemid == 0 or itemEx.type > 1 or isItemStackable(itemEx.uid) then
  return false
  end 
  if isCreature(itemEx.uid) then
  return false
  end
  local nam = Item(itemEx.uid):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
  function getper()
    local n = 1
    for i=1,10 do
      n = n+math.random(0,10)
      if n < 8*i then
        break
      end
    end
    return n
  end

  function getSlotCount(nam)
    local c = 0
    for _ in nam:gmatch('%[(.-)%]') do
      c = c+1
    end
    return c
  end

  local number = math.random(0,100)
  doPlayerSendTextMessage(cid,20,number)

  if number <= 3 then
      doPlayerSendTextMessage(cid,20,"Your item broke in the proccess.")
      doRemoveItem(item.uid,1)
      doRemoveItem(itemEx.uid,1)
      return false
  end

  if number <= 60 then
      doPlayerSendTextMessage(cid,20,"Fail to gain power.")
      doRemoveItem(item.uid,1)
      return false
  end



  if getSlotCount(nam) < conf.maxSlotCount then
    local l = choose('hp','mp','ml','melee','shield','dist')
    local p = getper()
    doSendMagicEffect(toPosition,30)
    nam = nam..' ['..l..'.+'..p..'%]'
    doPlayerSendTextMessage(cid, 20,l..'.+'..p..'%')
    doSetItemSpecialDescription(itemEx.uid, nam)
    doRemoveItem(item.uid,1)
    return false
  else
    doPlayerSendTextMessage(cid, 20,"Slot limit reached.")
  end
  return true
end
With this script you can upgrade wands and rods too, and you have a 60% failing rate and 3% chance of breaking the item. :)
 

medanny77

Member
Joined
Dec 25, 2013
Messages
37
Reaction score
3
mmm ML doesnt work for me any ideas? also i though just taking some part of the code where it restricted wands and rods out would alowed wands and rods and you can update them succesfully but it wont actually increase hp or mp or ml or anything on a wand any ideas?
 
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
Wands don't return weapontype or it's not coded, I'll check it later
 

Eldin

Eldin Projects
Joined
Jun 12, 2008
Messages
1,301
Reaction score
522
Location
Sweden
I must have messed up and can't find the problem uhm, might not have a to recent TFS 1.0 version?

Code:
The Forgotten Server - Version 1.0
Compilied on Dec 11 2013 10:15:34 for arch x86

~~~~~~
>> Loading monsters
>> Loading outfits
>> Checking world type... PVP
>> Loading map
> Map size: 2048x2048.
> Map loading time: 0.11 seconds.
>> Initializing gamestate
>> Loaded all modules, server starting up...
>> The ********** Server Online!

NO PROBLEM TO START UNTIL I TRYED TO LOGIN:

Eldin has logged in.

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/ItemSlot.lua:onLogin
data/lib/001_04_compat.lua:92: attempt to call method 'getWeaponType' (a nil val
ue)
stack traceback:
  [C]: in function 'getWeaponType'
  data/lib/001_04_compat.lua:92: in function 'getItemWeaponType'
  data/lib/001_04_compat.lua:94: in function 'isWeapon'
  data/creaturescripts/scripts/ItemSlot.lua:84: in function 'check_slot'
  data/creaturescripts/scripts/ItemSlot.lua:103: in function 'equip'
  data/creaturescripts/scripts/ItemSlot.lua:163: in function <data/creatur
escripts/scripts/ItemSlot.lua:162>
Eldin has logged out.
My Character DIDN'T "Login" on my screen, just loaded.

Kind Regards,
Eldin.
 
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
Are your slots empty?
Did you made changes in this script?

Edit:
go to creaturescript slot.lua and replace old function to this:
Code:
function check_slot(aab, i)
if aab == nil then return false end
if aab == 0 then return false end
   if i == 5 or i == 6 then
     if isWeapon(aab) or isShield(aab) or isBow(aab) then
       return true
     end
   else
     return true
   end
return false
end
 
Last edited:

Eldin

Eldin Projects
Joined
Jun 12, 2008
Messages
1,301
Reaction score
522
Location
Sweden
I must have to ask you what you mean by slots empty? :)

I added your code, took nothing from Mock ofcourse. (Unless I was ment to take parts?)
I tryed to login after adding the script but the character wont even login at the tibiascreen, it just stands "Eldin has logged in" at the logg.

(As its a login script I don't have to register it at login.lua except on creaturescripts.xml right? Tryed both anyway)

Kind Regards,
Eldin.
 
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
I must have to ask you what you mean by slots empty? :)
no item equipped, in left/right hand

Script registers itself, so you don't need to do it in login.lua.
Try to compile tfs again. If problem still occures in newest version, I'll test it myself.
 

Eldin

Eldin Projects
Joined
Jun 12, 2008
Messages
1,301
Reaction score
522
Location
Sweden
Alright, I'll note you once I got a resault.

Kind Regards,
Eldin.
 

Giddran

Techical Artist
Joined
Sep 8, 2007
Messages
71
Reaction score
25
Location
Sweden
I had some problems when trying to implement the code from this thread, but worked flawless when i used it from his datapack. Could be some problems with the compat file.
 

Eldin

Eldin Projects
Joined
Jun 12, 2008
Messages
1,301
Reaction score
522
Location
Sweden
Updated to latest TFS 1.0,(had a 2 month old version) everything is now working, thanks alot.

Kind Regards,
Eldin.
 

Eldin

Eldin Projects
Joined
Jun 12, 2008
Messages
1,301
Reaction score
522
Location
Sweden
The CreatureScript seem to be blocking me from login in, both this and the one that boost the spells.
I can login directly if I delete the files from CreatureScripts, im confused.

Kind Regards,
Eldin.
 
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
I see. I'll post working version tomorrow.
 
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
Works fine for me, you did something wrong during installation. If your TFS is older than three weeks, please check if it works with newest version before reporting further problems.
(this post contains same script as first post)

let me explain again:
actions.xml:
<action itemid="8300" script="slot.lua"/>
\data\actions\scripts\slot.lua:
Code:
local conf = {
maxSlotCount=3,
ignoredIds={}
}

function choose(...)
  local arg = {...}
  return arg[math.random(1,#arg)]
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
  if item.uid == 0 or item.itemid == 0 then return false end
  toPosition.stackpos = 255
  if isInArray(conf.ignoredIds, itemEx.itemid)
  or (not getItemWeaponType(itemEx.uid) or getItemWeaponType(itemEx.uid) > 5)
  or (getItemWeaponType(itemEx.uid) == 0 and not isArmor(itemEx.uid))
  or itemEx.itemid == 0 or itemEx.type > 1 or isItemStackable(itemEx.uid) then
  return false
  end
  if isCreature(itemEx.uid) then
  return false
  end
  local nam = Item(itemEx.uid):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
  function getper()
  local n = 1
  for i=1,10 do
  n = n+math.random(0,10)
  if n < 8*i then
  break
  end
  end
  return n
  end
  function getSlotCount(nam)
  local c = 0
  for _ in nam:gmatch('%[(.-)%]') do
  c = c+1
  end
  return c
  end
  if getSlotCount(nam) < conf.maxSlotCount then
  local l = choose('hp','mp','ml','melee','shield','dist')
  local p = getper()
  doSendMagicEffect(toPosition,30)
  nam = nam..' ['..l..'.+'..p..'%]'
  doPlayerSendTextMessage(cid, 20,l..'.+'..p..'%')
  doSetItemSpecialDescription(itemEx.uid, nam)
  doRemoveItem(item.uid,1)
  else
  doPlayerSendTextMessage(cid, 20,"Slot limit reached.")
  end
  return true
end
creaturescripts.xml:
<event type="login" name="SlotLogin" script="slot.lua"/>
\data\creaturescripts\scripts\slot.lua
Code:
local conditionMP,conditionHP,conditionML,conditionCLUB,conditionSHI,conditionDIST,conditionAMP = {},{},{},{},{},{},{}
for i=1,300 do
  conditionHP[i] = createConditionObject(CONDITION_ATTRIBUTES)
  setConditionParam(conditionHP[i], CONDITION_PARAM_SUBID, 50)
  setConditionParam(conditionHP[i], CONDITION_PARAM_BUFF_SPELL, 1)
  setConditionParam(conditionHP[i], CONDITION_PARAM_TICKS, -1)
  setConditionParam(conditionHP[i], CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, 100+i)

  conditionMP[i] = createConditionObject(CONDITION_ATTRIBUTES)
  setConditionParam(conditionMP[i], CONDITION_PARAM_SUBID, 51)
  setConditionParam(conditionMP[i], CONDITION_PARAM_BUFF_SPELL, 1)
  setConditionParam(conditionMP[i], CONDITION_PARAM_TICKS, -1)
  setConditionParam(conditionMP[i], CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, 100+i)

  conditionML[i] = createConditionObject(CONDITION_ATTRIBUTES)
  setConditionParam(conditionML[i], CONDITION_PARAM_SUBID, 52)
  setConditionParam(conditionML[i], CONDITION_PARAM_BUFF_SPELL, 1)
  setConditionParam(conditionML[i], CONDITION_PARAM_TICKS, -1)
  setConditionParam(conditionML[i], CONDITION_PARAM_STAT_MAGICLEVELPERCENT, 100+i)


  conditionCLUB[i] = createConditionObject(CONDITION_ATTRIBUTES)
  setConditionParam(conditionCLUB[i], CONDITION_PARAM_SUBID, 53)
  setConditionParam(conditionCLUB[i], CONDITION_PARAM_BUFF_SPELL, 1)
  setConditionParam(conditionCLUB[i], CONDITION_PARAM_TICKS, -1)
  setConditionParam(conditionCLUB[i], CONDITION_PARAM_SKILL_MELEEPERCENT, 100+i)


  conditionSHI[i] = createConditionObject(CONDITION_ATTRIBUTES)
  setConditionParam(conditionSHI[i], CONDITION_PARAM_SUBID, 54)
  setConditionParam(conditionSHI[i], CONDITION_PARAM_BUFF_SPELL, 1)
  setConditionParam(conditionSHI[i], CONDITION_PARAM_TICKS, -1)
  setConditionParam(conditionSHI[i], CONDITION_PARAM_SKILL_SHIELDPERCENT, 100+i)

  conditionDIST[i] = createConditionObject(CONDITION_ATTRIBUTES)
  setConditionParam(conditionDIST[i], CONDITION_PARAM_SUBID, 55)
  setConditionParam(conditionDIST[i], CONDITION_PARAM_BUFF_SPELL, 1)
  setConditionParam(conditionDIST[i], CONDITION_PARAM_TICKS, -1)
  setConditionParam(conditionDIST[i], CONDITION_PARAM_SKILL_DISTANCEPERCENT, 100+i)
end

function getSlotType(n)
  if not n then
  return false
  end
  if n:match('%[(.+)%]') then
  n = n:match('%[(.+)%]')
  if n == '?' then
  return 0,n
  else
  return n:match('(.-)%.([+-])(%d+)%%')
  end
  else
  return false
  end
end

local function loadSet(cid)
  local t = {}
  for slot=1,9 do
  t[slot] = ''
  local s = getPlayerSlotItem(cid,slot).uid
  if s ~= 0 then
  t[slot] = Item(s):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
  end
  end
  return t
end

function chk(cid,f)
  if not isPlayer(cid) then return false end
  local t = loadSet(cid)
  for i=1,#f do
  if f[i] ~= t[i] then
  equip(cid,nil,slot)
  break
  end
  end
  addEvent(chk,2000,cid,t)
end

function check_slot(aab, i)
  if i == 5 or i == 6 then
  if isWeapon(aab) or isShield(aab) or isBow(aab) then
  return true
  end
  else
  return true
  end
return false
end

function equip(cid,item,slot)
  local t = {}
  if item then
  local mm,sinal,qto = getSlotType(Item(item.uid):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION))
  t[mm] = tonumber(qto)
  end
  for i=1,9 do
  if i ~= slot then
  if getPlayerSlotItem(cid,i).itemid ~= 0 then
  local aab = getPlayerSlotItem(cid,i).uid
  if aab and check_slot(aab,i) then
  for _ in Item(aab):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION):gmatch('(%[.-%])') do
  local mm,sinal,qto2 = getSlotType(_)
  if mm then
  if not t[mm] then
  t[mm] = 0
  end
  t[mm] = t[mm]+tonumber(qto2)
  t[mm] = t[mm] > 300 and 300 or t[mm]
  end
  end
  end
  end
  end
  end
  local fu = 0
  local ca = {}
  local s = ''
  for sl,n in pairs(t) do
  fu = fu+1
  s = s..''..n..'% more of '..sl..'\n'
  if sl == 'hp' then
  doAddCondition(cid,conditionHP[tonumber(n)])
  Player(cid):addHealth(Player(cid):getMaxHealth() - Player(cid):getHealth())
  ca[50] = 1
  doSendTutorial(cid,19)
  elseif sl == 'mp' then
  doAddCondition(cid,conditionMP[tonumber(n)])
  Player(cid):addMana(Player(cid):getMaxMana() - Player(cid):getMana())
  ca[51] = 1
  doSendTutorial(cid,19)
  elseif sl == 'ml' then
  doAddCondition(cid,conditionML[tonumber(n)])
  ca[52] = 1
  elseif sl == 'melee' then
  doAddCondition(cid,conditionCLUB[tonumber(n)])
  ca[53] = 1
  elseif sl == 'shield' then
  doAddCondition(cid,conditionSHI[tonumber(n)])
  ca[54] = 1
  elseif sl == 'dist' then
  doAddCondition(cid,conditionDIST[tonumber(n)])
  ca[55] = 1
  end
  end
  if fu > 0 then
  for i=50,55 do
  if not ca[i] then
  doRemoveCondition(cid,CONDITION_ATTRIBUTES,i)
  end
  end
  else
  for i=50,55 do
  doRemoveCondition(cid,CONDITION_ATTRIBUTES,i)
  end
  end
  return true
end

function onLogin(cid)
  equip(cid,nil,slot)
  addEvent(chk,2000,cid,loadSet(cid))
  return true
end
global.lua at end of file:
dofile('data/lib/001_04_compat.lua')
You have to put 0.4 compat file in data/lib folder now. It doesn't exist by default so do this:


go to this folder and create file with name: 001_04_compat.lua
code is too long to paste here so here is link to that lib: http://wklej.to/qc4z3





@Codinablack
@EldinWorld
@Giddran
.
 
Last edited:
Top