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

TFS 0.X Custom desert quest with error

caquinha

Member
Joined
Aug 8, 2016
Messages
248
Solutions
1
Reaction score
24
I'm trying to do a desert quest for my custom server (it is not a default desert quest)

Code:
-- table based on base vocations
local p = {
    [1] = { -- knight
        player = {
            position = {x = 1550, y = 1678, z = 10},
            toPos = {x = 1589, y = 1636, z = 8}
        },
        item = {
            position = {x = 1551, y = 1678, z = 10},
            itemid = 2376
        }
    },
    [2] = { -- archer
        player = {
            position = {x = 1547, y = 1675, z = 10},
            toPos = {x = 1589, y = 1635, z = 8}
        },
        item = {
            position = {x = 1547, y = 1674, z = 10},
            itemid = 2456
        }
    },
    [3] = { --mage
        player = {
            position = {x = 1544, y = 1678, z = 10},
            toPos = {x = 1588, y = 1635, z = 8}
        },
        item = {
            position = {x = 1573, y = 1678, z = 10},
            itemid = 2175
        }
    }
}
local playerMinimumLevel  = 50
-- get a vocation's base vocation
function getBaseVocation(cid)
    local voc = getPlayerVocation(cid)
    if isInArray({1, 4, 5, 6, 7}, voc) then
        return 1
    elseif isInArray({2, 8, 9, 10}, voc) then
        return 2
    elseif isInArray({3, 11, 12, 13, 14, 15, 16, 17}, voc) then
        return 3
    elseif voc == 0 then
        return 0
    end
end
function onUse(cid)
    local questItems, questPlayers = {}, {}
    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid
        if isPlayer(pid) then
            if getPlayerLevel(pid) >= playerMinimumLevel then
                local j = getBaseVocation( getPlayerVocation(pid))
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    local neededItem = getTileItemById(p[i].item.position, p[i].item.itemid).uid
                    if neededItem > 0 then
                        table.insert(questItems, neededItem)
                        table.insert(questPlayers, pid)
                    else
                        doPlayerSendCancel(cid, "Some items are missing.")
                        return false
                    end
                else
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, they must be atleast level " .. playerMinimumLevel .. ".")
                return false
            end
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    for x = 1, #questPlayers do
        doRemoveItem(questItems[x])
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    doTeleportThing(cid, {x = 1588, y = 1636, z = 8})
    return true
end

but when i try to pull the lever print this errors on console
Code:
[21:55:12.188] [Error - Action Interface] 
[21:55:12.188] data/actions/scripts/desertquest_lever.lua:onUse
[21:55:12.188] Description: 
[21:55:12.188] (internalGetPlayerInfo) Player not found when requesting player info #6

[21:55:12.188] [Error - Action Interface] 
[21:55:12.188] data/actions/scripts/desertquest_lever.lua:onUse
[21:55:12.188] Description: 
[21:55:12.188] (internalGetPlayerInfo) Player not found when requesting player info #6

why?
 
Solution
Code:
1
i 1
2
3

