Hello I was facing troubles with this script it was working in old distro but when I used it in 0.3.7 it didn't work can someone give a hint or correct something because it doesn't show any errors in console or anything basically this works as huskies dog sled when u step in this item it start to sledding you to reach this actionid in 9001 in one direction then it stops if u could also improve it putting the path it goes to go or some x,y,z postion to go i mean it walks in only one direction
Lua:
function addSled(params)
local startpos = params.startpos
local spawnDelay = params.spawnDelay
local speed = 250 --The speed in miliseconds before the sled moves 1 tile
local pos = params.pos
local cid = params.cid
-- Dont edit any of the following unless you know what your doing
local groundpos = {x=pos.x, y=pos.y, z=pos.z, stackpos=0}
local ground = getThingfromPos(groundpos)
pos1 = {x=pos.x, y=pos.y, z=pos.z, stackpos=1}
pos2 = {x=pos.x, y=pos.y+2, z=pos.z, stackpos=1}
pos3 = {x=pos.x, y=pos.y+3, z=pos.z, stackpos=1}
pos4 = {x=pos.x, y=pos.y+5, z=pos.z, stackpos=1}
item1 = getThingfromPos(pos1)
item2 = getThingfromPos(pos2)
item3 = getThingfromPos(pos3)
item4 = getThingfromPos(pos4)
newpos = {x=pos.x, y=pos.y+1, z=pos.z}
if ground.actionid == 9001 then
spawnparams = {startpos = startpos, pos = pos}
addEvent(spawnSled,spawnDelay*1000,spawnparams)
setPlayerStorageValue(cid,9006,-1)
else
doRemoveItem(item1.uid,1)
doRemoveItem(item2.uid,1)
doRemoveItem(item3.uid,1)
doRemoveItem(item4.uid,1)
newpos1 = {x=newpos.x, y=newpos.y, z=newpos.z}
newpos2 = {x=newpos.x, y=newpos.y+2, z=newpos.z}
newpos3 = {x=newpos.x, y=newpos.y+3, z=newpos.z}
newpos4 = {x=newpos.x, y=newpos.y+5, z=newpos.z}
doCreateItem(7266,1,newpos1)
doCreateItem(7268,1,newpos2)
doCreateItem(7269,1,newpos3)
doCreateItem(7270,1,newpos4)
doTeleportThing(cid, newpos)
newparams = {pos = newpos, cid = cid, startpos = startpos, spawnDelay = 10}
addEvent(addSled,speed,newparams)
end
end
function spawnSled(params)
local startpos = params.startpos
local pos = params.pos
pos1 = {x=startpos.x, y=startpos.y, z=startpos.z}
pos2 = {x=startpos.x, y=startpos.y+2, z=startpos.z}
pos3 = {x=startpos.x, y=startpos.y+3, z=startpos.z}
pos4 = {x=startpos.x, y=startpos.y+5, z=startpos.z}
doCreateItem(7266,1,pos1)
doCreateItem(7268,1,pos2)
doCreateItem(7269,1,pos3)
doCreateItem(7270,1,pos4)
pos1 = {x=pos.x, y=pos.y, z=pos.z, stackpos=1}
pos2 = {x=pos.x, y=pos.y+2, z=pos.z, stackpos=1}
pos3 = {x=pos.x, y=pos.y+3, z=pos.z, stackpos=1}
pos4 = {x=pos.x, y=pos.y+5, z=pos.z, stackpos=1}
item1 = getThingfromPos(pos1)
item2 = getThingfromPos(pos2)
item3 = getThingfromPos(pos3)
item4 = getThingfromPos(pos4)
doRemoveItem(item1.uid,1)
doRemoveItem(item2.uid,1)
doRemoveItem(item3.uid,1)
doRemoveItem(item4.uid,1)
ppos1 = {x=startpos.x, y=startpos.y, z=startpos.z, stackpos=253}
ppos2 = {x=startpos.x, y=startpos.y+2, z=startpos.z, stackpos=253}
ppos3 = {x=startpos.x, y=startpos.y+3, z=startpos.z, stackpos=253}
ppos4 = {x=startpos.x, y=startpos.y+5, z=startpos.z, stackpos=253}
player1 = getThingfromPos(ppos1)
player2 = getThingfromPos(ppos2)
player3 = getThingfromPos(ppos3)
player4 = getThingfromPos(ppos4)
nppos1 = {x=startpos.x+1, y=startpos.y, z=startpos.z}
nppos2 = {x=startpos.x+1, y=startpos.y+2, z=startpos.z}
nppos3 = {x=startpos.x+1, y=startpos.y+3, z=startpos.z}
nppos4 = {x=startpos.x+1, y=startpos.y+5, z=startpos.z}
if player1.itemid > 0 then
doTeleportThing(player1.uid, nppos1)
end
if player2.itemid > 0 then
doTeleportThing(player2.uid, nppos2)
end
if player3.itemid > 0 then
doTeleportThing(player3.uid, nppos3)
end
if player4.itemid > 0 then
doTeleportThing(player4.uid, nppos4)
end
end
function onStepIn(cid, item, pos)
if isPlayer(cid) == 1 then
isMoving = getPlayerStorageValue(cid,9006)
if item.itemid == 7266 and isMoving == -1 then
params = {cid = cid, pos = pos, startpos = pos, spawnDelay = 10}
addEvent(addSled, 100, params)
setPlayerStorageValue(cid,9006,1)
end
end
end
XML:
<movevent event="StepIn" itemid="7266" script="sled.lua" />