zabuzo
Well-Known Member
- Joined
- Jun 10, 2016
- Messages
- 238
- Reaction score
- 54
is anybody know how to fix this error
from this dungeon lever script?
it's from sourcepack 0.4 Fir3element/3777 (https://github.com/Fir3element/3777/)
Code:
[23:47:32.173] [Error - Action Interface]
[23:47:32.173] data/actions/scripts/dungeon_lever.lua:onUse
[23:47:32.173] Description:
[23:47:32.173] attempt to index a number value
[23:47:32.173] stack traceback:
[23:47:32.173] [C]: in function 'getSpectators'
[23:47:32.173] data/actions/scripts/dungeon_lever.lua:53: in function <data/actions/scripts/dungeon_lever.lua:51>
from this dungeon lever script?
Code:
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
it's from sourcepack 0.4 Fir3element/3777 (https://github.com/Fir3element/3777/)
Last edited: