• 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!

MoveEvent Flying Carpet

DeGhost

blue-php.com
Joined
Apr 21, 2008
Messages
42
Reaction score
0
Location
Poland
Information:
Script on the base [Naruto Car]
I edited data/movements/car.lua ...
[Movie]by me ...

Install xD:
copy to data/movements/
flyingcarpet.lua
Code:
local storages = {
    isMoving = 12550,
    direction = 12551,
    speed = 12552
}
function CarMoveLeft(x)
cpos = x.Cpos
Car = getThingfromPos(cpos)
newpos = {x=x.pos.x-1, y=x.pos.y, z=x.pos.z}

new1pos = {x=x.pos.x-2, y=x.pos.y-1, z=x.pos.z}
new2pos = {x=x.pos.x-1, y=x.pos.y-1, z=x.pos.z}
new3pos = {x=x.pos.x, y=x.pos.y-1, z=x.pos.z}

new4pos = {x=x.pos.x-2, y=x.pos.y, z=x.pos.z}

new6pos = {x=x.pos.x, y=x.pos.y, z=x.pos.z}

new7pos = {x=x.pos.x-2, y=x.pos.y+1, z=x.pos.z}
new8pos = {x=x.pos.x-1, y=x.pos.y+1, z=x.pos.z}
new9pos = {x=x.pos.x, y=x.pos.y+1, z=x.pos.z}


gate1pos = {x=x.pos.x-1, y=x.pos.y-1, z=x.pos.z, stackpos=1}
gate2pos = {x=x.pos.x, y=x.pos.y-1, z=x.pos.z, stackpos=1}
gate3pos = {x=x.pos.x+1, y=x.pos.y-1, z=x.pos.z, stackpos=1}

gate4pos = {x=x.pos.x-1, y=x.pos.y, z=x.pos.z, stackpos=1}

gate6pos = {x=x.pos.x+1, y=x.pos.y, z=x.pos.z, stackpos=1}

gate7pos = {x=x.pos.x-1, y=x.pos.y+1, z=x.pos.z, stackpos=1}
gate8pos = {x=x.pos.x, y=x.pos.y+1, z=x.pos.z, stackpos=1}
gate9pos = {x=x.pos.x+1, y=x.pos.y+1, z=x.pos.z, stackpos=1}

get1gate = getThingfromPos(gate1pos)
get2gate = getThingfromPos(gate2pos)
get3gate = getThingfromPos(gate3pos)
get4gate = getThingfromPos(gate4pos)
get6gate = getThingfromPos(gate6pos)
get7gate = getThingfromPos(gate7pos)
get8gate = getThingfromPos(gate8pos)
get9gate = getThingfromPos(gate9pos)

doCreateItem(1798,1,newpos)
doCreateItem(1794,1,new1pos)
doCreateItem(1795,1,new2pos)
doCreateItem(1796,1,new3pos)
doCreateItem(1797,1,new4pos)
doCreateItem(1799,1,new6pos)
doCreateItem(1800,1,new7pos)
doCreateItem(1801,1,new8pos)
doCreateItem(1802,1,new9pos)
doTeleportThing(x.cid, newpos, FALSE)
doRemoveItem(Car.uid,1)
doRemoveItem(get1gate.uid,1)
doRemoveItem(get2gate.uid,1)
doRemoveItem(get3gate.uid,1)
doRemoveItem(get4gate.uid,1)
doRemoveItem(get6gate.uid,1)
doRemoveItem(get7gate.uid,1)
doRemoveItem(get8gate.uid,1)
doRemoveItem(get9gate.uid,1)


end

function CarMoveRight(x)
cpos = x.Cpos
Car = getThingfromPos(cpos)
newpos = {x=x.pos.x+1, y=x.pos.y, z=x.pos.z}

new1pos = {x=x.pos.x, y=x.pos.y-1, z=x.pos.z}
new2pos = {x=x.pos.x+1, y=x.pos.y-1, z=x.pos.z}
new3pos = {x=x.pos.x+2, y=x.pos.y-1, z=x.pos.z}

new4pos = {x=x.pos.x, y=x.pos.y, z=x.pos.z}

new6pos = {x=x.pos.x+2, y=x.pos.y, z=x.pos.z}

new7pos = {x=x.pos.x, y=x.pos.y+1, z=x.pos.z}
new8pos = {x=x.pos.x+1, y=x.pos.y+1, z=x.pos.z}
new9pos = {x=x.pos.x+2, y=x.pos.y+1, z=x.pos.z}



