• 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 Dugeon Lever

zabuzo

Well-Known Member
Joined
Jun 10, 2016
Messages
238
Reaction score
54
I want to make a full server based in dugeons but idk how to do the lever system, so i need some help

I made this scripts by searching and copy from others scripts, i need 4 things that i asked in comments -- how to
So just ctrl+f in scripts "-- how to" in scripts
My questions are in the code
-- 1 how to: if there is a team doing players cant go in
-- 2 how to: only accept different IPs
-- 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7
-- 4 how to: after go in have a exausted of 24 hours to go again

Even help with 1 would help a lot

dungeon_lever.lua
Code:
-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- get a vocation's base vocation
function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

-- 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    -- 2 how to: only accept different IPs
    local questPlayers = {}
    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid
        if isPlayer(pid) then
            if getPlayerLevel(pid) >= minLevel and getPlayerLevel(pid) <= maxLevel then
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    -- 3 how to: remove tile per vocation, only accept if have 4 vocation, but dosent matter the position
                else
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end
 
Solution
Code:
[13:17:05.067] [Error - Action Interface]
[13:17:05.067] data/actions/scripts/dungeon_lever.lua:onUse
[13:17:05.067] Description:
[13:17:05.067] data/actions/scripts/dungeon_lever.lua:53: attempt to index global 'Game' (a nil value)
[13:17:05.067] stack traceback:
[13:17:05.067]     data/actions/scripts/dungeon_lever.lua:53: in function <data/actions/scripts/dungeon_lever.lua:51>

[13:17:06.305] [Error - Action Interface]
[13:17:06.305] data/actions/scripts/dungeon_lever.lua:onUse
[13:17:06.305] Description:
[13:17:06.305] data/actions/scripts/dungeon_lever.lua:53: attempt to index global 'Game' (a nil value)
[13:17:06.305] stack traceback:
[13:17:06.305]     data/actions/scripts/dungeon_lever.lua:53: in function...
I did the first one, it seems like the easiest. See picture below on how to setup the x, y ranges and the centerPos variablees. It is just an area that it scans for players, so in your case it will be the room where the players are after teleporting. Make sure you cover the entire area (any tile the player can step on)

Lua:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- get a vocation's base vocation
function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

-- 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end
   
   
    -- 2 how to: only accept different IPs
    local questPlayers = {}
    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid
        if isPlayer(pid) then
            if getPlayerLevel(pid) >= minLevel and getPlayerLevel(pid) <= maxLevel then
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    -- 3 how to: remove tile per vocation, only accept if have 4 vocation, but dosent matter the position
                else
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end



36915
 
I did the first one, it seems like the easiest. See picture below on how to setup the x, y ranges and the centerPos variablees. It is just an area that it scans for players, so in your case it will be the room where the players are after teleporting. Make sure you cover the entire area (any tile the player can step on)

Lua:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- get a vocation's base vocation
function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

-- 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end
  
  
    -- 2 how to: only accept different IPs
    local questPlayers = {}
    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid
        if isPlayer(pid) then
            if getPlayerLevel(pid) >= minLevel and getPlayerLevel(pid) <= maxLevel then
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    -- 3 how to: remove tile per vocation, only accept if have 4 vocation, but dosent matter the position
                else
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end



View attachment 36915

THANK YOU

(X) 1 how to: if there is a team doing players cant go in
() 2 how to: only accept different IPs
() 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7
() 4 how to: after go in have a exausted of 24 hours to go again
 
THANK YOU

(X) 1 how to: if there is a team doing players cant go in
() 2 how to: only accept different IPs
() 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7
() 4 how to: after go in have a exausted of 24 hours to go again

You are welcome! Here; no 2.

Lua:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- get a vocation's base vocation
function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

-- 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end
  
    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid   
        if isPlayer(pid) then
            local newIp = getPlayerIp(pid)
            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
            
            if getPlayerLevel(pid) >= minLevel and getPlayerLevel(pid) <= maxLevel then
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    -- 3 how to: remove tile per vocation, only accept if have 4 vocation, but dosent matter the position
                else
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end
 
Lol!
Thank you so much!

