<movevent event="StepIn" uniqueid="40001" script="citizenship.lua" /> <!-- Town with ID 1 -->
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if player == nil then
return false
end
local newTownId = item.uid-40000
local towns = Game:getTowns()
local newTownName = towns[newTownId]:getName()
if player:getTown():getID() ~= newTownId then
player:setTown(newTownId)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now citizen of " .. newTownName .. ".")
return true
end
return false
end
Haven't tested it, may not work.
In data/movements/movements.xml add line:
XML:<movevent event="StepIn" uniqueid="40001" script="citizenship.lua" /> <!-- Town with ID 1 -->
In data/movements/scripts add new file named citizenship.lua:
Lua:function onStepIn(creature, item, position, fromPosition) local player = creature:getPlayer() if player == nil then return false end local newTownId = item.uid-40000 local towns = Game:getTowns() local newTownName = towns[newTownId]:getName() if player:getTown():getID() ~= newTownId then player:setTown(newTownId) player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now citizen of " .. newTownName .. ".") return true end return false end
Dont forget to place teleport with unique id of 40001 on map leading to temple of your town with id 1.
function onStepIn(creature, item, position, fromPosition)
local player = creature:getPlayer()
if player == nil then
return false
end
local newTownId = item.uid-40000
if player:getTown():getID() ~= newTownId then
local newTown = Town(newTownId)
player:setTown(newTown)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now citizen of " .. newTown:getName().. ".")
return true
end
return false
end
If not working post the error from console.
Lua:function onStepIn(creature, item, position, fromPosition) local player = creature:getPlayer() if player == nil then return false end local newTownId = item.uid-40000 if player:getTown():getID() ~= newTownId then local newTown = Town(newTownId) player:setTown(newTown) player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now citizen of " .. newTown:getName().. ".") return true end return false end
function onStepIn(cid, item, position, fromPosition)
local player = Player(cid)
if not player then
return false
end
local newTownId = item.uid - 40000
if player:getTown():getId() ~= newTownId then
local newTown = Town(newTownId)
player:setTown(newTown)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now citizen of " .. newTown:getName().. ".")
end
return true
end
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
Try this >>>>>>>>>>>>>>>>
Lua:function onStepIn(cid, item, position, fromPosition) local player = Player(cid) if not player then return false end local newTownId = item.uid - 40000 if player:getTown():getId() ~= newTownId then local newTown = Town(newTownId) player:setTown(newTown) player:sendTextMessage(MESSAGE_INFO_DESCR, "You are now citizen of " .. newTown:getName().. ".") end return true end
I use this.
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
If you use thisDoesn't Work. It also doesn't show anything on the Console.
Post automatically merged:
Sould i put this lua as a uniqueid=40001 as well or as actionid = 30020
<movevent event="StepIn" uniqueid="40001" script="citizen.lua" />
Post automatically merged:
And the Console is telling me something about the "unique ID Duplicated" if the 40001 is duplicated how can i change it to another unique ID? Do i have to make changes in the lua also?
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
If you use this
Then you set the action ID on teleporter to 30021 for town 1 and 30022 for town 2 and so on.Lua: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
and then it set up on the Movement.XML like this?
<movevent event="StepIn" actionid="30020" script="citizen.lua" />
and then it set up on the Movement.XML like this?
<movevent event="StepIn" actionid="30020" script="citizen.lua" />
Post automatically merged:
and didnt work.
<movevent event="StepIn" actionid="30021" script="citizen.lua" />