gate1pos = {x=x.pos.x-1, y=x.pos.y-1, z=x.pos.z, stackpos=1}
gate2pos = {x=x.pos.x, y=x.pos.y-1, z=x.pos.z, stackpos=1}
gate3pos = {x=x.pos.x+1, y=x.pos.y-1, z=x.pos.z, stackpos=1}

gate4pos = {x=x.pos.x-1, y=x.pos.y, z=x.pos.z, stackpos=1}

gate6pos = {x=x.pos.x+1, y=x.pos.y, z=x.pos.z, stackpos=1}

gate7pos = {x=x.pos.x-1, y=x.pos.y+1, z=x.pos.z, stackpos=1}
gate8pos = {x=x.pos.x, y=x.pos.y+1, z=x.pos.z, stackpos=1}
gate9pos = {x=x.pos.x+1, y=x.pos.y+1, z=x.pos.z, stackpos=1}

get1gate = getThingfromPos(gate1pos)
get2gate = getThingfromPos(gate2pos)
get3gate = getThingfromPos(gate3pos)
get4gate = getThingfromPos(gate4pos)
get6gate = getThingfromPos(gate6pos)
get7gate = getThingfromPos(gate7pos)
get8gate = getThingfromPos(gate8pos)
get9gate = getThingfromPos(gate9pos)

doCreateItem(1798,1,newpos)
doCreateItem(1794,1,new1pos)
doCreateItem(1795,1,new2pos)
doCreateItem(1796,1,new3pos)
doCreateItem(1797,1,new4pos)
doCreateItem(1799,1,new6pos)
doCreateItem(1800,1,new7pos)
doCreateItem(1801,1,new8pos)
doCreateItem(1802,1,new9pos)
doTeleportThing(x.cid, newpos, FALSE)
doRemoveItem(Car.uid,1)
doRemoveItem(get1gate.uid,1)
doRemoveItem(get2gate.uid,1)
doRemoveItem(get3gate.uid,1)
doRemoveItem(get4gate.uid,1)
doRemoveItem(get6gate.uid,1)
doRemoveItem(get7gate.uid,1)
doRemoveItem(get8gate.uid,1)
doRemoveItem(get9gate.uid,1)

end
function CarMoveUp(x)
cpos = x.Cpos
Car = getThingfromPos(cpos)
newpos = {x=x.pos.x, y=x.pos.y-1, z=x.pos.z}

new1pos = {x=x.pos.x-1, y=x.pos.y-2, z=x.pos.z}
new2pos = {x=x.pos.x, y=x.pos.y-2, z=x.pos.z}
new3pos = {x=x.pos.x+1, y=x.pos.y-2, z=x.pos.z}

new4pos = {x=x.pos.x-1, y=x.pos.y-1, z=x.pos.z}

new6pos = {x=x.pos.x+1, y=x.pos.y-1, z=x.pos.z}

new7pos = {x=x.pos.x-1, y=x.pos.y, z=x.pos.z}
new8pos = {x=x.pos.x, y=x.pos.y, z=x.pos.z}
new9pos = {x=x.pos.x+1, y=x.pos.y, z=x.pos.z}

gate1pos = {x=x.pos.x-1, y=x.pos.y-1, z=x.pos.z, stackpos=1}
gate2pos = {x=x.pos.x, y=x.pos.y-1, z=x.pos.z, stackpos=1}
gate3pos = {x=x.pos.x+1, y=x.pos.y-1, z=x.pos.z, stackpos=1}

gate4pos = {x=x.pos.x-1, y=x.pos.y, z=x.pos.z, stackpos=1}

gate6pos = {x=x.pos.x+1, y=x.pos.y, z=x.pos.z, stackpos=1}

gate7pos = {x=x.pos.x-1, y=x.pos.y+1, z=x.pos.z, stackpos=1}
gate8pos = {x=x.pos.x, y=x.pos.y+1, z=x.pos.z, stackpos=1}
gate9pos = {x=x.pos.x+1, y=x.pos.y+1, z=x.pos.z, stackpos=1}

get1gate = getThingfromPos(gate1pos)
get2gate = getThingfromPos(gate2pos)
get3gate = getThingfromPos(gate3pos)
get4gate = getThingfromPos(gate4pos)
get6gate = getThingfromPos(gate6pos)
get7gate = getThingfromPos(gate7pos)
get8gate = getThingfromPos(gate8pos)
get9gate = getThingfromPos(gate9pos)

