• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua [help] This creaturescript error

gmstrikker

Well-Known Member
Joined
Jul 30, 2014
Messages
458
Solutions
1
Reaction score
50
It's don't work and now give me this msg error, any can fix this script for me?

AKUMDAo.png


Code:
local spells = {
  [1] = { --sorcerer
  level = {
  [1] = "utevo lux", "exura", "adori",
  [40] = "exevo gran mas vis"
  }
  },
  [2] = { --druid
  level = {
  [1] = "utevo lux", "exura", "adori",
  [28] = "exevo gran mas pox"
  }
  },
  [3] = { --paladin
  level = {
  [1] = "utevo lux", "exura", "exevo con",
  [14] = "exevo con vis"
  }
  },
  [4] = { --knight
  level = {
  [1] = "utevo lux", "exura",
  [5] = "exori"
  }
  }
}
local array_sorc = {1,4,8}
local array_druid = {2,5,9}
local array_paladin = {3,6,10}
local array_knight = {4,7,11}
local text = ""
function onAdvance(player, skill, oldLevel, newLevel)
if skill ~= SKILL_LEVEL then
player = Player(cid)
if player:getVocation():getBase():getId() == array_sorc then
CONFIG = spells[1]
elseif player:getVocation():getBase():getId() == array_druid then
CONFIG = spells[2]
elseif player:getVocation():getBase():getId() == array_paladin then
CONFIG = spells[3]
elseif player:getVocation():getBase():getId() == array_knight then
CONFIG = spells[4]
end
if not CONFIG then
return false
end
EVENT = CONFIG.level[player:getLevel()]
if not EVENT then
return false
end
for i, v in ipairs(EVENT) do
text = text..""..i..", "
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "New spells: "..text.."")
end
return true
end
 
It's don't work and now give me this msg error, any can fix this script for me?
Code:
local spells = {
  [1] = { --sorcerer
  level = {
  [1] = "utevo lux", "exura", "adori",
  [40] = "exevo gran mas vis"
  }
  },
  [2] = { --druid
  level = {
  [1] = "utevo lux", "exura", "adori",
  [28] = "exevo gran mas pox"
  }
  },
  [3] = { --paladin
  level = {
  [1] = "utevo lux", "exura", "exevo con",
  [14] = "exevo con vis"
  }
  },
  [4] = { --knight
  level = {
  [1] = "utevo lux", "exura",
  [5] = "exori"
  }
  }
}
local array_sorc = {1,4,8}
local array_druid = {2,5,9}
local array_paladin = {3,6,10}
local array_knight = {4,7,11}
local text = ""
function onAdvance(player, skill, oldLevel, newLevel)
if skill ~= SKILL_LEVEL then
player = Player(cid)
if player:getVocation():getBase():getId() == array_sorc then
CONFIG = spells[1]
elseif player:getVocation():getBase():getId() == array_druid then
CONFIG = spells[2]
elseif player:getVocation():getBase():getId() == array_paladin then
CONFIG = spells[3]
elseif player:getVocation():getBase():getId() == array_knight then
CONFIG = spells[4]
end
if not CONFIG then
return false
end
EVENT = CONFIG.level[player:getLevel()]
if not EVENT then
return false
end
for i, v in ipairs(EVENT) do
text = text..""..i..", "
end
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "New spells: "..text.."")
end
return true
end
I just find it extremely funny I wrote this spell parser because of you and you don't even use it...
https://otland.net/threads/lua-spells-parser-complete.236308/
 
Code:
local spells = {
    [1] = { --sorcerer
        level = {
            [1] = {"utevo lux", "exura", "adori"},
            [40] = {"exevo gran mas vis"}
        }
    },
    [2] = { --druid
        level = {
            [1] = {"utevo lux", "exura", "adori"},
            [28] = {"exevo gran mas pox"}
        }
    },
    [3] = { --paladin
        level = {
            [1] = {"utevo lux", "exura", "exevo con"},
            [14] = {"exevo con vis"}
        }
    },
    [4] = { --knight
        level = {
            [1] = {"utevo lux", "exura"},
            [5] = {"exori"}
        }
    }
}
local vocs = {
        {1,4,8},
        {2,5,9},
        {3,6,10},
        {4,7,11}
    }