[0:20:49.466] [Error - Action Interface]
[0:20:49.466] data/actions/scripts/desertquest_lever.lua:onUse
[0:20:49.466] Description:
[0:20:49.466] data/actions/scripts/desertquest_lever.lua:60: attempt to concatenate local 'voc' (a boolean value)
[0:20:49.466] stack traceback:
[0:20:49.467]     data/actions/scripts/desertquest_lever.lua:60: in function <data/actions/scripts/desertquest_lever.lua:49>
ah, I see.
We're inputting an incorrect variable.
change
local voc = getBaseVocation( getPlayerVocation(pid))
to
local voc = getBaseVocation(pid)
Well, at a glance there doesn't appear to be an issue, so the best thing to do is to add prints, and find out where it is breaking.
Lua:
-- table based on base vocations
local p = {
    [1] = { -- knight
        player = {
            position = {x = 1550, y = 1678, z = 10},
            toPos = {x = 1589, y = 1636, z = 8}
        },
        item = {
            position = {x = 1551, y = 1678, z = 10},
            itemid = 2376
        }
    },
    [2] = { -- archer
        player = {
            position = {x = 1547, y = 1675, z = 10},
            toPos = {x = 1589, y = 1635, z = 8}
        },
        item = {
            position = {x = 1547, y = 1674, z = 10},
            itemid = 2456
        }
    },
    [3] = { --mage
        player = {
            position = {x = 1544, y = 1678, z = 10},
            toPos = {x = 1588, y = 1635, z = 8}
        },
        item = {
            position = {x = 1573, y = 1678, z = 10},
            itemid = 2175
        }
    }
}
local playerMinimumLevel  = 50
-- get a vocation's base vocation
function getBaseVocation(cid)
    if not isPlayer(cid) then return false end
    local voc = getPlayerVocation(cid)
    if isInArray({1, 4, 5, 6, 7}, voc) then
        return 1
    elseif isInArray({2, 8, 9, 10}, voc) then
        return 2
    elseif isInArray({3, 11, 12, 13, 14, 15, 16, 17}, voc) then
        return 3
    elseif voc == 0 then
        return 0
    end
end
function onUse(cid)
    print(1)
    local questItems, questPlayers = {}, {}
    for i = 1, #p do
        print("i " .. i)
        local pid = getTopCreature(p[i].player.position).uid
        if isPlayer(pid) then
            print(2)
            if getPlayerLevel(pid) >= playerMinimumLevel then
                print(3)
                local j = getBaseVocation( getPlayerVocation(pid))
                print(4)
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    print(5)
                    local neededItem = getTileItemById(p[i].item.position, p[i].item.itemid).uid
                    if neededItem > 0 then
                        print(6)
                        table.insert(questItems, neededItem)
                        table.insert(questPlayers, pid)
                    else
                        print(7)
                        doPlayerSendCancel(cid, "Some items are missing.")
                        return false
                    end
                else
                    print(8)
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                print(9)
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, they must be atleast level " .. playerMinimumLevel .. ".")
                return false
            end
        else
            print(10)
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    print(11)
    for x = 1, #questPlayers do
        print("x " .. x)
        doRemoveItem(questItems[x])
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    print(12)
    doTeleportThing(cid, {x = 1588, y = 1636, z = 8})
    return true
end
 
Well, at a glance there doesn't appear to be an issue, so the best thing to do is to add prints, and find out where it is breaking.
Lua:
-- table based on base vocations
local p = {
    [1] = { -- knight
        player = {
            position = {x = 1550, y = 1678, z = 10},
            toPos = {x = 1589, y = 1636, z = 8}
        },
        item = {
            position = {x = 1551, y = 1678, z = 10},
            itemid = 2376
        }
    },
    [2] = { -- archer
        player = {
            position = {x = 1547, y = 1675, z = 10},
            toPos = {x = 1589, y = 1635, z = 8}
        },
        item = {
            position = {x = 1547, y = 1674, z = 10},
            itemid = 2456
        }
    },
    [3] = { --mage
        player = {
            position = {x = 1544, y = 1678, z = 10},
            toPos = {x = 1588, y = 1635, z = 8}
        },
        item = {
            position = {x = 1573, y = 1678, z = 10},
            itemid = 2175
        }
    }
}
local playerMinimumLevel  = 50
-- get a vocation's base vocation
function getBaseVocation(cid)
    if not isPlayer(cid) then return false end
    local voc = getPlayerVocation(cid)
    if isInArray({1, 4, 5, 6, 7}, voc) then
        return 1
    elseif isInArray({2, 8, 9, 10}, voc) then
        return 2
    elseif isInArray({3, 11, 12, 13, 14, 15, 16, 17}, voc) then
        return 3
    elseif voc == 0 then
        return 0
    end
