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

Lua Advanced/Script effect level up

Gaber Zen

Well-Known Member
Joined
Apr 22, 2023
Messages
224
Reaction score
51
Location
Egypt
hello every one
some one can help me i got erro in the script
(otx2-8.60)

[Error - CreatureScript Interface]
data/creaturescripts/scripts/levels.lua:eek:nAdvance
Description:
data/creaturescripts/scripts/levels.lua:39: attempt to get length of local 'data' (a nil value)
stack traceback:
data/creaturescripts/scripts/levels.lua:39: in function <data/creaturescripts/scripts/levels.lua:27>

Lua:
--[[ / / / / / / / / / / / / / / / / / / / / / /
        Advanced OnAdvance Fancy Edition
       The Best OnAdvance Creaturescript
            Scripted by Cybermaster
/ / / / / / / / / / / / / / / / / / / / / / ]]--
 
local area, data =
{
    {0, 1, 1, 1, 0},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {0, 1, 1, 1, 0}
},
{
    [SKILL_FIST] = 'FISTUP!',
    [SKILL_CLUB] = 'CLUBUP!',
    [SKILL_SWORD] = 'SWORDUP!',
    [SKILL_AXE] = 'AXEUP!',
    [SKILL_DISTANCE] = 'DISTANCEUP!',
    [SKILL_SHIELD] = 'SHIELDUP!',
    [SKILL_FISHING] = 'FISHINGUP!',
    [SKILL__MAGLEVEL] = 'MAGICUP!',
    [SKILL__LEVEL] = 'LEVELUP!'
}
 
function onAdvance(cid, skill, oldLevel, newLevel)
    doPlayerSave(cid)
    local center, data = {}, data[skill] --function doSendMagicEffectInArea of Mock
    center.y = math.floor(table.getn(area)/2)+1
    for y = 1, table.getn(area) do
        for x = 1, table.getn(area[y]) do
            if area[y][x] > 0 then
                center.x = math.floor(table.getn(area[y])/2)+1
                doSendMagicEffect({x=getThingPos(cid).x+x-center.x,y=getThingPos(cid).y+y-center.y,z= getThingPos(cid).z},math.random(28,30),cid)
            end
        end
    end   
    for i = 1, #data do
        addEvent(doSendAnimatedText, i*150, getThingPos(cid), data:sub(i,i), i%2 == 0 and TEXTCOLOR_RED or TEXTCOLOR_ORANGE)
    end
    return true
end
 
Solution
Lua:
--[[ / / / / / / / / / / / / / / / / / / / / / /
        Advanced OnAdvance Fancy Edition
       The Best OnAdvance Creaturescript
            Scripted by Cybermaster
/ / / / / / / / / / / / / / / / / / / / / / ]]--
 
local area, data =
{
    {0, 1, 1, 1, 0},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {0, 1, 1, 1, 0}
},
{
    [SKILL_FIST] = 'FISTUP!',
    [SKILL_CLUB] = 'CLUBUP!',
    [SKILL_SWORD] = 'SWORDUP!',
    [SKILL_AXE] = 'AXEUP!',
    [SKILL_DISTANCE] = 'DISTANCEUP!',
    [SKILL_SHIELD] = 'SHIELDUP!',
    [SKILL_FISHING] = 'FISHINGUP!',
    [SKILL__MAGLEVEL] = 'MAGICUP!',
    [SKILL__LEVEL] = 'LEVELUP!'
}
 
function onAdvance(cid, skill, oldLevel, newLevel)
    doPlayerSave(cid)
    local center, data = {}, data[skill] --function doSendMagicEffectInArea of Mock
    if not data then
        return...
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
    doPlayerSave(cid)
    local center, data = {}, data[skill] --function doSendMagicEffectInArea of Mock
    center.y = math.floor(table.getn(area)/2)+1
    for y = 1, table.getn(area) do
        for x = 1, table.getn(area[y]) do
            if area[y][x] > 0 then
                center.x = math.floor(table.getn(area[y])/2)+1
                doSendMagicEffect({x=getThingPos(cid).x+x-center.x,y=getThingPos(cid).y+y-center.y,z= getThingPos(cid).z},math.random(28,30),cid)
            end
        end
    end
    
    local i = 0
    for _, text in pairs(data) do
        addEvent(doSendAnimatedText, i*150, getThingPos(cid), text, i%2 == 0 and TEXTCOLOR_RED or TEXTCOLOR_ORANGE)
        i = i + 1
    end
    return true