local vocationSpells = {}
function onAdvance(player, skill, oldLevel, newLevel)
    if skill == SKILL_LEVEL then
        for i, class in ipairs(vocs) do
            if isInArray(class, player:getVocation():getId()) then
                vocationSpells = spells[i]
            end
        end
    
        if vocationSpells == nil then
            return false
        end

        local lvl = player:getLevel()
        local playerSpells = vocationSpells.level[lvl]
    
        if #playerSpells == nil or #playerSpells == 0 then
            return false
        end
    
        for x = 1, #playerSpells do
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "New spells for level["..lvl.."]: "..playerSpells[x]..".")
        end
    end
    return true
end
 
Last edited:
I just find it extremely funny I wrote this spell parser because of you and you don't even use it...
https://otland.net/threads/lua-spells-parser-complete.236308/

Im so sorry idk how to use it and whats i can do with this, sorry to my english too :(

Code:
local spells = {
    [1] = { --sorcerer
        level = {
            [1] = {"utevo lux", "exura", "adori"},
            [40] = {"exevo gran mas vis"}
        }
    },
    [2] = { --druid
        level = {
            [1] = {"utevo lux", "exura", "adori"},
            [28] = {"exevo gran mas pox"}
        }
    },
    [3] = { --paladin
        level = {
            [1] = {"utevo lux", "exura", "exevo con"},
            [14] = {"exevo con vis"}
        }
    },
    [4] = { --knight
        level = {
            [1] = {"utevo lux", "exura"},
            [5] = {"exori"}
        }
    }
}
local vocs = {
        {1,4,8},
        {2,5,9},
        {3,6,10},
        {4,7,11}
    }

local vocationSpells = {}
function onAdvance(player, skill, oldLevel, newLevel)
    if skill == SKILL_LEVEL then
        for i, class in ipairs(vocs) do
            if isInArray(class, player:getVocation():getId()) then
                vocationSpells = spells[i]
            end
        end
  
        if vocationSpells == nil then
            return false
        end

        local lvl = player:getLevel()
        local playerSpells = vocationSpells.level[lvl]
  
        if #playerSpells == nil or #playerSpells == 0 then
            return false
        end
  
        for x = 1, #playerSpells do
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "New spells for level["..lvl.."]: "..playerSpells[x]..".")
        end
    end
    return true
end


I have tryed it, no errors, but don't work, when i get ml 1 on knight no give me msg :\
ty for all trys my bro
 
Code:
local spells = {
    [1] = { --sorcerer
        level = {
            [1] = {"utevo lux", "exura", "adori"},
            [40] = {"exevo gran mas vis"}
        }
    },
    [2] = { --druid
        level = {
            [1] = {"utevo lux", "exura", "adori"},
            [28] = {"exevo gran mas pox"}
        }
    },
    [3] = { --paladin
        level = {
            [1] = {"utevo lux", "exura", "exevo con"},
            [14] = {"exevo con vis"}
        }
    },
    [4] = { --knight
        level = {
            [1] = {"utevo lux", "exura"},
            [5] = {"exori"}
        }
    }
}
local vocs = {
        {1,4,8},
        {2,5,9},
        {3,6,10},
        {4,7,11}
    }

local vocationSpells = {}
function onAdvance(player, skill, oldLevel, newLevel)
    if skill == SKILL_LEVEL then
        for i, class in ipairs(vocs) do
            if isInArray(class, player:getVocation():getId()) then
                vocationSpells = spells[i]
            end
        end

        if vocationSpells == nil then
            return false
        end

        local lvl = player:getLevel()
        local playerSpells = vocationSpells.level[lvl]

        if #playerSpells == nil or #playerSpells == 0 then
            return false
        end

        for x = 1, #playerSpells do
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "New spells for level["..lvl.."]: "..playerSpells[x]..".")
        end
    end
    return true
end
Not sure if intentional, but you have the vocation 4 twice. :p
Oh i'm sorry, i dont see topic owner ask :s

I want it to magic level, how to change?

