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

mhm cant figure it out (Citizen)

Wiw3K

New Member
Joined
Apr 16, 2008
Messages
371
Reaction score
3
i have tp in Venore with UniqueID 8000 , after enter you became citizen , in Edron its 8001 , Carlin 8002 , take a look at my script , what i did wrong?

Lua:
function onStepIn(cid, item, position, fromPosition)
    if item.uniqueid > 8000 and item.uniqueid < 8100 then
        doPlayerSetTown(cid, item.uniqueid - 8000)
            if getPlayerTown(cid) == 1 then
                doSendAnimatedText(playerPos, 'You became citizen of a Venore', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 2 then
                doSendAnimatedText(playerPos, 'You became citizen of a Edron', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 3 then
                doSendAnimatedText(playerPos, 'You became citizen of a Carlin', TEXTCOLOR_GOLD)
            end
        end
    return TRUE
end
 
Last edited:
I have Tps with Unique ID 800X:
8000 - 1st town
8001 - 2nd town
8002 - 3rd town
...
8015 - last town

i have everything setted up on map but need to make script , there is my full script which dont work:


Lua:
function onStepIn(cid, item, position, fromPosition)
    if item.uniqueid > 8000 and item.uniqueid < 8100 then
        doPlayerSetTown(cid, item.uniqueid - 8000)
            if getPlayerTown(cid) == 1 then
                doSendAnimatedText(playerPos, 'You became citizen of a Venore', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 2 then
                doSendAnimatedText(playerPos, 'You became citizen of a Edron', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 3 then
                doSendAnimatedText(playerPos, 'You became citizen of a Carlin', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 4 then
                doSendAnimatedText(playerPos, 'You became citizen of a Ab dendriel', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 5 then
                doSendAnimatedText(playerPos, 'You became citizen of a Kazordoon', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 6 then
                doSendAnimatedText(playerPos, 'You became citizen of a Thais', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 7 then
                doSendAnimatedText(playerPos, 'You became citizen of a Darashia', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 8 then
                doSendAnimatedText(playerPos, 'You became citizen of a Port Hope', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 9 then
                doSendAnimatedText(playerPos, 'You became citizen of a Svargrond', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 10 then
                doSendAnimatedText(playerPos, 'You became citizen of a Ankrahmun', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 11 then
                doSendAnimatedText(playerPos, 'You became citizen of a Liberty Bay', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 12 then
                doSendAnimatedText(playerPos, 'You became citizen of a Donate Island', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 13 then
                doSendAnimatedText(playerPos, 'You became citizen of a Azeroth', TEXTCOLOR_GOLD)
            elseif getPlayerTown(cid) == 14 then
                doSendAnimatedText(playerPos, 'You became citizen of a Thais', TEXTCOLOR_GOLD)
            end
        end
    return TRUE
end
 
You can use/modify this: (Taken from private SVN)
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

use as always 30020 + townid
 
You can use/modify this: (Taken from private SVN)
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

use as always 30020 + townid
ahh thats not the point T_T ale dziena ;)
 
Ok then if you want use your script (these are still same) - you have error in playerPos - change to getCreaturePosition(cid)

and dont make 15 'else if' but use getTownName(id)

look:
Code:
local towns = {
	"Venore",
	"Edron",
	"Carlin"
}

function onStepIn(cid, item, position, fromPosition)
	if item.uniqueid > 8000 and item.uniqueid < 8100 then
		local newTown = item.uniqueid - 8000
		doPlayerSetTown(cid, newTown)
                doSendAnimatedText(getCreaturePosition(cid, 'You became citizen of a ' .. towns[newTown], TEXTCOLOR_GOLD)
        end
	return TRUE
end

Still if you would like to use normal 32000 + townId you won't need declaring these 'towns'. It will be automatic. Isn't it easiest?
 
ahh still something wrong in your script Slawkens

Lua:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/citizen.lua:onStepIn

data/movements/scripts/citizen.lua:18: attempt to compare number with nil
stack traceback:
        data/movements/scripts/citizen.lua:18: in function <data/movements/scrip
ts/citizen.lua:17>

thats the script:
Lua:
  local towns = {
        "Venore",
        "Edron",
        "Carlin",
        "Ab dendriel",
        "Kazordoon",
        "Thais",
        "Darashia",
        "Port Hope",
        "Svargrond",
        "Ankrahmun",
        "Liberty Bay",
        "Donate Island",
        "Azeroth"
}

function onStepIn(cid, item, position, fromPosition)
        if item.uniqueid > 8000 and item.uniqueid < 8100 then
                local newTown = item.uniqueid - 8000
                doPlayerSetTown(cid, newTown)
                doSendAnimatedText(getCreaturePosition(cid, 'You became citizen of a ' .. towns[newTown], TEXTCOLOR_GOLD))
        end
        return TRUE
end
 
Back
Top