Derlexy
Intermediate OT User
- Joined
- Jun 29, 2011
- Messages
- 219
- Reaction score
- 101
Hello guys, maybe someone can help me with this:
I'm working on a Avesta 7.4, and i got some console errors when I execute my script, it follows:
And here the error:
Obs: When the bridge is free for players, i got 3 times the same error, when the bridge have 1 player on it, i got 2 times this error, etc...
What i think the problem is: The function isCreature() isnt working, because the function insert on the table playersInArea every thing, not only players...
I'm working on a Avesta 7.4, and i got some console errors when I execute my script, it follows:
Code:
function getPlayersInArea(fromPos, toPos) -- function by amoeba13
playersInArea = {}
for Px = fromPos.x, toPos.x do
for Py = fromPos.y, toPos.y do
for Pz = fromPos.z, toPos.z do
totalArea = {x = Px, y = Py, z = Pz}
playerz = getTopCreature(totalArea)
if isCreature(playerz.uid) then
table.insert(playersInArea, playerz.uid)
end
end
end
end
return playersInArea
end
Code:
function onUse(cid, item, frompos, item2, topos)
-- Bridge Positions:
local bridge1 = {x = 32099, y = 32205, z = 8, stackpos = 0}
local bridge2 = {x = 32100, y = 32205, z = 8, stackpos = 0}
local bridge3 = {x = 32101, y = 32205, z = 8, stackpos = 0}
-- Bridge Players Positions:
local bridgeplayer1 = {x = 32099, y = 32205, z = 8}
local bridgeplayer2 = {x = 32100, y = 32205, z = 8}
local bridgeplayer3 = {x = 32101, y = 32205, z = 8}
-- Bridge Entries:
local entry1 = {x = 32098, y = 32205, z = 8}
local entry2 = {x = 32102, y = 32205, z = 8}
if item.itemid == 1945 or item.itemid == 1946 then
-- If the Bridge is off:
if getThingfromPos(bridge2).itemid == 493 then
-- Create the bridge:
doCreateItem(1284, 1, bridge1)
doCreateItem(1284, 1, bridge2)
doCreateItem(1284, 1, bridge3)
-- If the Bridge is on:
elseif getThingfromPos(bridge2).itemid == 1284 then
-- Players Check:
local Area = getPlayersInArea(bridgeplayer1, bridgeplayer3)
if Area then
for i in pairs(Area) do
doTeleportThing(Area[i], entry1)
end
end
-- Remove the bridge:
doCreateItem(508, 1, bridge1)
doCreateItem(493, 1, bridge2)
doCreateItem(509, 1, bridge3)
else
doPlayerSendCancel(cid,"Sorry, not possible!")
end
end
end
Obs: When the bridge is free for players, i got 3 times the same error, when the bridge have 1 player on it, i got 2 times this error, etc...
What i think the problem is: The function isCreature() isnt working, because the function insert on the table playersInArea every thing, not only players...