end
function onUse(cid)
    print(1)
    local questItems, questPlayers = {}, {}
    for i = 1, #p do
        print("i " .. i)
        local pid = getTopCreature(p[i].player.position).uid
        if isPlayer(pid) then
            print(2)
            if getPlayerLevel(pid) >= playerMinimumLevel then
                print(3)
                local j = getBaseVocation( getPlayerVocation(pid))
                print(4)
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    print(5)
                    local neededItem = getTileItemById(p[i].item.position, p[i].item.itemid).uid
                    if neededItem > 0 then
                        print(6)
                        table.insert(questItems, neededItem)
                        table.insert(questPlayers, pid)
                    else
                        print(7)
                        doPlayerSendCancel(cid, "Some items are missing.")
                        return false
                    end
                else
                    print(8)
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                print(9)
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, they must be atleast level " .. playerMinimumLevel .. ".")
                return false
            end
        else
            print(10)
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    print(11)
    for x = 1, #questPlayers do
        print("x " .. x)
        doRemoveItem(questItems[x])
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    print(12)
    doTeleportThing(cid, {x = 1588, y = 1636, z = 8})
    return true
end

Code:
----------------
1
i 1
2
3
4
8
 
No errors but sending that "A vocation is on the wrong spot."
So that sounds like the getBaseVocation isn't supplying a correct number.

Try this, and find out what 'j' is giving
Lua:
-- table based on base vocations
local p = {
    [1] = { -- knight
        player = {
            position = {x = 1550, y = 1678, z = 10},
            toPos = {x = 1589, y = 1636, z = 8}
        },
        item = {
            position = {x = 1551, y = 1678, z = 10},
            itemid = 2376
        }
    },
    [2] = { -- archer
        player = {
            position = {x = 1547, y = 1675, z = 10},
            toPos = {x = 1589, y = 1635, z = 8}
        },
        item = {
            position = {x = 1547, y = 1674, z = 10},
            itemid = 2456
        }
    },
    [3] = { --mage
        player = {
            position = {x = 1544, y = 1678, z = 10},
            toPos = {x = 1588, y = 1635, z = 8}
        },
        item = {
            position = {x = 1573, y = 1678, z = 10},
            itemid = 2175
        }
    }
}
local playerMinimumLevel  = 50
-- get a vocation's base vocation
function getBaseVocation(cid)
    if not isPlayer(cid) then return false end
    local voc = getPlayerVocation(cid)
    if isInArray({1, 4, 5, 6, 7}, voc) then
        return 1
    elseif isInArray({2, 8, 9, 10}, voc) then
        return 2
    elseif isInArray({3, 11, 12, 13, 14, 15, 16, 17}, voc) then
        return 3
    elseif voc == 0 then
        return 0
    end
end
function onUse(cid)
    print(1)
    local questItems, questPlayers = {}, {}
    for i = 1, #p do
        print("i " .. i)
        local pid = getTopCreature(p[i].player.position).uid
        if isPlayer(pid) then
            print(2)
            if getPlayerLevel(pid) >= playerMinimumLevel then
                print(3)
                local voc = getBaseVocation( getPlayerVocation(pid))
                print("voc" .. voc .. "i" .. i)
                print(4)
                if voc == i then
                    print(5)
                    local neededItem = getTileItemById(p[i].item.position, p[i].item.itemid).uid
                    if neededItem > 0 then
                        print(6)
                        table.insert(questItems, neededItem)
                        table.insert(questPlayers, pid)
                    else
                        print(7)
                        doPlayerSendCancel(cid, "Some items are missing.")
                        return false
                    end
                else
                    print(8)
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                print(9)
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, they must be atleast level " .. playerMinimumLevel .. ".")
                return false
            end
        else
            print(10)
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    print(11)
    for x = 1, #questPlayers do
        print("x " .. x)
        doRemoveItem(questItems[x])
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    print(12)
    doTeleportThing(cid, {x = 1588, y = 1636, z = 8})
    return true
end
 
