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

Action [TFS1.3] Change gender rune

Landera

Veteran OT User
Joined
Nov 24, 2011
Messages
905
Solutions
1
Reaction score
318
Hello I'd like to share this little change gender rune I saw this new item en thought of this right away, very easy to script but maybe somebody likes it anyway :)

1601747265192.png

This in your action.xml
XML:
<action itemid="32605" script="tools/changesexrune.lua" />

<data\actions\scripts\tools>
changesexrune.lua

XML:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end
    if player:getGroup():getAccess() then
        player:setSex(player:getSex() == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have changed your sex.")
        player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
        item:remove(1)
        return true
    end
    end

It works like a rune you have to use it on yourself and done ur done for 2020.
 
Last edited:
Lua:
local playersCanUse = true

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local target = Player(target)
    
    if not target then return false end
    
    if not playersCanUse and not player:getGroup():getAccess() then return false end
    
    if playersCanUse and target:getId() ~= player:getId() then
        return player:sendCancelMessage("You may only change your own sex.")
    end
    
    target:setSex(player:getSex() == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
    target:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
    item:remove(1)
    
    if target:getId() ~= player:getId() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have changed "..target:getName().."('s) sex.")
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have changed your sex.")
    end
return true
end
 
I've made an edit it changes the outfit right away to female or male citizen base.

PHP:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end
    if player:getGroup() then
        player:setSex(player:getSex() == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
        local outfit = player:getOutfit()
        if player:getSex(cid) == PLAYERSEX_MALE then
            outfit.lookType = 128
        else
            outfit.lookType = 136
        end
        player:setOutfit(outfit)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have changed your sex.")
        player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
        item:remove(1)
        return true
    end
end

@mods cant edit the main post can somebody update the first post?
 
Last edited:
I tried doing this myself some time ago and couldn't get it to work, I thought I had to use item editor to solve the issue but nevermind.

Thanks :D

You should also consider adding the line to prevent people from using it on other players like ltutorial did. Unless it's already edited in there and I can't see it?
 
I tried doing this myself some time ago and couldn't get it to work, I thought I had to use item editor to solve the issue but nevermind.

Thanks :D

You should also consider adding the line to prevent people from using it on other players like ltutorial did. Unless it's already edited in there and I can't see it?

If I try to use it on an other player im getting a sex change, so no way of changing somebody else.
 
All modifications added if anyone wants it

Lua:
local playersCanUse = true

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local target = Player(target)
   
    if not target then return false end
   
    if not playersCanUse and not player:getGroup():getAccess() then return false end
   
    if playersCanUse and target:getId() ~= player:getId() then
        return player:sendCancelMessage("You may only change your own sex.")
    end
   
    local outfit = target:getOutfit()
    if target:getSex() == PLAYERSEX_FEMALE then
        outfit.looktype = 128
    else
        outfit.looktype = 136
    end
   
    if target:getId() ~= player:getId() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have changed "..target:getName().."('s) sex.")
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have changed your sex.")
    end
   
    target:setOutfit(outfit)
    target:setSex(player:getSex() == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
    target:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
    item:remove(1)
return true
end

and landra this part in your code is not right
Lua:
if player:getSex(cid) == PLAYERSEX_MALE then
 
All modifications added if anyone wants it

Lua:
local playersCanUse = true

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local target = Player(target)
   
    if not target then return false end
   
    if not playersCanUse and not player:getGroup():getAccess() then return false end
   
    if playersCanUse and target:getId() ~= player:getId() then
        return player:sendCancelMessage("You may only change your own sex.")
    end
   
    local outfit = target:getOutfit()
    if target:getSex() == PLAYERSEX_FEMALE then
        outfit.looktype = 128
    else
        outfit.looktype = 136
    end
   
    if target:getId() ~= player:getId() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have changed "..target:getName().."('s) sex.")
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have changed your sex.")
    end
   
    target:setOutfit(outfit)
    target:setSex(player:getSex() == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
    target:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
    item:remove(1)
return true
end

and landra this part in your code is not right
Lua:
if player:getSex(cid) == PLAYERSEX_MALE then

Nice modifications I'm not home atm but forgot to fix an bug regarding to addons.
 
Back
Top