• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

how I can make tp if used, go to residence city

Code:
function onUse(cid, item, frompos, item2, topos)
	if item.uid==10000 then
		newpos = {x=xxx, y=xxx, z=x} -- possition of the town.
		doPlayerSetTown(cid, 1) -- put the town id here
		doPlayerSendTextMessage(cid,22,"You have changed your residence to cityname ")
		doTeleportThing(cid,newpos)
		doSendMagicEffect(newpos,12)
		return 1
	end
end
 
The script could be shortened, not that it's really necessary or something.

This will do exactly what you said without having to change anything. It will get the player town ID and then look for the temple position of this town, and teleport him there.
Code:
function onUse(cid, item, frompos, item2, topos)
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
		doPlayerSendTextMessage(cid, 22, "Welcome back, my friend!")
		doSendMagicEffect(getCreaturePosition(cid), 12)
	return true
end
 
Last edited:
I use that same script spoking mentioned and what it does is that teleports you somehwere else and the teleport becomes a ramp.

How do i fix this?
 
function onStepIn(cid, item, pos)

LUA:
local t = {x=xxxx, y=xxxx, z=x}

    if item.actionid == 4567 then  -- ActionID of the Portal
        doPlayerSetTown(cid,1)  -- TownID
		doTeleportThing(cid,t) -- Town Name
        doSendMagicEffect(getCreaturePosition(cid),12)
		doPlayerSendTextMessage(cid,22, "Enter Your Text Here")
        end
    return 1
end
 
Then I get this error

[Error - LuaScriptInterface::loadFile] data/movements/scripts/citizen.lua:21: '<eof>' expected near 'end'
[Warning - Event::loadScript] Cannot load script (data/movements/scripts/citizen.lua)
data/movements/scripts/citizen.lua:21: '<eof>' expected near 'end'
>> Loading chat channels


Edit: Nvm I got rid of the error. Testing it now.
Thanks

Edit 2: Thanks it worked like a charm. Thank you appreciated.
 
Last edited:
function onStepIn(cid, item, position, fromPosition)local t = {x=4282, y=4279, z=7}

if item.actionid == 30021 then -- ActionID of the Portal
doPlayerSetTown(cid,1) -- TownID
doTeleportThing(cid,t) -- Town Name
doSendMagicEffect(getCreaturePosition(cid),12)
doPlayerSendTextMessage(cid,22, "You have become an Oxolon resident")
end
return 1
end




function onStepIn(cid, item, position, fromPosition)
local t = {x=4149, y=4310, z=5}
if item.actionid == 30022 then -- ActionID of the Portal
doPlayerSetTown(cid,1) -- TownID
doTeleportThing(cid,t) -- Town Name
doSendMagicEffect(getCreaturePosition(cid),12)
doPlayerSendTextMessage(cid,22, "You have become a Vandura resident")
end
return 1
end


But it does not work.
Am I doing something wrong?

EDIT: I think I am not changing the town ID. Doing some testing now.

EDIT: Worked. That was the problem. When I copied the second script I did not change the town ID so the portal was still setting the town id to 1 rather than 2.

Thanks once Again
 
Last edited:
But it does not work.
Am I doing something wrong?

EDIT: I think I am not changing the town ID. Doing some testing now.

EDIT: Worked. That was the problem. When I copied the second script I did not change the town ID so the portal was still setting the town id to 1 rather than 2.

Thanks once Again

Me here again -_-

This time I did test but it did not work what I tried.

I have

function onStepIn(cid, item, position, fromPosition)
local t = {x=4282, y=4279, z=7}

if item.actionid == 30021 then -- ActionID of the Portal
doPlayerSetTown(cid,1) -- TownID
doTeleportThing(cid,t) -- Town Name
doSendMagicEffect(getCreaturePosition(cid),12)
doPlayerSendTextMessage(cid,22, "You have become an Oxolon resident")
end
return 1
end


function onStepIn(cid, item, position, fromPosition)
local t = {x=4149, y=4310, z=5}
if item.actionid == 30022 then -- ActionID of the Portal
doPlayerSetTown(cid,2) -- TownID
doTeleportThing(cid,t) -- Town Name
doSendMagicEffect(getCreaturePosition(cid),12)
doPlayerSendTextMessage(cid,22, "You have become a Vandura resident")
end
return 1
end





When I had the first part, the residence for the first city worked. When I added the second part, the second city worked but later I realized that the first residence got messed up. Now the residence of the first city does not work, I walk right by and if I do /t it brings me back to the temple of second city.

Any Ideas.
This time I did run test before posting and try to play around with the code and change stuff but it did not work. Any help would be appreciated.
 
The script could be shortened, not that it's really necessary or something.

This will do exactly what you said without having to change anything. It will get the player town ID and then look for the temple position of this town, and teleport him there.
Code:
function onUse(cid, item, frompos, item2, topos)
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
		doPlayerSendTextMessage(cid, 22, "Welcome back, my friend!")
		doSendMagicEffect(getCreaturePosition(cid), 12)
	return true
end
Way better
 
Way better


the problem with that is that turns my teleport into a ramp, and it takes me to the roof of the building where the teleport is at.

Is not working for me.
Any other suggestion?

The one that Lakh worked like a charm for once city, but when I try to combine with more than one city then does not work properly.

Edit: I even changed the onuse to onstepin and still doesnt work. It tells you welcomeback my friend or whatever, teleports you but when you do /t with the gm still send you to the temple of the previous city.
 
Last edited:
Back
Top