ka0zstyle
New Member
- Joined
- Oct 30, 2009
- Messages
- 128
- Reaction score
- 2
Rain items not work ;S i using 0.3.6 Tfs
ERROR CONSOLE:
Code:
local fromPos = {x=1098, y=1255, z=7}
local toPos = {x=1128, y=1274, z=7}
local items = {{2392,1}, {2391,1}, {2415,1}, {2414,1}, {2431,1}, {7413,1}, {5803,1}, {8850,1}, {6529,2}, {2390,1},
{2393,1}, {2400,1}, {2446,1}, {7390,1}, {2453,1}, {2365,1}, {7739,1}, {9774,1}, {2343,1}, {2493,1}, {2499,1},
{7461,1}, {9778,1}, {2466,1}, {2472,1}, {2492,1}, {2492,1}, {2656,1}, {8890,1}, {9776,1}, {2495,1},
{2470,1}, {6132,1}, {9933,1}, {2523,1}, {2539,1}, {8905,1}, {2520,1}, {2514,1}}
local maxItems = 15
function onThink(pos, creature, proj, pz)
if getTileThingByPos({x=pos.x,y=pos.y,z=pos.z,stackpos=0}).itemid == 0 then return false end
local n = not proj and 3 or 2
for i = 0, 255 do
pos.stackpos = i
local tile = getTileThingByPos(pos)
if tile.itemid ~= 0 and not isCreature(tile.uid) then
if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
return true
end
end
end
return true
end
function checkPositions(n)
local pos = {x=math.random(fromPos.x,toPos.x), y=math.random(fromPos.y,toPos.y), z=math.random(fromPos.z,toPos.z)}
if isWalkable(pos, true, false, true) then
return pos
end
return (n < 50 and checkPositions(n+1) or false)
end
function onSay(cid, words, param)
doBroadcastMessage("Rain item event will start in 15 minutes. Go go go!.", MESSAGE_EVENT_ADVANCE)
return addEvent(spawnItem, 900000, 1)
end
function spawnItem(created)
if created >= maxItems then
return doBroadcastMessage("Rain Item Event just finished!", MESSAGE_EVENT_ADVANCE)
end
local itemPos, itemInf = checkPositions(1), math.random(#items)
doCreateItem(items[itemInf][1], items[itemInf][2], itemPos)
doSendMagicEffect(itemPos, CONST_ME_LOSEENERGY)
return addEvent(spawnItem, 5000, created+1)
end
ERROR CONSOLE:
Code:
[05/05/2016 22:35:48] [Error - GlobalEvent Interface]
[05/05/2016 22:35:48] data/globalevents/scripts/rain items.lua:onThink
[05/05/2016 22:35:48] Description:
[05/05/2016 22:35:48] data/globalevents/scripts/rain items.lua:13: attempt to index local 'pos' (a number value)
[05/05/2016 22:35:48] stack traceback:
[05/05/2016 22:35:48] data/globalevents/scripts/rain items.lua:13: in function <data/globalevents/scripts/rain items.lua:9>
[05/05/2016 22:35:48] [Error - GlobalEvents::think] Couldn't execute event: Rain items