doCreateItem(1798,1,newpos)
doCreateItem(1794,1,new1pos)
doCreateItem(1795,1,new2pos)
doCreateItem(1796,1,new3pos)
doCreateItem(1797,1,new4pos)
doCreateItem(1799,1,new6pos)
doCreateItem(1800,1,new7pos)
doCreateItem(1801,1,new8pos)
doCreateItem(1802,1,new9pos)
doTeleportThing(x.cid, newpos, FALSE)
doRemoveItem(Car.uid,1)
doRemoveItem(get1gate.uid,1)
doRemoveItem(get2gate.uid,1)
doRemoveItem(get3gate.uid,1)
doRemoveItem(get4gate.uid,1)
doRemoveItem(get6gate.uid,1)
doRemoveItem(get7gate.uid,1)
doRemoveItem(get8gate.uid,1)
doRemoveItem(get9gate.uid,1)
end

function CarMoveDown(x)
cpos = x.Cpos
Car = getThingfromPos(cpos)
newpos = {x=x.pos.x, y=x.pos.y+1, z=x.pos.z}

new1pos = {x=x.pos.x-1, y=x.pos.y, z=x.pos.z}
new2pos = {x=x.pos.x, y=x.pos.y, z=x.pos.z}
new3pos = {x=x.pos.x+1, y=x.pos.y, z=x.pos.z}

new4pos = {x=x.pos.x-1, y=x.pos.y+1, z=x.pos.z}

new6pos = {x=x.pos.x+1, y=x.pos.y+1, z=x.pos.z}

new7pos = {x=x.pos.x-1, y=x.pos.y+2, z=x.pos.z}
new8pos = {x=x.pos.x, y=x.pos.y+2, z=x.pos.z}
new9pos = {x=x.pos.x+1, y=x.pos.y+2, z=x.pos.z}

gate1pos = {x=x.pos.x-1, y=x.pos.y-1, z=x.pos.z, stackpos=1}
gate2pos = {x=x.pos.x, y=x.pos.y-1, z=x.pos.z, stackpos=1}
gate3pos = {x=x.pos.x+1, y=x.pos.y-1, z=x.pos.z, stackpos=1}

gate4pos = {x=x.pos.x-1, y=x.pos.y, z=x.pos.z, stackpos=1}

gate6pos = {x=x.pos.x+1, y=x.pos.y, z=x.pos.z, stackpos=1}

gate7pos = {x=x.pos.x-1, y=x.pos.y+1, z=x.pos.z, stackpos=1}
gate8pos = {x=x.pos.x, y=x.pos.y+1, z=x.pos.z, stackpos=1}
gate9pos = {x=x.pos.x+1, y=x.pos.y+1, z=x.pos.z, stackpos=1}

get1gate = getThingfromPos(gate1pos)
get2gate = getThingfromPos(gate2pos)
get3gate = getThingfromPos(gate3pos)
get4gate = getThingfromPos(gate4pos)
get6gate = getThingfromPos(gate6pos)
get7gate = getThingfromPos(gate7pos)
get8gate = getThingfromPos(gate8pos)
get9gate = getThingfromPos(gate9pos)

doCreateItem(1798,1,newpos)
doCreateItem(1794,1,new1pos)
doCreateItem(1795,1,new2pos)
doCreateItem(1796,1,new3pos)
doCreateItem(1797,1,new4pos)
doCreateItem(1799,1,new6pos)
doCreateItem(1800,1,new7pos)
doCreateItem(1801,1,new8pos)
doCreateItem(1802,1,new9pos)
doTeleportThing(x.cid, newpos, FALSE)
doRemoveItem(Car.uid,1)
doRemoveItem(get1gate.uid,1)
doRemoveItem(get2gate.uid,1)
doRemoveItem(get3gate.uid,1)
doRemoveItem(get4gate.uid,1)
doRemoveItem(get6gate.uid,1)
doRemoveItem(get7gate.uid,1)
doRemoveItem(get8gate.uid,1)
doRemoveItem(get9gate.uid,1)