end
 
[Error - CreatureScript Interface]
data/creaturescripts/scripts/levels.lua:eek:nAdvance
Description:
data/creaturescripts/scripts/levels.lua:43: bad argument #1 to 'pairs' (table expected, got string)
stack traceback:
[C]: in function 'pairs'
data/creaturescripts/scripts/levels.lua:43: in function <data/creaturescripts/scripts/levels.lua:29>

[Error - CreatureScript Interface]
data/creaturescripts/scripts/levels.lua:eek:nAdvance
Description:
data/creaturescripts/scripts/levels.lua:43: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
[C]: in function 'pairs'
data/creaturescripts/scripts/levels.lua:43: in function <data/creaturescripts/scripts/levels.lua:29>
 
try.
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
    doPlayerSave(cid)
    local center = {}
    local skillData = data[skill]

    center.y = math.floor(table.getn(area) / 2) + 1
    for y = 1, table.getn(area) do
        for x = 1, table.getn(area[y]) do
            if area[y][x] > 0 then
                center.x = math.floor(table.getn(area[y]) / 2) + 1
                doSendMagicEffect({x = getThingPos(cid).x + x - center.x, y = getThingPos(cid).y + y - center.y, z = getThingPos(cid).z}, math.random(28, 30), cid)
            end
        end
    end

    for i = 1, #skillData do
        addEvent(doSendAnimatedText, i * 150, getThingPos(cid), skillData:sub(i, i), i % 2 == 0 and TEXTCOLOR_RED or TEXTCOLOR_ORANGE)
    end

    return true
end
 
hello every one
some one can help me i got erro in the script
(otx2-8.60)

[Error - CreatureScript Interface]
data/creaturescripts/scripts/levels.lua:eek:nAdvance
Description:
data/creaturescripts/scripts/levels.lua:39: attempt to get length of local 'data' (a nil value)
stack traceback:
data/creaturescripts/scripts/levels.lua:39: in function <data/creaturescripts/scripts/levels.lua:27>

Lua:
--[[ / / / / / / / / / / / / / / / / / / / / / /
        Advanced OnAdvance Fancy Edition
       The Best OnAdvance Creaturescript
            Scripted by Cybermaster
/ / / / / / / / / / / / / / / / / / / / / / ]]--
 
local area, data =
{
    {0, 1, 1, 1, 0},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {0, 1, 1, 1, 0}
},
{
    [SKILL_FIST] = 'FISTUP!',
    [SKILL_CLUB] = 'CLUBUP!',
    [SKILL_SWORD] = 'SWORDUP!',
    [SKILL_AXE] = 'AXEUP!',
    [SKILL_DISTANCE] = 'DISTANCEUP!',
    [SKILL_SHIELD] = 'SHIELDUP!',
    [SKILL_FISHING] = 'FISHINGUP!',
    [SKILL__MAGLEVEL] = 'MAGICUP!',
    [SKILL__LEVEL] = 'LEVELUP!'
}
 
function onAdvance(cid, skill, oldLevel, newLevel)
    doPlayerSave(cid)
    local center, data = {}, data[skill] --function doSendMagicEffectInArea of Mock
    center.y = math.floor(table.getn(area)/2)+1
    for y = 1, table.getn(area) do
        for x = 1, table.getn(area[y]) do
            if area[y][x] > 0 then
                center.x = math.floor(table.getn(area[y])/2)+1
                doSendMagicEffect({x=getThingPos(cid).x+x-center.x,y=getThingPos(cid).y+y-center.y,z= getThingPos(cid).z},math.random(28,30),cid)
            end
        end
    end  
    for i = 1, #data do
        addEvent(doSendAnimatedText, i*150, getThingPos(cid), data:sub(i,i), i%2 == 0 and TEXTCOLOR_RED or TEXTCOLOR_ORANGE)
    end
    return true
end
Looks like there's a hiccup in your CreatureScript interface. The error is pointing to line 39 in the "levels.lua" script, where it's trying to get the length of a local variable 'data' that turns out to be nil. It might be a case of uninitialized or missing data.

Without the specific code, it's a bit tricky to pinpoint the issue. But generally, you might want to check if the 'data' variable is properly initialized before trying to get its length. Also, make sure that the data you're trying to access is available at that point in the script.
 