Now there are just 3 left, because i'm fucking dumb and i write 2 asks with number 3
(X) 1 how to: if there is a team doing players cant go in
(X) 2 how to: only accept different IPs
( ) 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7
( ) 3 how to: remove tile per vocation, only accept if have 4 vocation, but dosent matter the position
( ) 4 how to: after go in have a exausted of 24 hours to go again
 
Lol!
Thank you so much!

Now there are just 3 left, because i'm fucking dumb and i write 2 asks with number 3
(X) 1 how to: if there is a team doing players cant go in
(X) 2 how to: only accept different IPs
( ) 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7
( ) 3 how to: remove tile per vocation, only accept if have 4 vocation, but dosent matter the position
( ) 4 how to: after go in have a exausted of 24 hours to go again

haha no worries, there number 4 :cool:

Lua:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- get a vocation's base vocation
function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

-- 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end
 
    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid   
        if isPlayer(pid) then
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                doPlayerSendCancel(cid, getPlayerName(pid) .. " cannot participate right now.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
            
            if getPlayerLevel(pid) >= minLevel and getPlayerLevel(pid) <= maxLevel then
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    -- 3 how to: remove tile per vocation, only accept if have 4 vocation, but dosent matter the position
                else
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end
 
haha no worries, there number 4 :cool:

Lua:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- get a vocation's base vocation
function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

-- 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end

    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid  
        if isPlayer(pid) then
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                doPlayerSendCancel(cid, getPlayerName(pid) .. " cannot participate right now.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
           
            if getPlayerLevel(pid) >= minLevel and getPlayerLevel(pid) <= maxLevel then
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    -- 3 how to: remove tile per vocation, only accept if have 4 vocation, but dosent matter the position
                else
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end

lol u do know everything!? haha

what is it 86400?
can i show how many minutes left to do dungeon again?

is it right \/
Code:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- get a vocation's base vocation
function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

-- 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end
 
    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid   
        if isPlayer(pid) then
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                local exaustedMins = math.ceil(((getPlayerStorageValue(cid, 5824)) - timeNow)/60)
                doPlayerSendCancel(cid, getPlayerName(pid) .. " have to wait " .. exaustedMins .. " minutes to do this dugeon again.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
            
            if getPlayerLevel(pid) >= minLevel and getPlayerLevel(pid) <= maxLevel then
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    -- 3 how to: remove tile per vocation, only accept if have 4 vocation, but dosent matter the position
                else
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end
 
lol u do know everything!? haha

what is it 86400?
can i show how many minutes left to do dungeon again?

is it right \/
Code:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- get a vocation's base vocation
function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

-- 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end

    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid  
        if isPlayer(pid) then
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                local exaustedMins = math.ceil(((getPlayerStorageValue(cid, 5824)) - timeNow)/60)
                doPlayerSendCancel(cid, getPlayerName(pid) .. " have to wait " .. exaustedMins .. " minutes to do this dugeon again.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
           
            if getPlayerLevel(pid) >= minLevel and getPlayerLevel(pid) <= maxLevel then
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    -- 3 how to: remove tile per vocation, only accept if have 4 vocation, but dosent matter the position
                else
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end

86400 is the amount of seconds in a day

yes the code is ok, change timeNow to os.time()
 
So this is the script for now:
Code:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- get a vocation's base vocation
function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

-- 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end
 
    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid   
        if isPlayer(pid) then
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                local exaustedMins = math.ceil(((getPlayerStorageValue(cid, 5824)) - os.time())/60)
                doPlayerSendCancel(cid, getPlayerName(pid) .. " have to wait " .. exaustedMins .. " minutes to do this dugeon again.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
            
            if getPlayerLevel(pid) >= minLevel and getPlayerLevel(pid) <= maxLevel then
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    -- 3 how to: remove tile per vocation, only accept if have 4 vocation, but dosent matter the position
                else
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end

There is only this lefft:
(X) 1 how to: if there is a team doing players cant go in
(X) 2 how to: only accept different IPs
( ) 3 how to: after enter have 15 min to do a quest, if dont teleport to 956/1039/7
( ) 3 how to: remove tile per vocation, only accept if have 4 vocation, but dosent matter the position
(X) 4 how to: after go in have a exausted of 24 hours to go again
 
There is only this lefft:
(X) 1 how to: if there is a team doing players cant go in
(X) 2 how to: only accept different IPs
( ) 3 how to: after enter in the dungeon, have 15 min to open the chest, if dont teleport to 956/1039/7
(X) 4 how to: after go in have a exausted of 24 hours to go again
( ) 5 how to: still need 4 vocation, but dosent matter the position (not based on desert quest where wich vocation have to be in a specific tile)

Code:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- get a vocation's base vocation
function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

-- 3 how to: after enter in the dungeon, have 15 min to open the chest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end
 
    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid   
        if isPlayer(pid) then
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                local exaustedMins = math.ceil(((getPlayerStorageValue(cid, 5824)) - os.time())/60)
                doPlayerSendCancel(cid, getPlayerName(pid) .. " have to wait " .. exaustedMins .. " minutes to do this dugeon again.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
            
            if getPlayerLevel(pid) >= minLevel and getPlayerLevel(pid) <= maxLevel then
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    -- 5 how to: still need 4 vocation, but dosent matter the position (not based on desert quest where wich vocation have to be in a specific tile)
                else
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end
 
---<movevent event="StepIn" actionid="47401" script="test.lua"/>
--data/movements/movements.xml^ actionid must match desired tile action id
local desiredposition = {x="32103",y="32172",z="8"}
-- desiredposition change that in dosummoncreature if you want customxyz
local monstertospawn = "rat"
local seconds = 0

local config =
{
makeExhaustion = 10, --make exhaust? put the exhaust time in seconds or false if it won't make exhaustion
exhaustionStorage = 51615,
}

function onStepIn(cid, item, position, fromPosition, player)
if getPlayerLevel(cid) > 1 then
-- npcHandler:eek:nThink() -- we are not handling anything via NPC so i guess it is not needed we will see
if (exhaustion.get (cid, config.exhaustionStorage)) then
return doPlayerSendCancel (cid, "Wait "..exhaustion.get (cid, config.exhaustionStorage).. " seconds to do it again.")
end

if (config.makeExhaustion ~= false and tonumber(config.makeExhaustion)) then
-- math.random in 1 out of 2 chances 50% or in 1,100 1% chance
chance = math.random(1,2)
if chance == 1 then
exhaustion.set (cid, config.exhaustionStorage, config.makeExhaustion)
doSummonCreature(monstertospawn, desiredposition)
doSummonCreature(monstertospawn, position)
doPlayerSendTextMessage(cid,21,"You have been ambushed!")
stopEvent(event)
else
return doPlayerSendCancel (cid, "IT didnt happen this time maybe try again")
-- return false once its debugged
end
end
end
end
take my exhaust script to add time to yours
 
There is only this lefft:
(X) 1 how to: if there is a team doing players cant go in
(X) 2 how to: only accept different IPs
( ) 3 how to: after enter in the dungeon, have 15 min to open the chest, if dont teleport to 956/1039/7
(X) 4 how to: after go in have a exausted of 24 hours to go again
( ) 5 how to: still need 4 vocation, but dosent matter the position (not based on desert quest where wich vocation have to be in a specific tile)

Code:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- get a vocation's base vocation
function getBaseVocation(vocation)
    if vocation >= 5 and vocation <= 8 then
        return vocation - 4
    elseif vocation >= 9 and vocation <= 12 then
        return vocation - 8
    end
    return vocation
end

-- 3 how to: after enter in the dungeon, have 15 min to open the chest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end

    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid  
        if isPlayer(pid) then
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                local exaustedMins = math.ceil(((getPlayerStorageValue(cid, 5824)) - os.time())/60)
                doPlayerSendCancel(cid, getPlayerName(pid) .. " have to wait " .. exaustedMins .. " minutes to do this dugeon again.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
           
            if getPlayerLevel(pid) >= minLevel and getPlayerLevel(pid) <= maxLevel then
                if getBaseVocation( getPlayerVocation(pid) ) == i then
                    -- 5 how to: still need 4 vocation, but dosent matter the position (not based on desert quest where wich vocation have to be in a specific tile)
                else
                    doPlayerSendCancel(cid, "A vocation is on the wrong spot.")
                    return false
                end
            else
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end

removed getBaseVocation function. This is number 5

Lua:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- 3 how to: after enter in the dungeon, have 15 min to open the chest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end
 
    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    local SORCERER, DRUID, PALADIN, KNIGHT = false, false, false, false

    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid   
        if isPlayer(pid) then
            local voc = getPlayerVocation(pid)
            if voc == 1 or voc == 5 then
                SORCERER = true
            elseif voc == 2 or voc == 6 then
                DRUID = true
            elseif voc == 3 or voc == 7 then
                PALADIN = true
            elseif voc == 4 or voc == 8 then
                KNIGHT = true
            end
            
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                local exaustedMins = math.ceil(((getPlayerStorageValue(cid, 5824)) - os.time())/60)
                doPlayerSendCancel(cid, getPlayerName(pid) .. " have to wait " .. exaustedMins .. " minutes to do this dugeon again.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
            
            if not getPlayerLevel(pid) >= minLevel and not getPlayerLevel(pid) <= maxLevel then
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
            
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    
    if SORCERER == false or DRUID == false or PALADIN == false or KNIGHT == false then
        doPlayerSendCancel(cid, "Four different vocations are required.")
        return false
    end
    
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end
 
Only one left!
(X) 1 how to: if there is a team doing players cant go in
(X) 2 how to: only accept different IPs
( ) 3 how to: after enter in the dungeon, have 15 min to open the chest, if dont teleport to 956/1039/7
(X) 4 how to: after go in have a exausted of 24 hours to go again
(X) 5 how to: still need 4 vocation, but dosent matter the position (not based on desert quest where wich vocation have to be in a specific tile)

Code:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- 3 how to: after enter in the dungeon, have 15 min to open the chest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end
 
    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    local SORCERER, DRUID, PALADIN, KNIGHT = false, false, false, false

    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid   
        if isPlayer(pid) then
            local voc = getPlayerVocation(pid)
            if voc == 1 or voc == 5 or voc == 9 then
                SORCERER = true
            elseif voc == 2 or voc == 6 or voc == 10 then
                DRUID = true
            elseif voc == 3 or voc == 7 or voc == 11 then
                PALADIN = true
            elseif voc == 4 or voc == 8 or voc == 12 then
                KNIGHT = true
            end
            
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                local exaustedMins = math.ceil(((getPlayerStorageValue(cid, 5824)) - os.time())/60)
                doPlayerSendCancel(cid, getPlayerName(pid) .. " have to wait " .. exaustedMins .. " minutes to do this dugeon again.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
            
            if not getPlayerLevel(pid) >= minLevel and not getPlayerLevel(pid) <= maxLevel then
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
            
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    
    if SORCERER == false or DRUID == false or PALADIN == false or KNIGHT == false then
        doPlayerSendCancel(cid, "Four different vocations are required.")
        return false
    end
    
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end
 
Only one left!
(X) 1 how to: if there is a team doing players cant go in
(X) 2 how to: only accept different IPs
( ) 3 how to: after enter in the dungeon, have 15 min to open the chest, if dont teleport to 956/1039/7
(X) 4 how to: after go in have a exausted of 24 hours to go again
(X) 5 how to: still need 4 vocation, but dosent matter the position (not based on desert quest where wich vocation have to be in a specific tile)

Code:
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- 3 how to: after enter in the dungeon, have 15 min to open the chest, if dont teleport to 956/1039/7


function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end

    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    local SORCERER, DRUID, PALADIN, KNIGHT = false, false, false, false

    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid  
        if isPlayer(pid) then
            local voc = getPlayerVocation(pid)
            if voc == 1 or voc == 5 or voc == 9 then
                SORCERER = true
            elseif voc == 2 or voc == 6 or voc == 10 then
                DRUID = true
            elseif voc == 3 or voc == 7 or voc == 11 then
                PALADIN = true
            elseif voc == 4 or voc == 8 or voc == 12 then
                KNIGHT = true
            end
           
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                local exaustedMins = math.ceil(((getPlayerStorageValue(cid, 5824)) - os.time())/60)
                doPlayerSendCancel(cid, getPlayerName(pid) .. " have to wait " .. exaustedMins .. " minutes to do this dugeon again.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
           
            if not getPlayerLevel(pid) >= minLevel and not getPlayerLevel(pid) <= maxLevel then
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
           
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
   
    if SORCERER == false or DRUID == false or PALADIN == false or KNIGHT == false then
        doPlayerSendCancel(cid, "Four different vocations are required.")
        return false
    end
   
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    return true
end

bump
 
I'm sorry but I don't have the time to code it for you.

The first way you can do it - use game storages instead of searing fire:
This is what I used in my old server.
You will need to set a function to clear the dungeon in 15 min - scan the area, kick the players and remove the monsters - but if the first team already exit the dungeon and there is a new team on it, you cannot kick this new team.

You must have a certain amount of dungeons, so, use a game storage for each one of them.
When the server starts, reset the value of the game storages to 0.
When a team enters the dungeon, add +1 to the current value of the game storage of the respective dungeon.

The kick function:
Check the value of the game storage - only kick players and remove monsters if the value = 1.
In the end of the function - regardless if you cleared the dungeon or not - reduce the game storage value in -1.

The second way you can do it - use a searing fire:
If you explore a global map data pack, you can see that there is a searing fire around boss rooms, and also in the svargrond arena.
The searing fire is used to kick the player if he runs out of time, and it is restored when a new player enters the room.
You can copy the code and adapt it to your dungeon.
 

3

Lua:
local kickTo = Position(x = 956, y = 1039, z = 7) -- kick players after 15 minutes to this position
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- 3 how to: after enter in the dungeon, have 15 min to open the chest, if dont teleport to 956/1039/7
local function kickPlayers(players)
    local spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, spec in ipairs(spectators) do
        local specName = getPlayerName(spec)
        for _, player in ipairs(players) do
            if getPlayerName(player) == specName then
                doTeleportThing(spec, kickTo, false)
            end
        end
    end
end

function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    local spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end
 
    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    local oldPlayers = {}
    local SORCERER, DRUID, PALADIN, KNIGHT = false, false, false, false

    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid   
        if isPlayer(pid) then
            local voc = getPlayerVocation(pid)
            if voc == 1 or voc == 5 or voc == 9 then
                SORCERER = true
            elseif voc == 2 or voc == 6 or voc == 10 then
                DRUID = true
            elseif voc == 3 or voc == 7 or voc == 11 then
                PALADIN = true
            elseif voc == 4 or voc == 8 or voc == 12 then
                KNIGHT = true
            end
            
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                local exaustedMins = math.ceil(((getPlayerStorageValue(cid, 5824)) - os.time())/60)
                doPlayerSendCancel(cid, getPlayerName(pid) .. " have to wait " .. exaustedMins .. " minutes to do this dugeon again.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
            
            if not getPlayerLevel(pid) >= minLevel and not getPlayerLevel(pid) <= maxLevel then
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
            oldPlayers[#oldPlayers + 1] = pid
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    
    if SORCERER == false or DRUID == false or PALADIN == false or KNIGHT == false then
        doPlayerSendCancel(cid, "Four different vocations are required.")
        return false
    end
    
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    
    addEvent(kickPlayers, 900000, oldPlayers)
    return true
end
 
3

Lua:
local kickTo = Position(x = 956, y = 1039, z = 7) -- kick players after 15 minutes to this position
local centerPos = Position(x = 1000, y = 1000, z = 7)
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- 3 how to: after enter in the dungeon, have 15 min to open the chest, if dont teleport to 956/1039/7
local function kickPlayers(players)
    local spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, spec in ipairs(spectators) do
        local specName = getPlayerName(spec)
        for _, player in ipairs(players) do
            if getPlayerName(player) == specName then
                doTeleportThing(spec, kickTo, false)
            end
        end
    end
end

function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    local spectators = Game.getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end

    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    local oldPlayers = {}
    local SORCERER, DRUID, PALADIN, KNIGHT = false, false, false, false

    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid  
        if isPlayer(pid) then
            local voc = getPlayerVocation(pid)
            if voc == 1 or voc == 5 or voc == 9 then
                SORCERER = true
            elseif voc == 2 or voc == 6 or voc == 10 then
                DRUID = true
            elseif voc == 3 or voc == 7 or voc == 11 then
                PALADIN = true
            elseif voc == 4 or voc == 8 or voc == 12 then
                KNIGHT = true
            end
           
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                local exaustedMins = math.ceil(((getPlayerStorageValue(cid, 5824)) - os.time())/60)
                doPlayerSendCancel(cid, getPlayerName(pid) .. " have to wait " .. exaustedMins .. " minutes to do this dugeon again.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
           
            if not getPlayerLevel(pid) >= minLevel and not getPlayerLevel(pid) <= maxLevel then
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
            oldPlayers[#oldPlayers + 1] = pid
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
   
    if SORCERER == false or DRUID == false or PALADIN == false or KNIGHT == false then
        doPlayerSendCancel(cid, "Four different vocations are required.")
        return false
    end
   
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
   
    addEvent(kickPlayers, 900000, oldPlayers)
    return true
end

Amazing, but not work

Code:
[11:31:04.658] [Error - LuaInterface::loadFile] data/actions/scripts/dungeon_lever.lua:1: ')' expected near '='
[11:31:04.658] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/dungeon_lever.lua)
[11:31:04.658] data/actions/scripts/dungeon_lever.lua:1: ')' expected near '='
 
Amazing, but not work

Code:
[11:31:04.658] [Error - LuaInterface::loadFile] data/actions/scripts/dungeon_lever.lua:1: ')' expected near '='
[11:31:04.658] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/dungeon_lever.lua)
[11:31:04.658] data/actions/scripts/dungeon_lever.lua:1: ')' expected near '='

thank you 😎

replace first two lines of code with this

Lua:
local kickTo = {x = 956, y = 1039, z = 7} -- kick players after 15 minutes to this position
local centerPos = {x = 1000, y = 1000, z = 7}
 
thank you 😎

replace first two lines of code with this

Lua:
local kickTo = {x = 956, y = 1039, z = 7} -- kick players after 15 minutes to this position
local centerPos = {x = 1000, y = 1000, z = 7}

Code:
[13:17:05.067] [Error - Action Interface] 
[13:17:05.067] data/actions/scripts/dungeon_lever.lua:onUse
[13:17:05.067] Description: 
[13:17:05.067] data/actions/scripts/dungeon_lever.lua:53: attempt to index global 'Game' (a nil value)
[13:17:05.067] stack traceback:
[13:17:05.067]     data/actions/scripts/dungeon_lever.lua:53: in function <data/actions/scripts/dungeon_lever.lua:51>

[13:17:06.305] [Error - Action Interface] 
[13:17:06.305] data/actions/scripts/dungeon_lever.lua:onUse
[13:17:06.305] Description: 
[13:17:06.305] data/actions/scripts/dungeon_lever.lua:53: attempt to index global 'Game' (a nil value)
[13:17:06.305] stack traceback:
[13:17:06.305]     data/actions/scripts/dungeon_lever.lua:53: in function <data/actions/scripts/dungeon_lever.lua:51>
 
Code:
[13:17:05.067] [Error - Action Interface]
[13:17:05.067] data/actions/scripts/dungeon_lever.lua:onUse
[13:17:05.067] Description:
[13:17:05.067] data/actions/scripts/dungeon_lever.lua:53: attempt to index global 'Game' (a nil value)
[13:17:05.067] stack traceback:
[13:17:05.067]     data/actions/scripts/dungeon_lever.lua:53: in function <data/actions/scripts/dungeon_lever.lua:51>

[13:17:06.305] [Error - Action Interface]
[13:17:06.305] data/actions/scripts/dungeon_lever.lua:onUse
[13:17:06.305] Description:
[13:17:06.305] data/actions/scripts/dungeon_lever.lua:53: attempt to index global 'Game' (a nil value)
[13:17:06.305] stack traceback:
[13:17:06.305]     data/actions/scripts/dungeon_lever.lua:53: in function <data/actions/scripts/dungeon_lever.lua:51>

lets fix it:

Lua:
local kickTo = {x = 956, y = 1039, z = 7} -- kick players after 15 minutes to this position
local centerPos = {x = 1000, y = 1000, z = 7}
local xRange = 5
local yRange = 4

-- positions and where go
local p = {
    [1] = {
        player = {
            position = {x = 952, y = 1039, z = 7},
            toPos = {x = 953, y = 1047, z = 6}
        }
    },
    [2] = {
        player = {
            position = {x = 953, y = 1039, z = 7},
            toPos = {x = 954, y = 1047, z = 6}
        }
    },
    [3] = {
        player = {
            position = {x = 954, y = 1039, z = 7},
            toPos = {x = 955, y = 1047, z = 6}
        }
    },
    [4] = {
        player = {
            position = {x = 955, y = 1039, z = 7},
            toPos = {x = 956, y = 1047, z = 6}
        }
    }
}

-- min lvl
local minLevel = 10
local maxLevel = 20

-- 3 how to: after enter in the dungeon, have 15 min to open the chest, if dont teleport to 956/1039/7
local function kickPlayers(players)
    local spectators = getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, spec in ipairs(spectators) do
        local specName = getPlayerName(spec)
        for _, player in ipairs(players) do
            if getPlayerName(player) == specName then
                doTeleportThing(spec, kickTo, false)
            end
        end
    end
end

function onUse(cid)
    -- 1 how to: if there is a team doing players cant go in
    local spectators = getSpectators(centerPos, false, true, 0, xRange, 0, yRange)
    for _, player in ipairs(spectators) do
        doPlayerSendCancel(cid, "There are still remaining players in the room.")
        return false
    end
 
    -- 2 how to: only accept different IPs
    local ipAddress = {}
    local questPlayers = {}
    local oldPlayers = {}
    local SORCERER, DRUID, PALADIN, KNIGHT = false, false, false, false

    for i = 1, #p do
        local pid = getTopCreature(p[i].player.position).uid   
        if isPlayer(pid) then
            local voc = getPlayerVocation(pid)
            if voc == 1 or voc == 5 or voc == 9 then
                SORCERER = true
            elseif voc == 2 or voc == 6 or voc == 10 then
                DRUID = true
            elseif voc == 3 or voc == 7 or voc == 11 then
                PALADIN = true
            elseif voc == 4 or voc == 8 or voc == 12 then
                KNIGHT = true
            end
            
            local newIp = getPlayerIp(pid)
            if getPlayerStorageValue(pid, 5824) >= os.time() then
                local exaustedMins = math.ceil(((getPlayerStorageValue(cid, 5824)) - os.time())/60)
                doPlayerSendCancel(cid, getPlayerName(pid) .. " have to wait " .. exaustedMins .. " minutes to do this dugeon again.")
                return false
            end

            for _, ip in ipairs(ipAddress) do
                if newIp == ip then
                    doPlayerSendCancel(cid, "Players with the same IP address detected.")
                    return false
                end
            end
            ipAddress[#ipAddress + 1] = newIp
            
            if not getPlayerLevel(pid) >= minLevel and not getPlayerLevel(pid) <= maxLevel then
                doPlayerSendCancel(cid, getCreatureName(pid) .. ", is not high enough in level, the level to enter have to be between " .. minLevel .. "~ " .. maxLevel .. ". ")
                return false
            end
            oldPlayers[#oldPlayers + 1] = pid
        else
            doPlayerSendCancel(cid, "A player is missing.")
            return false
        end
    end
    
    if SORCERER == false or DRUID == false or PALADIN == false or KNIGHT == false then
        doPlayerSendCancel(cid, "Four different vocations are required.")
        return false
    end
    
    for x = 1, #questPlayers do
        -- 4 how to: after go in have a exausted of 24 hours to go again
        setPlayerStorageValue(questPlayers[x], 5824, os.time() + 86400)
        doPlayerSendTextMessage(questPlayers[x], MESSAGE_INFO_DESCR, "Good luck!")
        doTeleportThing(questPlayers[x], p[x].player.toPos)
    end
    
    addEvent(kickPlayers, 900000, oldPlayers)
    return true
end

fyi; the code is not complete. There are some unused parts such as questPlayers. I didn't touch it because that wasn't requested
 
Solution
Back
Top