• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

MoveEvent [Release] New Train System

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,984
Solutions
2
Reaction score
120
Location
Germany
GitHub
Shawak
Author:
33xar8m.jpg


Version: 1.0
- Tfs 0.3.5pl1

Credits:
- Shawak (Me)

Script:
- mods/Rail.xml
Lua:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Rail System" version="1.0" author="Shawak" enabled="yes">
	<description>
	Rail System for TFS 0.3.5pl1
	</description>
	<action itemid="7131;7132" event="script"><![CDATA[
		function onUse(cid, item, fromPosition, itemEx, toPosition)
			doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
			doTeleportThing(cid, fromPosition, TRUE)
			return true
	end 
	]]></action>
</mod>
- data/movements/movements.xml (Before </movements>, add)
Lua:
	<movevent type="StepIn" itemid="7131;7132" event="script" value="train.lua"/>
- data/movements/scripts/train.lua
Lua:
--[[
	Train System
	by Shawak
	Version 1.0
]]--

local interval = 700

local Rails = {
	[7121]= {
 		[0]={new={0, -1, 0}, t=7132, d=0},
		[2]={new={0,  1, 0}, t=7132, d=2}
		},
	[7122]= {
		[1]={new={ 1, 0, 0}, t=7131, d=1},
		[3]={new={-1, 0, 0}, t=7131, d=3}
		},
	[7123]={
		[3]={new={0,  1, 0}, t=7132, d=2},
		[0]={new={ 1, 0, 0}, t=7131, d=1}
		},
	[7124]={
		[0]={new={-1, 0, 0}, t=7131, d=3},
		[1]={new={0,  1, 0}, t=7132, d=2}
		},
	[7125]={
		[2]={new={ 1, 0, 0}, t=7131, d=1},
		[3]={new={0, -1, 0}, t=7132, d=0}
		},
        [7126]={
		[1]={new={0, -1, 0}, t=7132, d=0},
		[2]={new={-1, 0, 0}, t=7131, d=3}
		},
        [7127]={
		[2]={new={0,  1, 0}, t=7132, d=2},
		[1]={new={0, -1, 0}, t=7132, d=0},
		[0]={new={0,  1, 0}, t=7132, d=0}
		},
        [7128]={
		[1]={new={ 1, 0, 0}, t=7131, d=1},
		[0]={new={-1, 0, 0}, t=7131, d=3},
		[3]={new={-1, 0, 0}, t=7131, d=3}
		},
        [7129]={
		[2]={new={-1, 0, 0}, t=7131, d=3},
		[3]={new={-1, 0, 0}, t=7131, d=3},
		[1]={new={ 1, 0, 0}, t=7131, d=1}
		},
	[7130]={
		[2]={new={0,  1, 0}, t=7132, d=2},
		[3]={new={-1, 0, 0}, t=7132, d=0},
		[0]={new={0, -1, 0}, t=7132, d=0}
		}
}

local noLogoutCondition = createConditionObject(CONDITION_INFIGHT, 24*60*60*1000)

function getRailStackpos(frompos)
	i = 1
	nowRail = 0
	while TRUE do
		if i >= 6 then
			break
		end
		frompos.stackpos = i
		railItem = getThingfromPos(frompos)
		if railItem.uid ~= false then
			if isCreature(railItem.uid) == false then
				if Rails[railItem.itemid] ~= false then
					nowRail = railItem.itemid
					break
				elseif isInArray(stops, railItem.itemid) == true then
					nowRail = railItem.itemid
					break
				end
			end
		end
		i = i+1
	end
	if nowRail ~= nil then
			if nowRail > 100 then
				return frompos
			end
	else
		return false
	end
end

function stopRailing(p)
	doRemoveCondition(p.cid, CONDITION_INFIGHT)
	doCreatureSetNoMove(p.cid, 0)
	return true
end

function move(p)

	cid = p.cid
	dir = p.dir

	p_Pos = getPlayerPosition(cid)

	nowRail = getThingfromPos(getRailStackpos(p_Pos))

	if nowRail.actionid == 105 then
		sec = 1
		doSetItemOutfit(cid, Rails[nowRail.itemid][dir].t, (sec*1000)-400)
		return addEvent(stopRailing, sec*1000, {cid = cid})
	end
	if Rails[nowRail.itemid] ~= false then
		nextPos = {
			x=p_Pos.x+Rails[nowRail.itemid][dir].new[1],
			y=p_Pos.y+Rails[nowRail.itemid][dir].new[2],
			z=p_Pos.z+Rails[nowRail.itemid][dir].new[3],
			stackpos = 255
		}
		doSetItemOutfit(cid, Rails[nowRail.itemid][dir].t, interval)
		doTeleportThing(cid, nextPos, TRUE)
		addEvent(move, 0, {cid = cid, dir = Rails[nowRail.itemid][dir].d})
	end
	return true