end
function onStepIn(cid, item, position, fromPosition)
local pos = position
if isPlayer(cid) == 1 then
    local status = {
        isMoving = getPlayerStorageValue(cid, storages.isMoving),
        direction = getPlayerStorageValue(cid, storages.direction),
        speed = getPlayerStorageValue(cid, storages.speed)
    }
    if status.speed <= 0 then
        setPlayerStorageValue(cid, storages.speed, 500)
        status.speed = 800
    elseif status.speed >= 3500 then
        setPlayerStorageValue(cid, storages.speed, 500)
        status.speed = 800    
    end
    CarPos = getThingPos(item.uid)



     if status.isMoving == 1 then

		local x = {cid = cid, pos = pos, Cpos = CarPos}
        if status.direction == 1  then

            CheckRight = getThingfromPos({x = pos.x+1, y = pos.y, z = pos.z, stackpos = 1})
 	    	CheckLeft = getThingfromPos({x = pos.x-1, y = pos.y, z = pos.z, stackpos = 1})
            CheckRight2 = getThingfromPos({x = pos.x+1, y = pos.y, z = pos.z, stackpos = 2})
 	    	CheckLeft2 = getThingfromPos({x = pos.x-1, y = pos.y, z = pos.z, stackpos = 2})


			

			
	    	if (isWall(CheckLeft.itemid) == 1 or isWall(CheckLeft2.itemid) == 1 or isCreature(CheckLeft.uid) >0) and (isWall(CheckRight.itemid)==0 and  isWall(CheckRight2.itemid)==0) then 
                setPlayerStorageValue(cid, storages.direction, 2)
                addEvent(CarMoveRight, status.speed, x)

            elseif isWall(CheckLeft.itemid) == 0 and isWall(CheckLeft2.itemid) == 0 then
                addEvent(CarMoveLeft, status.speed, x)
			else

			setPlayerStorageValue(cid, storages.isMoving, 1)
			
            end



        elseif status.direction == 2 then
            CheckRight = getThingfromPos({x = pos.x+1, y = pos.y, z = pos.z, stackpos = 1})
 	    	CheckLeft = getThingfromPos({x = pos.x-1, y = pos.y, z = pos.z, stackpos = 1})
            CheckRight2 = getThingfromPos({x = pos.x+1, y = pos.y, z = pos.z, stackpos = 2})
 	    	CheckLeft2 = getThingfromPos({x = pos.x-1, y = pos.y, z = pos.z, stackpos = 2})

           
	
			
	    	if (isWall(CheckRight.itemid) == 1 or isWall(CheckRight2.itemid) == 1 or isCreature(CheckRight.uid) >0) and ( isWall(CheckLeft.itemid) == 0 and  isWall(CheckLeft2.itemid) == 0) then 
                setPlayerStorageValue(cid, storages.direction, 1)
                addEvent(CarMoveLeft, status.speed, x)

            elseif isWall(CheckRight.itemid) == 0 and isWall(CheckRight2.itemid) == 0 then
                addEvent(CarMoveRight, status.speed, x)
			else
			
			setPlayerStorageValue(cid, storages.isMoving, 1)
            end

           
        elseif status.direction == 3 then
           CheckUp = getThingfromPos({x = pos.x, y = pos.y-1, z = pos.z, stackpos = 1})
           CheckDown = getThingfromPos({x = pos.x, y = pos.y+1, z = pos.z, stackpos = 1})
           CheckUp2 = getThingfromPos({x = pos.x, y = pos.y-1, z = pos.z, stackpos = 2})
           CheckDown2 = getThingfromPos({x = pos.x, y = pos.y+1, z = pos.z, stackpos = 2})
		   
		   
			if (isWall(CheckUp.itemid) == 1 or isWall(CheckUp2.itemid) == 1 or isCreature(CheckUp.uid) >0) and (isWall(CheckDown.itemid) == 0 and  isWall(CheckDown2.itemid) == 0) then
			
                setPlayerStorageValue(cid, storages.direction, 4)
                addEvent(CarMoveDown, status.speed, x)
				
elseif isWall(CheckUp.itemid) == 0 and isWall(CheckUp2.itemid) == 0 then
		     addEvent(CarMoveUp, status.speed, x)
		
            else
           
				setPlayerStorageValue(cid, storages.isMoving, 1)
            end


        elseif status.direction == 4 then
           CheckUp = getThingfromPos({x = pos.x, y = pos.y-1, z = pos.z, stackpos = 1})
           CheckDown = getThingfromPos({x = pos.x, y = pos.y+1, z = pos.z, stackpos = 1})
           CheckUp2 = getThingfromPos({x = pos.x, y = pos.y-1, z = pos.z, stackpos = 2})
           CheckDown2 = getThingfromPos({x = pos.x, y = pos.y+1, z = pos.z, stackpos = 2})
		   
		   
			if (isWall(CheckDown.itemid) == 1 or isWall(CheckDown2.itemid) == 1 or isCreature(CheckDown.uid) >0) and (isWall(CheckUp.itemid) == 0 and  isWall(CheckUp2.itemid) == 0) then
			
                setPlayerStorageValue(cid, storages.direction, 3)
                addEvent(CarMoveUp, status.speed, x)
				
