MoveEvent Nahruto's Car.

Status
Not open for further replies.

Jano

oturhaN
Joined
Feb 21, 2008
Messages
876
Best answers
0
Reaction score
67
Location
Chile
Video Here.


this is the TFS version

data/movements.scripts

car.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}
doCreateItem(7267,1,newpos)
doTeleportThing(x.cid, newpos, FALSE)
doRemoveItem(Car.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}
doCreateItem(7267,1,newpos)
doTeleportThing(x.cid, newpos, FALSE)
doRemoveItem(Car.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}
doCreateItem(7266,1,newpos)
doTeleportThing(x.cid, newpos, FALSE)
doRemoveItem(Car.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}
doCreateItem(7266,1,newpos)
doTeleportThing(x.cid, newpos, FALSE)
doRemoveItem(Car.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 >= 2500 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
            CheckLeft = getThingfromPos({x = pos.x-1, y = pos.y, z = pos.z, stackpos = 1})
            if isWall(CheckLeft.itemid) == 1 or isCreature(CheckLeft.uid) == 1 then
                setPlayerStorageValue(cid, storages.direction, 2)
                addEvent(CarMoveRight, status.speed, x)
            else
                addEvent(CarMoveLeft, status.speed, x)
            end
        elseif status.direction == 2 then
            CheckRight = getThingfromPos({x = pos.x+1, y = pos.y, z = pos.z, stackpos = 1})
            if isWall(CheckRight.itemid) == 1 or isCreature(CheckRight.uid) == 1 then
                setPlayerStorageValue(cid, storages.direction, 1)
                addEvent(CarMoveLeft, status.speed, x)
            else
                addEvent(CarMoveRight, status.speed, x)
            end            
        elseif status.direction == 3 then
            CheckUp = getThingfromPos({x = pos.x, y = pos.y-1, z = pos.z, stackpos = 1})
            if isWall(CheckUp.itemid) == 1 or isCreature(CheckUp.uid) == 1 then
                setPlayerStorageValue(cid, storages.direction, 4)
                addEvent(CarMoveDown, status.speed, x)
            else
                addEvent(CarMoveUp, status.speed, x)
            end
        elseif status.direction == 4 then
            CheckDown = getThingfromPos({x = pos.x, y = pos.y+1, z = pos.z, stackpos = 1})
            if isWall(CheckDown.itemid) == 1 or isCreature(CheckDown.uid) == 1 then
                setPlayerStorageValue(cid, storages.direction, 3)
                addEvent(CarMoveUp, status.speed, x)            
            else
				addEvent(CarMoveDown, status.speed, x)    
            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="7267" script="car.lua" />
<movevent event="StepIn" itemid="7266" script="car.lua" />

data/talkactions/scripts

car.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 car.")
end
end
data/talkations/talkactions.xml add.

Code:
<talkaction words="car" script="car.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

here
Code:
local walls = {1025, 1032, 1028, 1030, 1035, 1027, 1219, 4645, 4647, 4646, 4644}
add all the wall, door, and items that you wont the car go on Ids.



Controls

to the directions.
car "left
car "right
car "up
car "down

to the speed.
car "speedup
car "speeddown

to stop the car
car "stop
 

Clary

New Member
Joined
Mar 7, 2008
Messages
1,007
Best answers
0
Reaction score
1
ye i know it it is great but can u till me how to make it
for example u say car "down it will go down 1 step
if u say car "downdown it keeps going down
would be great if u help me in this (it will work for all right, left, down & up down was just an example)
 

spash

I
Joined
Jul 21, 2007
Messages
182
Best answers
0
Reaction score
2
Location
Germany
[13/06/2008 05:39:17] Lua Script Error: [MoveEvents Interface]
[13/06/2008 05:39:17] data/movements/scripts/car.lua:eek:nStepIn

[13/06/2008 05:39:17] data/movements/scripts/car.lua:21: attempt to call global 'isWall' (a nil value)

This is what i get!
I use TFS 0.3 rev 815
 

Tony

New Member
Joined
Sep 23, 2007
Messages
81
Best answers
0
Reaction score
0
Where do you add the functioniswall part cuz mine's not working :(
 

Tony

New Member
Joined
Sep 23, 2007
Messages
81
Best answers
0
Reaction score
0
Is There any way this could be configured to work with The New TFS distro?
Thanks, Tony
 

Reah

New Member
Joined
Jul 7, 2008
Messages
87
Best answers
0
Reaction score
0
when i go into wall i got crashed... My car... Need to change my AC in Liberty Direct... :D Good! Awesome script
 

richux

Tibera.org
Joined
Aug 18, 2008
Messages
3,667
Best answers
0
Reaction score
24
Location
---------
Holy crap!!! Rofl!! GOna try it right now. :D :D

Edited: Not working for me. If i step on the car and say any command, it shoves Invalid operation :S
 
Last edited:

Yakushi

New Member
Joined
Dec 30, 2008
Messages
110
Best answers
0
Reaction score
0
Location
Germany
Please help!!

When I am in car, and say car "up or car "right or the other things, there appear: You are not in car.

Please help! I mapped the sled ID 7266 and 7267 in my city. Then i walk in it, but it doesn't go.
Pls help!
 

kilergui

New Member
Joined
Apr 20, 2010
Messages
40
Best answers
0
Reaction score
0
help When I am in car, and say car "up or car "right or the other things, there appear: You are not in car.

Please help! I mapped the sled ID 7266 and 7267 in my city. Then i walk in it, but it doesn't go.
Pls help!
 

Zerak

http://otstatus.com/
Joined
Oct 4, 2009
Messages
1,126
Best answers
0
Reaction score
47
Location
Sweden
i hate this where is the training way?
 

nisam

New Member
Joined
Jun 12, 2010
Messages
3
Best answers
0
Reaction score
0
where i put that Function isWall...

Code:
 
Status
Not open for further replies.
Top