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
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
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
[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
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
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
Way betterThe 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