i'm trying to put in my server roller coaster system.
but i want everytime when the roller finish his path he will be removed.
Here is the script - thx in advance
but i want everytime when the roller finish his path he will be removed.
PHP:
local storage = 242526
local interval = 10
function tileChecker(pos)
local myTable = {}
if (type(pos) == 'table') then
for i = 1, 5 do
pos.stackpos = i
local thisID = getThingFromPos(pos).itemid
if thisID > 1 then
table.insert(myTable, thisID)
end
end
end
return #myTable > 0 and myTable or nil
end
local function findItem(pos, t)
if (type(pos) == 'table' and type(t) == 'table') then
for _i, i in ipairs(tileChecker(pos)) do
if isInArray(t, i) then
pos.stackpos = _i
ret = getThingFromPos(pos).uid
break
end
end
end
return ret
end
local function moveTrain(p)
doCreateItem(p.t, 1, p.new)
doTeleportThing(p.cid, p.new, FALSE)
doRemoveItem(findItem(p.pos, {7131, 7132}))
end
function onStepIn(cid, item, pos)
local Rail = false
local Rails =
{
[7122]={
[1]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[2]={n={x=pos.x+1, y=pos.y, z=pos.z}, t=7131, ns=2}
},
[7121]={
[3]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3},
[4]={n={x=pos.x, y=pos.y+1, z=pos.z}, t=7132, ns=4}
},
[7123]={
[3]={n={x=pos.x+1, y=pos.y, z=pos.z}, t=7131, ns=2},
[1]={n={x=pos.x, y=pos.y+1, z=pos.z}, t=7132, ns=4}
},
[7124]={
[3]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[2]={n={x=pos.x, y=pos.y+1, z=pos.z}, t=7131, ns=4}
},
[7125]={
[4]={n={x=pos.x+1, y=pos.y, z=pos.z}, t=7131, ns=2},
[1]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3}
},
[7126]={
[4]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[2]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3}
},
[7127]={
[4]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[3]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3},
[2]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3}
},
[7128]={
[3]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[1]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[2]={n={x=pos.x, y=pos.y+1, z=pos.z}, t=7132, ns=4}
},
[7130]={
[4]={n={x=pos.x+1, y=pos.y, z=pos.z}, t=7131, ns=2},
[3]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3},
[1]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3}
},
[7129]={
[1]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1},
[2]={n={x=pos.x, y=pos.y-1, z=pos.z}, t=7132, ns=3},
[4]={n={x=pos.x-1, y=pos.y, z=pos.z}, t=7131, ns=1}
}
}
if isPlayer(cid) == TRUE then
local tileItems = tileChecker(pos)
if tileItems ~= nil then
for _, i in ipairs(tileItems) do
if Rails[i] then
Rail = Rails[i]
break
end
end
end
if Rail ~= false then
local Direction = Rail[getPlayerStorageValue(cid,storage)]
if Direction then
setPlayerStorageValue(cid, storage, Direction.ns)
doSetItemOutfit(cid, Direction.t, 1000)
addEvent(moveTrain, interval, {cid=cid, new=Direction.n, t=Direction.t, pos=pos})
end
end
end
return TRUE
end