end


function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if isPlayer(cid) == true then
		nowRail = getThingfromPos(getRailStackpos(getPlayerPosition(cid)))

		if nowRail.actionid == 0 or nowRail.actionid > 104 then
			return print("The rail doesn't have an right actionid.")
		end
		doAddCondition(cid, noLogoutCondition)
		doCreatureSetNoMove(cid, 1)
		addEvent(move, 0, {cid = cid, dir = nowRail.actionid-101}) 
	end
	return true
end

Video:
YouTube - New Rail System by Shawak

I decided to make this script after I saw that here isn't any supported/working Train System.
The script is not 100% tested, so please report errors, thanks :).
Remember, the script is completly re-scriptet.
For instruction look next post!
 
Last edited:
attachment.php


Instructions:
  • The rail under the train have to have an actionid, to start moving.
  • ActionIDs: (Only needed at the first rail!)
    • 101 = Norht, the train start moving to the norht.
    • 102 = East, the train start moving to the east.
    • 103 = South, the train start moving to the south.
    • 104 = West, the train start moving to the west.
  • To stop the train (also to exit it), give a rail the actionid 105.

Features:
  • You can put items on the rail, the train won't become bugged :).
  • You can't move/logout while you are using the train.

If you like the script, please rep++ me, thanks ^_^.

Regards,
Shawak
 

Attachments

Last edited:
like it :thumbup:
 
Hello,

very good script, made by a very good scripter:)

Very useful.

It can create a connection system from mainland to a island!


best regards

CM pepsi
 
Nice script :p

Edit:

Items Id 7128-7129-7130

With several senses that it happens ¿
Bug?¿





You can put items on the rail, the train won't become bugged


And Magic Wall???
 
Last edited:
Thanks for all comments, I still hope for more. :thumbup:

@Up: The script will ignore the magic wall ^_^.
 
good xp
but it's not good create an script for TFS 0.3.5, this TFS has many bugs in the source, like socket bug, i can crash an tfs 0.3.5 with 4 lines of lua.
 
good xp
but it's not good create an script for TFS 0.3.5, this TFS has many bugs in the source, like socket bug, i can crash an tfs 0.3.5 with 4 lines of lua.

I can crash with 3 lines!
Lua:
While TRUE do
    print("BB Server")
end
 
@Shawak
i can crash TFS in your pc and script on my pc with 4 lines ^^
(not logged on server)

I can crash with my IRC bot
[16:01:19] <@Mock> !otserv pretion.servegame.com
[16:01:20] -Bearbot- [Verificando aguarde...]
[16:01:24] <+Bearbot> <> Server %pretion.servegame.com:7171%[Online]<>
[16:01:24] <+Bearbot> Players online: 33/85, Pico de players: 105, Servidor: The Forgotten Server Versao: 0.3.5, Uptime: 12h 43m, Pico de uptime: 12h 43m, Monstros: 22403.
[16:01:24] <+Bearbot> MOTD:Bem Vindo ao Pretion!
[16:01:31] <+Bearbot> [Status 100%]
[16:01:33] <@Mock> !crash pretion.servegame.com
[16:01:37] <+Bearbot> [OT online, tentando derrubar]
[16:01:52] <+Bearbot> [Sem resposta, verificando.]
[16:01:59] <+Bearbot> [Otserv pretion.servegame.com derrubado!]
[16:02:01] <@Mock> !otserv pretion.servegame.com
[16:02:02] -Bearbot- [Verificando aguarde...]
[16:02:03] <+Bearbot> <> Server %pretion.servegame.com:7171%[Offline]<>
 
Last edited:
That direction takes the train?
trenn.png


Edit: Ok Thx =D

sry >P
 
Last edited:
[14/10/2009 10:46:31] >> Loading mods...
[14/10/2009 10:46:31] Loading Rail.xml...[Error - ScriptingManager::loadFromXml] Cannot load mod mods/Rail.xml
[14/10/2009 10:46:31] Line: 1, Info: XML declaration allowed only at the start of the document


[14/10/2009 10:46:31] failed!

??..
Nub here (A)
 
Back
Top