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

change sex

ZeroSkyer

New Member
Joined
May 17, 2019
Messages
31
Reaction score
4
Location
EEUU
Hello, could someone guide me? My outfit system is based on the fact that if you are male you will get only the male outfit, and not like in quests that you get both. How could I do to give the female outfit in the sex change? I understand that there is no function in tfs like if player:hasoutfit, thanks in advance.

Lua:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    -- Adding outfits
    local outfit = player:getOutfit()
    if player:getSex() == PLAYERSEX_FEMALE then
        outfit.looktype = 128
    else
        outfit.looktype = 136
    end
  
    if player:getId() ~= player:getId() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have changed "..player:getName().."('s) sex.")
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have changed your sex.")
    end
  
    player:setOutfit(outfit)
    player:setSex(player:getSex() == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
    player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
    item:remove(1)
return true
end
Post automatically merged:

I already saw that if the function "hasoutfit" exists, how gross I am. Well anyway, could someone help me with the code for that, give the female outfit if you have the male outfit?
 
Solution
Lua:
local outfits = {
    -- Add all outfits here --
    [1] = {male = 128, female = 136}
}

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    -- Adding outfits
    local outfit = player:getOutfit()
    if player:getSex() == PLAYERSEX_FEMALE then
        outfit.looktype = 128
        for i = 1, #outfits do
            if player:hasOutfit(outfits[i].female) then
                player:addOutfit(outfits[i].male)
            end
        end
    else
        outfit.looktype = 136
        for i = 1, #outfits do
            if player:hasOutfit(outfits[i].male) then
                player:addOutfit(outfits[i].female)
            end
        end
    end
  
    if player:getId() ~= player:getId() then...

Itutorial

Excellent OT User
Joined
Dec 23, 2014
Messages
1,973
Solutions
52
Reaction score
671
Lua:
local outfits = {
    -- Add all outfits here --
    [1] = {male = 128, female = 136}
}

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    -- Adding outfits
    local outfit = player:getOutfit()
    if player:getSex() == PLAYERSEX_FEMALE then
        outfit.looktype = 128
        for i = 1, #outfits do
            if player:hasOutfit(outfits[i].female) then
                player:addOutfit(outfits[i].male)
            end
        end
    else
        outfit.looktype = 136
        for i = 1, #outfits do
            if player:hasOutfit(outfits[i].male) then
                player:addOutfit(outfits[i].female)
            end
        end
    end
  
    if player:getId() ~= player:getId() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have changed "..player:getName().."('s) sex.")
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have changed your sex.")
    end
  
    player:setOutfit(outfit)
    player:setSex(player:getSex() == PLAYERSEX_FEMALE and PLAYERSEX_MALE or PLAYERSEX_FEMALE)
    player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
    item:remove(1)
return true
end
 
Solution
OP
OP
ZeroSkyer

ZeroSkyer

New Member
Joined
May 17, 2019
Messages
31
Reaction score
4
Location
EEUU
Thanks brother, it works perfect. I made some small changes to verify if the player had the addons 1, 2 unlocked in the outfit and also to give the addons, since it only gave the outfit and not the addons, but you helped me too much I did not know what to do.
These are the modifications I made.

Lua:
-- Adding outfits
    local outfit = player:getOutfit()
    if player:getSex() == PLAYERSEX_FEMALE then
        outfit.looktype = 128
        for i = 1, #outfits do
            if player:hasOutfit(outfits[i].female, 3) then
                player:addOutfitAddon(outfits[i].male, 3)
            end
        end
    else
        outfit.looktype = 136
        for i = 1, #outfits do
            if player:hasOutfit(outfits[i].male, 3) then
                player:addOutfitAddon(outfits[i].female, 3)
            end
        end
    end
 
Top