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

Fix vocation script

ToloXXX

New Member
Joined
Dec 14, 2014
Messages
93
Reaction score
4
Hi, im using this script but it not reseting any skills :/ see if anyone have any ideas. Running 0.3.6 client 8.60
i get this error:
[05/08/2017 01:39:40] [Error - TalkAction Interface]
[05/08/2017 01:39:40] data/talkactions/scripts/vocation.lua:eek:nSay
[05/08/2017 01:39:40] Description:
[05/08/2017 01:39:40] data/talkactions/scripts/vocation.lua:47: attempt to concatenate local 'id' (a boolean value)
[05/08/2017 01:39:40] stack traceback:
[05/08/2017 01:39:40] data/talkactions/scripts/vocation.lua:47: in function <data/talkactions/scripts/vocation.lua:13>
[05/08/2017 01:39:43] Jesus has logged in.
[05/08/2017 01:41:16] Jesus has logged out.

[05/08/2017 01:41:16] [Error - TalkAction Interface]
[05/08/2017 01:41:16] data/talkactions/scripts/vocation.lua:eek:nSay
[05/08/2017 01:41:16] Description:
[05/08/2017 01:41:16] (internalGetPlayerInfo) Player not found when requesting player info #18



Lua:
-----------------------CONFIG---START-----------------------------------------
local config = {
    removelevel = 1, -- Amount of level taken away.
    itemid = 11207, -- Item ID.
    efekt = 2, -- Effect shown.
    skilafter = 10, -- What skill will the player have after change.
    minlevel = 90, -- What will be min level required?
    magafter = 5, -- What magic level will he recive after change?
    kickTime = 5, -- seconds to kick player.
}
-----------------------CONFIG---END-------------------------------------------
function onSay(cid, words, param)
    local param, oldVoc = param:lower(), 0
    local voc = {
    ['sorcerer'] = {hp = 5, mana = 30, cap = 10, voc = 1},
    ['druid'] = {hp = 5, mana = 30, cap = 10, voc = 2},
    ['paladin'] = {hp = 10, mana = 15, cap = 20, voc = 3},
    ['knight'] = {hp = 15, mana = 5, cap = 25, voc = 4},
    }
    if(getPlayerVocation(cid) > 4)then
        oldVoc = getPlayerVocation(cid)-4
    else
        oldVoc = getPlayerVocation(cid)
    end   
    if(voc[param])then
        if getPlayerLevel(cid) >= config.minlevel then
            if(getPlayerItemCount(cid, config.itemid) > 0)then
                if(oldVoc ~= voc[param].voc)then
                    doPlayerAddLevel(cid, -(config.removelevel)) --Set new level
                    doPlayerSetVocation(cid, voc[param].voc) --Change vocation
                    setCreatureMaxHealth(cid, (185+((getPlayerLevel(cid)-8)*voc[param].hp))) --Set new hp
                    setCreatureMaxMana(cid, (35+((getPlayerLevel(cid)-8)*voc[param].mana))) --Set new mana
                    doPlayerSetMaxCapacity(cid, (470+((getPlayerLevel(cid)-8)*voc[param].cap))) --Set new cap
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your vocation has been changed to ".. param ..".")
                    doSendMagicEffect(getCreaturePosition(cid), 2)
                    doPlayerRemoveItem(cid, config.itemid, 1)
                    doSendMagicEffect(getCreaturePosition(cid), config.efekt)
                    doCreatureAddMana(cid, -((getCreatureMana(cid))-(getCreatureMaxMana(cid))))
                    doCreatureAddHealth(cid, -((getCreatureHealth(cid))-(getCreatureMaxHealth(cid))))
                    doRemoveCreature(cid)
                    local queries = {}
                    local id = getPlayerGUID(cid)
                    for i = 0,6 do
                        table.insert(queries, "update player_skills set value = " .. config.skilafter .. ", count = 0 where skillid = " .. i .. " and player_id = " .. id .. ";")
                        table.insert(queries, "update players set maglevel = ".. config.magafter .. ", promotion = 0;")
                        addEvent(reset, config.kickTime, getCreatureName(cid), queries)
                    end
                else
                     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You already are a ".. param ..".")
                end
            else
                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have a ".. getItemNameById(config.itemid) ..".")
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to be at least level ".. config.minlevel .." to use this command.")
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must say what vocation you want to change into, ie !changevoc sorcerer.")
    end
    return true
end
function reset(p, queries)
    if getPlayerByName(p) ~= nil then
        doRemoveCreature(getCreatureByName(p))
        db.executeQuery("update players set online = 0 where id = " .. getPlayerGUIDByName(p) .. ";")
    end
    for i = 1, table.maxn(queries) do
        if not db.executeQuery(queries[i]) then
            print("[RESET] Unable to execute query: " .. queries[i])
        end
    end
    return true
end
 