@Gaber Zen

try this?

Lua:
--[[ / / / / / / / / / / / / / / / / / / / / / /
        Advanced OnAdvance Fancy Edition
       The Best OnAdvance Creaturescript
            Scripted by Cybermaster
/ / / / / / / / / / / / / / / / / / / / / / ]]--
 
local area, data =
{
    {0, 1, 1, 1, 0},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {0, 1, 1, 1, 0}
},
{
    [SKILL_FIST] = 'FISTUP!',
    [SKILL_CLUB] = 'CLUBUP!',
    [SKILL_SWORD] = 'SWORDUP!',
    [SKILL_AXE] = 'AXEUP!',
    [SKILL_DISTANCE] = 'DISTANCEUP!',
    [SKILL_SHIELD] = 'SHIELDUP!',
    [SKILL_FISHING] = 'FISHINGUP!',
    [SKILL__MAGLEVEL] = 'MAGICUP!',
    [SKILL__LEVEL] = 'LEVELUP!'
}

function onAdvance(cid, skill, oldLevel, newLevel)
    doPlayerSave(cid)
    local center, skillData = {}, data[skill] -- Rename 'data' to 'skillData'
    center.y = math.floor(table.getn(area)/2)+1
    for y = 1, table.getn(area) do
        for x = 1, table.getn(area[y]) do
            if area[y][x] > 0 then
                center.x = math.floor(table.getn(area[y])/2)+1
                doSendMagicEffect({x=getThingPos(cid).x+x-center.x,y=getThingPos(cid).y+y-center.y,z= getThingPos(cid).z},math.random(28,30),cid)
            end
        end
    end  
    for i = 1, #skillData do -- Use 'skillData' and not 'data'
        addEvent(doSendAnimatedText, i*150, getThingPos(cid), skillData:sub(i,i), i%2 == 0 and TEXTCOLOR_RED or TEXTCOLOR_ORANGE)
    end
    return true
end
 
[Error - CreatureScript Interface]
data/creaturescripts/scripts/levels.lua:eek:nAdvance
Description:
data/creaturescripts/scripts/levels.lua:39: attempt to get length of local 'skillData' (a nil value)
stack traceback:
data/creaturescripts/scripts/levels.lua:39: in function <data/creaturescripts/scripts/levels.lua:27>
 
Lua:
--[[ / / / / / / / / / / / / / / / / / / / / / /
        Advanced OnAdvance Fancy Edition
       The Best OnAdvance Creaturescript
            Scripted by Cybermaster
/ / / / / / / / / / / / / / / / / / / / / / ]]--
 
local area, data =
{
    {0, 1, 1, 1, 0},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {1, 1, 1, 1, 1},
    {0, 1, 1, 1, 0}
},
{
    [SKILL_FIST] = 'FISTUP!',
    [SKILL_CLUB] = 'CLUBUP!',
    [SKILL_SWORD] = 'SWORDUP!',
    [SKILL_AXE] = 'AXEUP!',
    [SKILL_DISTANCE] = 'DISTANCEUP!',
    [SKILL_SHIELD] = 'SHIELDUP!',
    [SKILL_FISHING] = 'FISHINGUP!',
    [SKILL__MAGLEVEL] = 'MAGICUP!',
    [SKILL__LEVEL] = 'LEVELUP!'
}
 
function onAdvance(cid, skill, oldLevel, newLevel)
    doPlayerSave(cid)
    local center, data = {}, data[skill] --function doSendMagicEffectInArea of Mock
    if not data then
        return true
    end
    
    center.y = math.floor(table.getn(area)/2)+1
    for y = 1, table.getn(area) do
        for x = 1, table.getn(area[y]) do
            if area[y][x] > 0 then
                center.x = math.floor(table.getn(area[y])/2)+1
                doSendMagicEffect({x=getThingPos(cid).x+x-center.x,y=getThingPos(cid).y+y-center.y,z= getThingPos(cid).z},math.random(28,30),cid)
            end
        end
    end   
    for i = 1, string.len(data) do
        addEvent(doSendAnimatedText, i*150, getThingPos(cid), data:sub(i,i), i%2 == 0 and TEXTCOLOR_RED or TEXTCOLOR_ORANGE)
    end
    return true
end
 
Solution
Back
Top