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

MoveEvent Slot system - Multi slot (No crashes)

[16/11/2013 14:6:31] [Error - Test Interface]
[16/11/2013 14:6:31] data/creaturescripts/scripts/slot.lua
[16/11/2013 14:6:31] Description:
[16/11/2013 14:6:31] data/creaturescripts/scripts/slot.lua:28: attempt to index local 'conditionCLUB' (a number value)
[16/11/2013 14:6:31] [Error - Event::checkScript] Cannot load script (data/creaturescripts/scripts/slot.lua)

Sorry for this little revive, but i'm getting this error.

How I can solve then?
 
[16/11/2013 14:6:31] [Error - Test Interface]
[16/11/2013 14:6:31] data/creaturescripts/scripts/slot.lua
[16/11/2013 14:6:31] Description:
[16/11/2013 14:6:31] data/creaturescripts/scripts/slot.lua:28: attempt to index local 'conditionCLUB' (a number value)
[16/11/2013 14:6:31] [Error - Event::checkScript] Cannot load script (data/creaturescripts/scripts/slot.lua)

Sorry for this little revive, but i'm getting this error.

How I can solve then?

I have the same error...
 
@up
Same here. The effects dont really work, I only have the description of upgraded items changed, but they don't change any skills while equiped.
 
@up Yes i noticed the same thing... I am pretty certain its because the attributes mod hasn't been added to your source code yet, I am trying to add it to mine but having some problems with my compiler right now....
 
@Codinablack I thought that this could be the problem, but ignored as long as the post says that the only thing we would have to include to sources
was 'hitchance'
 
Yeah true, but however, if you check out the feature attributes mod here http://otland.net/threads/attributes-mod.156649/

then you will see in the file attributes.cpp it doesn't have hitchance, so if you figure the attributes mod doesn't have hitchance then thats probably why it needs hitchance added, as for the system working but the attributes not working in game, that I am certain is because they/we need to add that to our sources, but as for the other problem Idk, what the deal is....
 
someone can explain to me how it works?, how i can add? i dont undertsnad
 
I added the http://otland.net/threads/attributes-mod.156649/

and compiled... no crashes no errors while running the server, been running it for a few days now, and I never got this system to work right, I am however using Azi's upgrade system 3.1 and it is working correctly, but every other system I try I return nearly same exact kind of error... I am wondering if ANYONE can PLEASE help me, I would really love to learn how to add more attributes working with

doItemSetAttribute()

EDIT: My hitChance doesn't work with the upgrade system I got right now, because I apparently can't find the source edit for that either... anyone have it bookmarked? Because I am a terrible noob with the search function here on otland...
 
Last edited:
[16/11/2013 14:6:31] [Error - Test Interface]
[16/11/2013 14:6:31] data/creaturescripts/scripts/slot.lua
[16/11/2013 14:6:31] Description:
[16/11/2013 14:6:31] data/creaturescripts/scripts/slot.lua:28: attempt to index local 'conditionCLUB' (a number value)
[16/11/2013 14:6:31] [Error - Event::checkScript] Cannot load script (data/creaturescripts/scripts/slot.lua)

Sorry for this little revive, but i'm getting this error.

How I can solve then?

Getting exact same error, anyone got an idea what are we missing here?
 
How change the percent what gives the slot? For example. I just want to give a maximum of 10%. of all attributes.
 
