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

Action Mock Train system V 1.0

Mock

Mock the bear (MTB)
Joined
Jul 29, 2008
Messages
619
Reaction score
106
Location
Brazil
  • Author: Mock
  • Tested: TFS 0.3.6

With script script you need only add one AID (on train), and only add the rail custom!
like this:
reil.png

You can see this script in action on this video:
http://www.youtube.com/watch?v=9xz7XM8loog

First i have to THX nord by tables and, ids and a bit help :)

Add only this tag on actions.xml:
Code:
<action itemid="7131" event="script" value="railbymock.lua" />
<action itemid="7132" event="script" value="railbymock.lua" />
And in railbymock.lua add it:
Lua:
--Script by mock the bear
--Config
local SPEED = 200
local PLAYERSPEED = 250
--End
local RAILS = {7121, 7122, 7123, 7124, 7125, 7126, 7127, 7128, 7129, 7130} --Thxy rails itemid by nord :P
local CART = {[0] = 7132, [2] = 7132, [3] =7131, [1] =7131}
local CONFIG = {
	[7121] = 0,[7122] = 0,
	[7123] = {EAST, SOUTH},
	[7124] = {WEST, SOUTH},
	[7125] = {EAST, NORTH},
	[7126] = {WEST, NORTH},
	[7127] = 0,[7128] = 0,
	[7129] = 0,[7130] = 0,
	--Random
}
local reverse = {[0] = 2, 3, 0, 1} -- All that table was made by nord.
local function moveTrain(cid, frompos, direc)
	local tab
	if not isPlayer(cid) then
		return
	end
	local pos = getCreaturePosition(cid)
	local rar = findRail(pos)
	if not rar then
		doPlayerSetNoMove(cid, false)
		doRemoveCondition(cid, CONDITION_OUTFIT)
		doChangeSpeed(cid, -PLAYERSPEED)
		doMoveCreature(cid, direc)
	else
		tab = CONFIG[rar]
		if tab and type(tab) == 'table' then
			direc =  tab[tab[1] == reverse[direc] and 2 or 1] -- by nord here
		end
		doSetItemOutfit(cid, CART[direc], -1)
		doMoveCreature(cid, direc)
		addEvent(moveTrain, SPEED, cid, pos,direc)
	end
end
function findRail(p)
	local p_ = {x=p.x, y=p.y, z=p.z}
	for i=0,10 do
		p_.stackpos = i
		local t = getTileThingByPos(p_)
		if isInArray(RAILS, t.itemid) then
			return t.itemid,t.uid
		end
	end
end
function onUse(cid, item, frompos) --Script by mock the bear
	if hasCondition(cid, CONDITION_OUTFIT) or  (item.actionid < 500 and item.actionid > 503) then
		return false
	end
	doTeleportThing(cid, frompos, false)
	doPlayerSetNoMove(cid, true)
    doChangeSpeed(cid, PLAYERSPEED)
	addEvent(moveTrain, SPEED, cid, frompos, item.actionid-500)
	return true
end

Now create your custom rain and set one AID on train.
If you way start to nort set AID 500, to south set 502 to lest 501 to wast 503 :thumbup:
 
Last edited:
Tem um parecido aqui, eh melhor ? pior ? mesma coisa?
Mock, aqueles seus "training" ali ..
eles healam o player?
Me da o .xml ai *-* !!!


-Cara, namoral, seus scripts sao MUITOOOOOO complexos O_O
Não sei como tu consegue scriptar isso o_O-
 
@MrLipzZz
better because use only one script and one AID.
 
Great system, ive got a funny idea, you could use the blank tiles also to make jumps, use a ramp 1 side so you go +1 floor jump over a hole in the ground like a canyon, then have a stair tile to take you -1 to a landing ramp. then all you need is indiana jones music in the background hahaha. great system
 
I changed this:
Code:
<action itemid="7134" event="script" value="railbymock.lua" />
to:
Code:
<action uniqueid="7134" event="script" value="railbymock.lua" />
'cause with first option dont runs (only with itemid=7134, but have also an error)

and got this error on tfs 0.3.6pl1 :S
Code:
[25/07/2010 00:56:55] [Error - Action Interface] 
[25/07/2010 00:56:55] In a timer event called from: 
[25/07/2010 00:56:55] data/actions/scripts/railbymock.lua:onUse
[25/07/2010 00:56:55] Description: 
[25/07/2010 00:56:55] data/actions/scripts/railbymock.lua:25: attempt to call global 'findRail' (a nil value)
[25/07/2010 00:56:55] stack traceback:
[25/07/2010 00:56:55] 	data/actions/scripts/railbymock.lua:25: in function <data/actions/scripts/railbymock.lua:19>
 
@mock
i'll copy it again, but i copied it 2 times before posting here :S
 
but how must it be,
Code:
<action uniqueid="7134" event="script" value="railbymock.lua" />
or
Code:
<action itemid="7134" event="script" value="railbymock.lua" />
 
Back
Top