mm probably need to grab the number.It’s good to think, to define an area to identify the territory in which the player is.
idk what happened, but even in Town 1, he respawn at the temple after logging in.
I tried it both as an event and in the login script and I had the same result.
if player:getTown() ~= 1 then
if player:getTown():getId() ~= 1 then
Hello people,
I would like to know how I could make a system in which, if a player logs out of a town other than ID 1, upon logging in, he respawn in the temple of town 1. Its possible? How?
Sorry for my bad english, thx
local loginEvent = CreatureEvent("onLogin_EventName")
loginEvent:type("login")
function loginEvent.onLogin(player)
if player:getTown() ~= 1 then
player:teleportTo(Town(1):getTemplePosition())
end
return true
end
loginEvent:register()
It’s good to think, to define an area to identify the territory in which the player is.Yes, it's possible. Everything is possible if you have an idea.
In my opinion - you should make an script in creaturescripts using onLogout function which will be checking where player excatly is when he is doing "logout action", so you have to check areaPos (fromX, toY left top corner to right bottom corner) - an area - which will be "territory" of town 1 and if player is in this area and he is doing logout move (teleport) the character to position of town 2 temple.
Remember to declare perfectly the area because the "area" is always rectangle so it might be tricky.
I don't remember if character will be straight teleported while clicking Logout because TFS may recognize this action as "remove character from game (logout)" without any delay, so you can do it by giving storage to character (onLogout) and check the storage in onLogin and do the teleport thing in onLogin.
I don't know why you making that type of thing because it's kinda useless, but I gave you an tip how to do that. I don't know if there are other options to do that kind of thing.
idk what happened, but even in Town 1, he respawn at the temple after logging in.Lua:local loginEvent = CreatureEvent("onLogin_EventName") loginEvent:type("login") function loginEvent.onLogin(player) if player:getTown() ~= 1 then player:teleportTo(Town(1):getTemplePosition()) end return true end loginEvent:register()
mm probably need to grab the number.It’s good to think, to define an area to identify the territory in which the player is.
idk what happened, but even in Town 1, he respawn at the temple after logging in.
I tried it both as an event and in the login script and I had the same result.
if player:getTown() ~= 1 then
if player:getTown():getId() ~= 1 then
This worked, put in the login script, and in the end, for set player to town 1, like:mm probably need to grab the number.
change
toLua:if player:getTown() ~= 1 then
Lua:if player:getTown():getId() ~= 1 then
if player:getTown():getId() ~= 1 then
player:teleportTo(Town(1):getTemplePosition())
player:setTown(Town(1))
end