Hi. if someone still needs this system here is fixed and it works on TFS 0.4.
You only have to change creaturescripts and the rest is the same:
ceratruescripts:
Code:
---Script by mock the bear!
local conditionMP,conditionHP,conditionML,conditionCLUB,conditionSHI,conditionDIST,conditionAMP = {},{},{},{},{},{},{}
for i=1,100 do ---Carrega as conditions
--- HP
conditionHP[i] = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionHP[i], CONDITION_PARAM_TICKS, -1)
setConditionParam(conditionHP[i], CONDITION_PARAM_STAT_MAXHEALTHPERCENT, 100+i)
setConditionParam(conditionHP[i], CONDITION_PARAM_BUFF, true)
setConditionParam(conditionHP[i], CONDITION_PARAM_SUBID, 50)
--MANA
conditionMP[i] = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionMP[i], CONDITION_PARAM_TICKS, -1)
setConditionParam(conditionMP[i], CONDITION_PARAM_STAT_MAXMANAPERCENT, 100+i)
setConditionParam(conditionMP[i], CONDITION_PARAM_BUFF, true)
setConditionParam(conditionMP[i], CONDITION_PARAM_SUBID, 51)
--Magic level
conditionML[i] = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionML[i], CONDITION_PARAM_TICKS, -1)
setConditionParam(conditionML[i], CONDITION_PARAM_STAT_MAGICLEVELPERCENT, 100+i)
setConditionParam(conditionML[i], CONDITION_PARAM_BUFF, true)
setConditionParam(conditionML[i], CONDITION_PARAM_SUBID, 52)
--club axe sword
conditionCLUB[i] = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionCLUB[i], CONDITION_PARAM_TICKS, -1)
setConditionParam(conditionCLUB[i], CONDITION_PARAM_SKILL_CLUBPERCENT, 100+i)
setConditionParam(conditionCLUB[i], CONDITION_PARAM_SKILL_SWORDPERCENT, 100+i)
setConditionParam(conditionCLUB[i], CONDITION_PARAM_SKILL_AXEPERCENT, 100+i)
setConditionParam(conditionCLUB[i], CONDITION_PARAM_BUFF, true)
setConditionParam(conditionCLUB[i], CONDITION_PARAM_SUBID, 53)
--- shield
conditionSHI[i] = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionSHI[i], CONDITION_PARAM_TICKS, -1)
setConditionParam(conditionSHI[i], CONDITION_PARAM_SKILL_SHIELDPERCENT, 100+i)
setConditionParam(conditionSHI[i], CONDITION_PARAM_BUFF, true)
setConditionParam(conditionSHI[i], CONDITION_PARAM_SUBID, 54)
--- dist
conditionDIST[i] = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionDIST[i], CONDITION_PARAM_TICKS, -1)
setConditionParam(conditionDIST[i], CONDITION_PARAM_SKILL_DISTANCEPERCENT, 100+i)
setConditionParam(conditionDIST[i], CONDITION_PARAM_BUFF, true)
setConditionParam(conditionDIST[i], CONDITION_PARAM_SUBID, 55)
end
function getSlotType(n) --By mock the bear
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] = getItemName(s)
end
end
return t
end
function isInArray2(arr,var) -- Because in some servers it return 1 and 0 and others true and false
for i,b in pairs(arr) do
if var == b then
return true
end
end
return false
end
function check2(cid,i)
if i == 5 or i == 6 then
if isInArray({'head','necklace','backpack','body','legs','feet','ring'},getItemValue(getPlayerSlotItem(cid,i).itemid,'slotType') or '') then
return false
end
end
return true
end
function chk(cid,f)
if not isPlayer(cid) then return 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
items = { ---- Only to get attr: slotType because getItemName dont return it -.-'
_VERSION='1.0 By mock',
XML_DIR='data/items/items.xml',
}
do
local ia = os.clock()
io.write('Loading items')
local i = io.open(items.XML_DIR,'r')
local u = i:read(-1)
i:close()
local u = u:match('<items>(.+)</items>')
for mi,id,mid,name,data,me in u:gmatch('<(%a-)%s*id%s*=%s*"(%d+)"%s*(.-)%s*name%s*=%s*"(.-)"%s*>(.-)</(%a*)>') do
if mi == 'item' and me == 'item' then
local td = {name=name,id=id,type=1}
for key,value in data:gmatch('<attribute key="(.-)" value="(.-)"/>') do
td[key] = value
end
for key,value in mid:gmatch('(.-)="(.-)"') do
td[key] = value
end
items[tonumber(id)] = td