Hi, im using this script but it not reseting any skills :/ see if anyone have any ideas. Running 0.3.6 client 8.60
i get this error:
[05/08/2017 01:39:40] [Error - TalkAction Interface]
[05/08/2017 01:39:40] data/talkactions/scripts/vocation.lua:eek:nSay
[05/08/2017 01:39:40] Description:
[05/08/2017 01:39:40] data/talkactions/scripts/vocation.lua:47: attempt to concatenate local 'id' (a boolean value)
[05/08/2017 01:39:40] stack traceback:
[05/08/2017 01:39:40] data/talkactions/scripts/vocation.lua:47: in function <data/talkactions/scripts/vocation.lua:13>
[05/08/2017 01:39:43] Jesus has logged in.
[05/08/2017 01:41:16] Jesus has logged out.

[05/08/2017 01:41:16] [Error - TalkAction Interface]
[05/08/2017 01:41:16] data/talkactions/scripts/vocation.lua:eek:nSay
[05/08/2017 01:41:16] Description:
[05/08/2017 01:41:16] (internalGetPlayerInfo) Player not found when requesting player info #18



Lua:
-----------------------CONFIG---START-----------------------------------------
local config = {
    removelevel = 1, -- Amount of level taken away.
    itemid = 11207, -- Item ID.
    efekt = 2, -- Effect shown.
    skilafter = 10, -- What skill will the player have after change.
    minlevel = 90, -- What will be min level required?
    magafter = 5, -- What magic level will he recive after change?
    kickTime = 5, -- seconds to kick player.
}
-----------------------CONFIG---END-------------------------------------------
function onSay(cid, words, param)
    local param, oldVoc = param:lower(), 0
    local voc = {
    ['sorcerer'] = {hp = 5, mana = 30, cap = 10, voc = 1},
    ['druid'] = {hp = 5, mana = 30, cap = 10, voc = 2},
    ['paladin'] = {hp = 10, mana = 15, cap = 20, voc = 3},
    ['knight'] = {hp = 15, mana = 5, cap = 25, voc = 4},
    }
    if(getPlayerVocation(cid) > 4)then
        oldVoc = getPlayerVocation(cid)-4
    else
        oldVoc = getPlayerVocation(cid)
    end  
    if(voc[param])then
        if getPlayerLevel(cid) >= config.minlevel then
            if(getPlayerItemCount(cid, config.itemid) > 0)then
                if(oldVoc ~= voc[param].voc)then
                    doPlayerAddLevel(cid, -(config.removelevel)) --Set new level
                    doPlayerSetVocation(cid, voc[param].voc) --Change vocation
                    setCreatureMaxHealth(cid, (185+((getPlayerLevel(cid)-8)*voc[param].hp))) --Set new hp
                    setCreatureMaxMana(cid, (35+((getPlayerLevel(cid)-8)*voc[param].mana))) --Set new mana
                    doPlayerSetMaxCapacity(cid, (470+((getPlayerLevel(cid)-8)*voc[param].cap))) --Set new cap
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Your vocation has been changed to ".. param ..".")
                    doSendMagicEffect(getCreaturePosition(cid), 2)
                    doPlayerRemoveItem(cid, config.itemid, 1)
                    doSendMagicEffect(getCreaturePosition(cid), config.efekt)
                    doCreatureAddMana(cid, -((getCreatureMana(cid))-(getCreatureMaxMana(cid))))
                    doCreatureAddHealth(cid, -((getCreatureHealth(cid))-(getCreatureMaxHealth(cid))))
                    doRemoveCreature(cid)
                    local queries = {}
                    local id = getPlayerGUID(cid)
                    for i = 0,6 do
                        table.insert(queries, "update player_skills set value = " .. config.skilafter .. ", count = 0 where skillid = " .. i .. " and player_id = " .. id .. ";")
                        table.insert(queries, "update players set maglevel = ".. config.magafter .. ", promotion = 0;")
                        addEvent(reset, config.kickTime, getCreatureName(cid), queries)
                    end
                else
                     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You already are a ".. param ..".")
                end
            else
                 doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You don't have a ".. getItemNameById(config.itemid) ..".")
            end
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to be at least level ".. config.minlevel .." to use this command.")
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must say what vocation you want to change into, ie !changevoc sorcerer.")
    end
    return true
end
function reset(p, queries)
    if getPlayerByName(p) ~= nil then
        doRemoveCreature(getCreatureByName(p))
        db.executeQuery("update players set online = 0 where id = " .. getPlayerGUIDByName(p) .. ";")
    end
    for i = 1, table.maxn(queries) do
        if not db.executeQuery(queries[i]) then
            print("[RESET] Unable to execute query: " .. queries[i])
        end
    end
    return true
end

Lua:
doRemoveCreature(cid)
local queries = {}
local id = getPlayerGUID(cid)

The player is removed then you try to get the GUID for it? :p

Swap them around, get the GUID first, then remove the player.
 
Lua:
doRemoveCreature(cid)
local queries = {}
local id = getPlayerGUID(cid)

The player is removed then you try to get the GUID for it? :p

Swap them around, get the GUID first, then remove the player.
The addEvent is sending the players name through to the function.
They will likely want to adjust that line as well.
 
Back
Top