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

Action [TFS 1.1] - Slot system

Status
Not open for further replies.
hi, i use script from first post and i get bug in console. How to fix it? TFS 1.1
ymnqswvszmvaegkzqqdtymgdxyspregihrghwnvshypvjznfjzptqxemfkstegbvfnsmzcddvllaxltxlmfspnrjmucmubnbxupw
 
How can I make it so it updates onHealthChange instead of onLogin? As it is players have to re-login to get the bonus
 
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/creaturescripts/scripts/slot.lua:158: attempt to index local 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/slot.lua:158: in function 'equip'
data/creaturescripts/scripts/slot.lua:79: in function <data/creaturescripts/scripts/slot.lua:72>

tfs 1.2
 
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/creaturescripts/scripts/slot.lua:158: attempt to index local 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/creaturescripts/scripts/slot.lua:158: in function 'equip'
data/creaturescripts/scripts/slot.lua:79: in function <data/creaturescripts/scripts/slot.lua:72>

getting this on tfs 1.2, can u help me @zbizu ?
 
Last edited:
i use this script a long time and never problems , a few days has been reported a bug , if use utito tempo/san and relog my skill up and not down.
i have Skill = 10
Itens edited up to = 90
after upgrade = 117

Utito tempo san and first relog
skill = 134
second relog
skill = 137
 
Hello. Is there a way to set a range of values eg. from +1 to +6 instead of %?
 
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:


\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:


\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:


You have to put 0.4 compat file in data/lib folder now. It doesn't exist by default so do this:
32zl0kz.jpg


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
.

how add name itemEx
normal:
You see a demon helmet (Arm:10).
It weighs 29.50 oz.
You hear an evil whispering from inside.

with slot system:
You see a MELEE demon helmet (Arm:10).
It weighs 29.50 oz.
You hear an evil whispering from inside.
 
Status
Not open for further replies.
Back
Top