items[name] = td
end
end
for mi,id,mid,name,data in u:gmatch('<(%a-)%s*id%s*=%s*"(%d*)"%s*(.-)%s*name%s*=%s*"(%a+)"%s*/>') do
if mi == 'item' then
local td = {name=name,id=id,type=2}
for key,value in mid:gmatch('(.-)="(.-)"') do
td[key] = value
end
items[tonumber(id)] = td
items[name] = td
end
end
io.write('[done '..os.clock()-ia..']\n')
end
function getItemValue(item,value)
return items[item] and items[item][value]
end
function equip(cid,item,slot) --By mock the bear
local HP = getCreatureHealth(cid)
local MP = getCreatureMana(cid)
local t = {}
if item then
local mm,sinal,qto = getSlotType(getItemName(item.uid))
t[mm] = tonumber(qto)
end
for i=1,9 do -- Not on slot 10 > arrow
if i ~= slot then
if getPlayerSlotItem(cid,i).itemid ~= 0 then
local aab = getPlayerSlotItem(cid,i).uid
if aab and check2(cid,i) then
for _ in getItemName(aab):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] > 100 and 100 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)])
doCreatureAddHealth(cid,HP-getCreatureHealth(cid))
ca[50] = 1
doPlayerSendTutorial(cid,19)
elseif sl == 'mp' then
doAddCondition(cid,conditionMP[tonumber(n)])
doCreatureAddMana(cid,HP-getCreatureMana(cid))
ca[51] = 1
doPlayerSendTutorial(cid,19)
elseif sl == 'ml' then
doAddCondition(cid,conditionML[tonumber(n)])
ca[52] = 1
elseif sl == 'cas' 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
addEvent(doPlayerSendTextMessage,100,cid,24,'You have:\n'..s)
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) ---Script by mock the bear!
equip(cid,nil,slot)
addEvent(chk,2000,cid,loadSet(cid)) -- Here we check!
return TRUE
end
 
I needed it myself too, but I suck in finding strings, therefore I wrote one which removes all slots without detection(and keeps name of random items + upgrades, if you want upgrade system which keeps names from random stats mods pm me):
Lua:
--- Slot removal system
--- Based on Mock the bear (MTB)'s upgrade, slot systems.
--- compatible with Cyko's random stats
local function stringstarts(String,Start)
   return string.sub(String,1,string.len(Start))==Start
end

if not setItemName then
    function setItemName(uid,name)
        return doItemSetAttribute(uid,'name',name)
    end
end

local function getWeaponLevel(uid) -- Function by Mock the bear.
   uid = uid or 0
   local name = getItemName(uid.uid) or getItemInfo(uid.itemid).name or ''
   local lvl = string.match(name,'%s%+(%d+)%s*')
   return tonumber(lvl) or 0
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
local word = "" -- keep it for random items stats mod compatibility
         if item.uid == 0 or item.itemid == 0 then return false end
         toPosition.stackpos = 255
         if isCreature(itemEx.uid) == TRUE then
            return FALSE
         end
      
        -- keep it for random items stats mod compatibility
        if stringstarts(getItemName(itemEx.uid),"rare") then
        word = "rare "
        elseif stringstarts(getItemName(itemEx.uid),"special") then
        word = "special "
        elseif stringstarts(getItemName(itemEx.uid),"legendary") then
        word = "legendary "
        end
     

        local level = getWeaponLevel(itemEx)
        if level > 0 then
            setItemName(itemEx.uid, word..getItemNameById(itemEx.itemid)..' +'..(level))
        else
            setItemName(itemEx.uid, word..getItemNameById(itemEx.itemid))
        end
            addEvent(doPlayerSendTextMessage,500,cid, MESSAGE_LOOT,"All slots on your item are clear now.")
            doSendMagicEffect(toPosition, 12)
            doRemoveItem(item.uid,1)
    return true
end
b1d59c8ff31eb8beffb92403d0a77dd3o.png


It works, but it gets me out of the game
i use, TFS 0.3.6
 
Last edited:
Back
Top