skill == SKILL_MAGIC?
Use the skill ID instead.
Code:
if skill == 7 then
You'll also need to change this appropriately.
Code:
local lvl = player:getLevel()
Code:
0 = Fist
1 = Club
2 = Sword
3 = Axe
4 = Distance
5 = Shield
6 = Fishing
7 = Magic
8 = Level
-- This is TFS 0.3.7, however I doubt it's been changed in 1.x
 
Last edited by a moderator:
Yes I could have just responded with the solution, but I like to at least allow them make an attempt 1st.

By the time most of you are my age I will most likely be dead and gone or just wish I was dead :rolleyes: ...
Although this community might still be here most of us won't and if we don't allow people to start thinking about solutions for themselves they will always be needy.

I re-wrote the script, all they needed to do was change the skill type and they didn't even make an attempt to do so, they asked.. hey the script is not going to self destruct if you change something in it, so take a chance and live a little...
 
I tryed:
Code:
local spells = {
  [1] = { --sorcerer
  level = {
  [1] = {"utevo lux", "exura", "adori"},
  [40] = {"exevo gran mas vis"}
  }
  },
  [2] = { --druid
  level = {
  [1] = {"utevo lux", "exura", "adori"},
  [28] = {"exevo gran mas pox"}
  }
  },
  [3] = { --paladin
  level = {
  [1] = {"utevo lux", "exura", "exevo con"},
  [14] = {"exevo con vis"}
  }
  },
  [4] = { --knight
  level = {
  [1] = {"utevo lux", "exura"},
  [5] = {"exori"}
  }
  }
}
local vocs = {
  {1,4,8},
  {2,5,9},
  {3,6,10},
  {4,7,11}
  }

local vocationSpells = {}
function onAdvance(player, skill, oldLevel, newLevel)
  if skill == 7 then
  for i, class in ipairs(vocs) do
  if isInArray(class, player:getVocation():getId()) then
  vocationSpells = spells[i]
  end
  end
   
  if vocationSpells == nil then
  return false
  end

     local lvl = player:getMagicLevel()
  local playerSpells = vocationSpells.level[lvl]
   
  if #playerSpells == nil or #playerSpells == 0 then
  return false
  end
   
  for x = 1, #playerSpells do
  player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "New spells for level["..lvl.."]: "..playerSpells[x]..".")
  end
  end
  return true
end

error
a0d2IbS.png
 
I tryed:
Code:
local spells = {
  [1] = { --sorcerer
  level = {
  [1] = {"utevo lux", "exura", "adori"},
  [40] = {"exevo gran mas vis"}
  }
  },
  [2] = { --druid
  level = {
  [1] = {"utevo lux", "exura", "adori"},
  [28] = {"exevo gran mas pox"}
  }
  },
  [3] = { --paladin
  level = {
  [1] = {"utevo lux", "exura", "exevo con"},
  [14] = {"exevo con vis"}
  }
  },
  [4] = { --knight
  level = {
  [1] = {"utevo lux", "exura"},
  [5] = {"exori"}
  }
  }
}
local vocs = {
  {1,4,8},
  {2,5,9},
  {3,6,10},
  {4,7,11}
  }

local vocationSpells = {}
function onAdvance(player, skill, oldLevel, newLevel)
  if skill == 7 then
  for i, class in ipairs(vocs) do
  if isInArray(class, player:getVocation():getId()) then
  vocationSpells = spells[i]
  end
  end
 
  if vocationSpells == nil then
  return false
  end

     local lvl = player:getMagicLevel()
  local playerSpells = vocationSpells.level[lvl]
 
  if #playerSpells == nil or #playerSpells == 0 then
  return false
  end
 
  for x = 1, #playerSpells do
  player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "New spells for level["..lvl.."]: "..playerSpells[x]..".")
  end
  end
  return true
end

error
a0d2IbS.png
Code:
player = Player(cid)

You dont have the Player(cid) in your functions
 
It is more than not just not having player = Player(cid) this script won't run in any pre-1.x server unless metatables are built with the appropriate metamethods, so it needs to be downgraded to the distro they are using. Since they never mentioned the distro i just wrote it for 1x+.

I don't understand why almost everyone in support wants to have these key features on their server but refuse to learn the language or framework, yet they all want to make money with 'donations'.
 
