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

Changing town id when going through portal

poopsiedoodle

Gibe moni plos
Joined
Nov 23, 2011
Messages
2,458
Reaction score
585
Location
Georgia
I want to make it so that once a player goes through a portal in my nub island leading to the main, their town id changes. How would I script this and where would I put the script?
 
Citzen.lua - save this file in data/movements/scripts
Code:
function onStepIn(cid, item, position, fromPosition)
	if(item.actionid > 30020 and item.actionid < 30100) then
		local townId = (item.actionid - 30020)
		doPlayerSetTown(cid, townId)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are the newest resident of " .. getTownName(townId) .. ".")
	end

	return true
end

In movements.xml you need to put
Code:
<movevent type="StepIn" itemid="9773" event="script" value="citizen.lua"/>
notice that the tp id needs to be 9773 in this situation

Now after you've placed citizen.lua correctly and fixed movements.xml you need to decide what your TP's action ID will be. This can be easily figured out by using the following formula:
Code:
30020 + (town id) = action id
So if your town is thais with an id of 5 your action id for the teleporter will be 30025.

Thanks,
AmpedRPG staff /Justin

- - - Updated - - -

Let me know if this works for you! I'm pretty sure everything here is explained properly =)
 
I can't imagine why your 9773 id would be set to a ghost charm. What version of TFS are you using?

- - - Updated - - -

Either way, a simple fix would be to edit the line in movements.xml so that 9773 was set to the proper item id of your teleporter.
 
Back
Top