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

Lua Click on a Statue to turn into a citizen

alltus

Active Member
Joined
Aug 5, 2020
Messages
49
Reaction score
31
Hello guys!
I would like to, when the players in my server click on a Statue (Version 10.98, fts 1.2-64 bit), to turn into a citizen of the specified city (also having the message "Congratulations, you're now a Citizen of xxx...).
Thanks a lot!
 
add this to your data\actions\scripts in a Lua script, name it whatever you want.
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.actionid > 30020 and item.actionid < 30050 then
        player:setTown(Town(item.actionid - 30020))
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are now a citizen of " .. Town(item.actionid - actionIds.citizenship):getName() .. ".")
    end
    return true
end
then add this in data\actions\actions.xml
XML:
<action itemid="your statue idhere" script="yourscriptname.lua" />
and then do the same you did with teleport to the statue.
 
Last edited:
for the message, add bellow line 7:

Lua:
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are now a citizen of " .. Town(item.actionid - actionIds.citizenship):getName() .. ".")
 
add this to your data\actions\scripts in a Lua script, name it whatever you want.
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.actionid > 30020 and item.actionid < 30050 then
        if not creature:isPlayer() then
            return false
        end

        creature:setTown(Town(item.actionid - 30020))
    end
    return true
end
then add this in data\actions\actions.xml
XML:
<action itemid="your statue idhere" script="yourscriptname.lua" />
and then do the same you did with teleport to the statue.
creature -> player

Since npc's and monsters can't 'use' objects, you can remove that check as well.
 
Back
Top