So that sounds like the getBaseVocation isn't supplying a correct number.

Try this, and find out what 'j' is giving
Lua:
-- table based on base vocations
local p = {
    [1] = { -- knight
        player = {
            position = {x = 1550, y = 1678, z = 10},
            toPos = {x = 1589, y = 1636, z = 8}
        },
        item = {
            position = {x = 1551, y = 1678, z = 10},
            itemid = 2376
        }
    },
    [2] = { -- archer
        player = {
            position = {x = 1547, y = 1675, z = 10},
            toPos = {x = 1589, y = 1635, z = 8}
        },
        item = {
            position = {x = 1547, y = 1674, z = 10},
            itemid = 2456
        }
    },
    [3] = { --mage
        player = {
            position = {x = 1544, y = 1678, z = 10},
            toPos = {x = 1588, y = 1635, z = 8}
        },
        item = {
            position = {x = 1573, y = 1678, z = 10},
            itemid = 2175
        }
    }
}
local playerMinimumLevel  = 50
-- get a vocation's base vocation
function getBaseVocation(cid)
    if not isPlayer(cid) then return false end
    local voc = getPlayerVocation(cid)
    if isInArray({1, 4, 5, 6, 7}, voc) then
        return 1
    elseif isInArray({2, 8, 9, 10}, voc) then
        return 2
    elseif isInArray({3, 11, 12, 13, 14, 15, 16, 17}, voc) then
        return 3
    elseif voc == 0 then
        return 0
    end
end
function onUse(cid)
    print(1)
    local questItems, questPlayers = {}, {}
    for i = 1, #p do
        print("i " .. i)
        local pid = getTopCreature(p[i].player.position).uid
        if isPlayer(pid) then
            print(2)
            if getPlayerLevel(pid) >= playerMinimumLevel then
                print(3)
                local voc = getBaseVocation( getPlayerVocation(pid))
                print("voc" .. voc .. "i" .. i)
                print(4)
                if voc == i then
                    print(5)
                    local neededItem = getTileItemById(p[i].item.position, p[i].item.itemid).uid
                    if neededItem > 0 then
                        print(6)
                        table.insert(questItems, neededItem)
                        table.insert(questPlayers, pid)
                    else
                        print(7)
                        doPlayerSendCancel(cid, "Some items are missing.")
                        return false
                    end
                else
                    print(8)
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                print(9)
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, they must be atleast level " .. playerMinimumLevel .. ".")
                return false
            end
        else
            print(10)
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    print(11)
    for x = 1, #questPlayers do
        print("x " .. x)
        doRemoveItem(questItems[x])
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    print(12)
    doTeleportThing(cid, {x = 1588, y = 1636, z = 8})
    return true
end

Code:
1
i 1
2
3

[0:20:49.466] [Error - Action Interface] 
[0:20:49.466] data/actions/scripts/desertquest_lever.lua:onUse
[0:20:49.466] Description: 
[0:20:49.466] data/actions/scripts/desertquest_lever.lua:60: attempt to concatenate local 'voc' (a boolean value)
[0:20:49.466] stack traceback:
[0:20:49.467]     data/actions/scripts/desertquest_lever.lua:60: in function <data/actions/scripts/desertquest_lever.lua:49>
 
Code:
1
i 1
2
3

[0:20:49.466] [Error - Action Interface]
[0:20:49.466] data/actions/scripts/desertquest_lever.lua:onUse
[0:20:49.466] Description:
[0:20:49.466] data/actions/scripts/desertquest_lever.lua:60: attempt to concatenate local 'voc' (a boolean value)
[0:20:49.466] stack traceback:
[0:20:49.467]     data/actions/scripts/desertquest_lever.lua:60: in function <data/actions/scripts/desertquest_lever.lua:49>
ah, I see.
We're inputting an incorrect variable.
change
local voc = getBaseVocation( getPlayerVocation(pid))
to
local voc = getBaseVocation(pid)
 
Solution
Back
Top