It is more than not just not having player = Player(cid) this script won't run in any pre-1.x server unless metatables are built with the appropriate metamethods, so it needs to be downgraded to the distro they are using. Since they never mentioned the distro i just wrote it for 1x+.

I don't understand why almost everyone in support wants to have these key features on their server but refuse to learn the language or framework, yet they all want to make money with 'donations'.

srry, im using 0.4... i will study lua to dont require someone all times ;\
i just want make a server for fun, if i want donates i download a normal global map and put online
 
I tryed it
Code:
local spells = {
[1] = { --sorcerer
level = {
[1] = {"utevo lux", "exura", "adori"},
[40] = {"exevo gran mas vis"}
}
},
[2] = { --druid
level = {
[1] = {"utevo lux", "exura", "adori"},
[28] = {"exevo gran mas pox"}
}
},
[3] = { --paladin
level = {
[1] = {"utevo lux", "exura", "exevo con"},
[14] = {"exevo con vis"}
}
},
[4] = { --knight
level = {
[1] = {"utevo lux", "exura"},
[5] = {"exori"}
}
}
}
local vocs = {
{1,4,8},
{2,5,9},
{3,6,10},
{4,7,11}
}

local vocationSpells = {}

function onAdvance(cid, skill, oldLevel, newLevel)
if skill == 7 then
for i, class in ipairs(vocs) do
if isInArray(class, getPlayerVocation(cid)) then
vocationSpells = spells[i]
end
end

if vocationSpells == nil then
return false
end

local lvl = getPlayerMagLevel(cid)
local playerSpells = vocationSpells.level[lvl]

if #playerSpells == nil or #playerSpells == 0 then
return false
end

for x = 1, #playerSpells do
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "New spells for level["..lvl.."]: "..playerSpells[x]..".")
end
end
return true
end

No erros, no work... Why? Someone can fix or help me to fix?
 
I tryed it
Code:
local spells = {
[1] = { --sorcerer
level = {
[1] = {"utevo lux", "exura", "adori"},
[40] = {"exevo gran mas vis"}
}
},
[2] = { --druid
level = {
[1] = {"utevo lux", "exura", "adori"},
[28] = {"exevo gran mas pox"}
}
},
[3] = { --paladin
level = {
[1] = {"utevo lux", "exura", "exevo con"},
[14] = {"exevo con vis"}
}
},
[4] = { --knight
level = {
[1] = {"utevo lux", "exura"},
[5] = {"exori"}
}
}
}
local vocs = {
{1,4,8},
{2,5,9},
{3,6,10},
{4,7,11}
}

local vocationSpells = {}

function onAdvance(cid, skill, oldLevel, newLevel)
if skill == 7 then
for i, class in ipairs(vocs) do
if isInArray(class, getPlayerVocation(cid)) then
vocationSpells = spells[i]
end
end

if vocationSpells == nil then
return false
end

local lvl = getPlayerMagLevel(cid)
local playerSpells = vocationSpells.level[lvl]

if #playerSpells == nil or #playerSpells == 0 then
return false
end

for x = 1, #playerSpells do
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "New spells for level["..lvl.."]: "..playerSpells[x]..".")
end
end
return true
end

No erros, no work... Why? Someone can fix or help me to fix?
Use
Code:
local lvl = getPlayerMagLevel(cid, false)
And does the magic level you reached in testing have spells?

Is your vocation listed in local vocs?
Code:
local vocs = {
    {1,4,8},
    {2,5,9},
    {3,6,10},
    {4,7,11}
}
I also mentioned earlier in this thread that vocation 4 is in there twice.
That should be fixed as well.

At the top directly beneath the function onAdvance you can add some useful print information as well.. to ensure the script is actually working.
(print sends a message to your console.)
Code:
print(getPlayerMagLevel(cid, false))
print(getPlayerVocation(cid))
 
@Xikini so ty it's work now
Can u help me to remake this script?

I want change this:

It's work:
Code:
19:22 [NEW-SPELLS] Magic Level[4]: utevo lux.
19:22 [NEW-SPELLS] Magic Level[4]: exura.

How i can use to SPELL come with spell name
For exemple:
Code:
19:22 [NEW-SPELL] Name: Intense Healing. Words: Exura Gran. Price: 350.

Someone can help me?
????????????
 
Back
Top