• 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 [TFS 0.4] 8.60 Error globalevent

Leo Nard

New Member
Joined
Feb 13, 2022
Messages
8
Reaction score
0
Lua
local function createGemsOnPlaces(count)
local fromPosition = {x = 2382, y = 931, z = 6, stackpos=0}
local toPosition = {x = 2460, y = 985, z = 6, stackpos=0}
-- local buff_positions = {{x = math.random(948, 1045), y = math.random(970, 1029), z = 7}}
local pos = {x = math.random(fromPosition.x, toPosition.x), y = math.random(fromPosition.y, toPosition.y), z = math.random(fromPosition.z, toPosition.z), stackpos = 253}
local items = {9565, 9562, 9564}
local item = items[math.random(1, #items)]
local tileItem = getTileItemById(pos, item)
if(pos and isPosRealAndFree(pos) and (getTileItemById(pos, 9565).uid == 0) and (getTileItemById(pos, 9562).uid == 0) and (getTileItemById(pos, 9564).uid == 0) and not getTileInfo(pos).protection and not getTileInfo(pos).house) then
local bouns = doCreateItem(item, 1, pos)
doItemSetAttribute(bouns, "aid", 15160)
doBroadcastMessage("A new {Gem System} have been created on Some where on the Bridge.")
-- doBroadcastMessage("A new "..getItemNameById(item).." have been created on Some where on the Bridge.")
end
if count <= 10 then
addEvent(createGemsOnPlaces, 15 * 60 * 1000,count+1)
end
return true
end
function isPosClear(pos)
local tile = getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=0})
local item = getThingFromPos({x=pos.x, y=pos.y, z=pos.z, stackpos=1})
return (tile.uid ~= 0) and not hasProperty(tile.uid, CONST_PROP_BLOCKSOLID) and not getTileInfo(pos).protection and not getTileInfo(pos).house and not item.itemid
end
local function isWalkable(cid, pos) -- DOES NOT WORK WITH ACCESS 3+
local closest = getClosestFreeTile(cid, pos)
return type(closest) == "table" and doComparePositions(closest, pos)
end

function onThink(interval)
if isPosClear(pos) == true and isWalkable(cid, position) == true then
doBroadcastMessage("Gems will spawn in random place in map after 10 seconds from now have a fun war.!")
createGemsOnPlaces(1)
return true
end
end

Error
[18/2/2022 15:14:28] [Error - GlobalEvent Interface]
[18/2/2022 15:14:28] data/globalevents/scripts/Gem/gem.lua:eek:nThink
[18/2/2022 15:14:28] Description:
[18/2/2022 15:14:28] data/globalevents/scripts/Gem/gem.lua:21: attempt to index local 'pos' (a nil value)
[18/2/2022 15:14:28] stack traceback:
[18/2/2022 15:14:28] data/globalevents/scripts/Gem/gem.lua:21: in function 'isPosClear'
[18/2/2022 15:14:28] data/globalevents/scripts/Gem/gem.lua:31: in function <data/globalevents/scripts/Gem/gem.lua:30>
[18/2/2022 15:14:28] [Error - GlobalEvents::think] Couldn't execute event: Gem System
 
Back
Top