elseif isWall(CheckDown.itemid) == 0 and isWall(CheckDown2.itemid) == 0 then
		     addEvent(CarMoveDown, status.speed, x)
		
            else
           
				setPlayerStorageValue(cid, storages.isMoving, 1)
            end

				
        end
		

    elseif status.isMoving == -1 then
        setPlayerStorageValue(cid, storages.isMoving, 1)
    end
end
end

data/movements/movements.xml add.
Code:
<movevent event="StepIn" itemid="1798" script="flyingcarpet.lua" />

copy to data/talkactions/scripts/
flyingcarpet.lua
Code:
local storages = {
    isMoving = 12550,
    direction = 12551,
    speed = 12552
}
function onSay(cid, words, param)
local status = {
    isMoving = getPlayerStorageValue(cid, storages.isMoving),
    direction = getPlayerStorageValue(cid, storages.direction),
    speed = getPlayerStorageValue(cid, storages.speed)
}
local controls = {
    ["up"] = {storage = storages.direction, new = 3, txt = "up"},
    ["down"] = {storage = storages.direction, new = 4, txt = "down"}, 
    ["left"] = {storage = storages.direction, new = 1, txt = "left"}, 
    ["right"] = {storage = storages.direction, new = 2, txt = "right"},
    ["speedup"] = {storage = storages.speed, new = status.speed-50, txt = "fast"},
    ["speeddown"] = {storage = storages.speed, new = status.speed+50, txt = "slow"},
    ["stop"] = {storage = storages.direction, new = -1, txt = "stop"}
}
if status.isMoving == 1 then
    ctrl = controls[param]
    if (ctrl ~= nil) then
        setPlayerStorageValue(cid, ctrl.storage, ctrl.new)
        doCreatureSay(cid, ctrl.txt, TALKTYPE_SAY)
    else
        doSendMagicEffect(getPlayerPosition(cid), 2)
        doPlayerSendCancel(cid, "Invalid operation.")
    end
else
    doPlayerSendCancel(cid, "You are not in a Flying Carpet.")
end
end

data/talkations/talkactions.xml add.
Code:
<talkaction words="carpet" script="flyingcarpet.lua" />

Function isWall...

Code:
function isWall(id)
local walls = {1025, 1032, 1028, 1030, 1035, 1027, 1219, 4645, 4647, 4646, 4644}
if isInArray(walls, id) == 1 then
return 1
else
return 0
end
end

Controls:
Code:
to the directions
carpet "left
carpet "right
carpet "up
carpet "down

to the speed
carpet "speedup
carpet "speeddown

to stop the car
carpet "stop
 
Last edited:
can u please explain where this goes?

function isWall(id)
local walls = {1025, 1032, 1028, 1030, 1035, 1027, 1219, 4645, 4647, 4646, 4644}
if isInArray(walls, id) == 1 then
return 1
else
return 0
end
end
 
thnx, to the directions
carpet "left
carpet "right
carpet "up
carpet "down

to the speed
carpet "speedup
carpet "speeddown

to stop the car
carpet "stop

does this have to go anywhere, can i chnage the words?
 
@up the words are what you say and if you can find somewhere in the script to change them you can
 
["up"] = {storage = storages.direction, new = 3, txt = "up"},
["down"] = {storage = storages.direction, new = 4, txt = "down"},
["left"] = {storage = storages.direction, new = 1, txt = "left"},
["right"] = {storage = storages.direction, new = 2, txt = "right"},
["speedup"] = {storage = storages.speed, new = status.speed-50, txt = "fast"},
["speeddown"] = {storage = storages.speed, new = status.speed+50, txt = "slow"},
["stop"] = {storage = storages.direction, new = -1, txt = "stop"}
change this and this
<talkaction words="carpet" script="flyingcarpet.lua" />
 
sorry but this is a bad script :p it might be functional, but you need to learn loops cuz this will need alot from your computer and could be shortened by maybe 80% :p
 
the vest car system is of jordanhenry xDD
Controls =

CTRL + Right left u know (no WASD)
 
Help, please!

When i say carpet in my forgotten server it says me "You are not in Flying carpet!".
How can i get it work?
When i say carpet, must there come new carpet?
Or whatt?
 
Back
Top