• 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 Looking for an outfit remover movement TFS 1.2

Udun

Well-Known Member
Joined
Jan 5, 2012
Messages
192
Solutions
1
Reaction score
67
Hey guys! Im tryng to implement a race system.
This is the situation:
When the char enter in game the outfit is the ghost outfit looktype 319 (also it gain other outfits by vocation)
The movement should activate when the char step in a X sqm (with action or unique id) this remove the 319 and change the outfit to another ones (2 in this case for both sexes, for example looktypes 905 (female) and 906 (male)

I have been seaching in the forums and I found some codes but didn't work, some are from 0.3 era, etc

So I need 2 movements:
1: first removes the outfit 319 from the player storage
2: change the outfit 319 in the char and replace for 905 and 906
A little extra:
It would be very nice to set the "change outfit" window with the color palete when the 2nd movement is triggered

Thanks in advance!
 
Last edited:
Solution
thank you very much for trying to help me!
I tested it and I'm getting this error in console:
Lua:
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerOutfit = player:getOutfit()
    playerOutfit.lookAddons = 0
    
    if player:getSex() == PLAYERSEX_FEMALE then
        playerOutfit.lookType = 905
    else
        playerOutfit.lookType = 906
    end

    player:setOutfit(playerOutfit)
    player:removeOutfit(319)
    return true
end
In data/xml/outfits.xml you should have the outfit 319 enabled there.
it is enabled, is the only outfit enabled of all (unlocked).
then when the char connects gain the outfits by vocation but then I need to eliminate the ghost outfit or the char will have it forever and wont we'll be accurate for the race system
 
Last edited:
The website enables the outfit? or the source code of the server does?
this is how it works:
1. create char in website choosing race (custom vocation, same as in tibia)
2. in outfits.xml all the outfits are locked except the ghost outfit so when the char enter only appear this outfit by defect
3. at the same time when the char gain the exclusive outfits for the race with a creature script that gives you and unlock the race specific outfits (now if I eliminate the ghost base outfit and lock them all in outfits.xml the creature script doesn't work properly cause it seems that the char needs to set a valid base outfit, if this happen you get the citizen basic outfit but in the change outfit window it says "no outfit" and of course it goes agains the race system itself.
that's why I need to remove the ghost outfit once I get the race outfits.
so at the end is outfits.xml file sets the ghost outfit
 
I am going to guess its because its the only base outfit enabled by default but that's probably wrong.
Post automatically merged:

Its possible you need to add the new outfit first.

Lua:
local storage = 40020

local outfitMale = 111
local outfitFemale = 111

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then return true end
    
    if player:getStorageValue(storage) == -1 then
        player:addOutfit(player:getSex() == 0 and outfitFemale or outfitMale)
        player:removeOutfit(319)
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'There is nothing else.')
    end
    return true
end
 
It's printing There is nothing else because you have propably storage above -1, simple. Just for a test, try this;

Lua:
local storage = 40020

function onStepIn(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if not player then
        return true
    end
    
    player:setStorageValue(storage, -1)
    if player:getStorageValue(storage) == -1 then
        player:removeOutfit(319)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Removed outfit ID: 319')
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'There is nothing else.')
    end
    return true
end
 
Just one thing, why this storage? Or is it something that the OP wants?
I believe it will work for him.

Lua:
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    if player:getSex() == PLAYERSEX_FEMALE then
        player:setOutfit(905)
    else
        player:setOutfit(906)
    end
    player:removeOutfit(319)
    return true
end
 
Just one thing, why this storage? Or is it something that the OP wants?
I believe it will work for him.

Lua:
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    if player:getSex() == PLAYERSEX_FEMALE then
        player:setOutfit(905)
    else
        player:setOutfit(906)
    end
    player:removeOutfit(319)
    return true
end
I don't know, didn't read whole post just rewritted a script that someone made for him to make it work ;p
 
It's printing There is nothing else because you have propably storage above -1, simple. Just for a test, try this;

Lua:
local storage = 40020

function onStepIn(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if not player then
        return true
    end
  
    player:setStorageValue(storage, -1)
    if player:getStorageValue(storage) == -1 then
        player:removeOutfit(319)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'Removed outfit ID: 319')
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'There is nothing else.')
    end
    return true
end
thanks for your help!
I did the test, now is printing: Removed outfit ID: 319 but the outfit still there, no errors in console
Post automatically merged:

Just one thing, why this storage? Or is it something that the OP wants?
I believe it will work for him.

Lua:
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    if player:getSex() == PLAYERSEX_FEMALE then
        player:setOutfit(905)
    else
        player:setOutfit(906)
    end
    player:removeOutfit(319)
    return true
end

thank you very much for trying to help me!
I tested it and I'm getting this error in console:

Lua:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/remove_outfit.lua:onStepIn
attempt to index a number value
stack traceback:
        [C]: at 0x7ff659d22e20
        [C]: in function 'setOutfit'
        data/movements/scripts/remove_outfit.lua:8: in function <data/movements/scripts/remove_outfit.lua:1>
Post automatically merged:

Didn't really read through the whole thread, but.. Are you sure you are using tfs 1.2 and not 0.3.6 or 0.4?
it is tfs 1.2 100%
 
Last edited:
Did you try this?

Lua:
local outfitMale = 128
local outfitFemale = 136

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then return true end
    
    player:addOutfit(player:getSex() == 0 and outfitFemale or outfitMale)
    player:removeOutfit(319)
    return true
end
 
Did you try this?

Lua:
local outfitMale = 128
local outfitFemale = 136

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then return true end
 
    player:addOutfit(player:getSex() == 0 and outfitFemale or outfitMale)
    player:removeOutfit(319)
    return true
end
more one liners pls, we can still see the code
try maybe:
Lua:
local outfitMale = 128 local outfitFemale = 136 function onStepIn(creature, item, position, fromPosition) local player = creature:getPlayer() if not player then return true end player:addOutfit(player:getSex() == 0 and outfitFemale or outfitMale) player:removeOutfit(319) return true end
Post automatically merged:

@Udun if you didn't add the outfit with code, you cant remove it with code.
 
Did you try this?

Lua:
local outfitMale = 128
local outfitFemale = 136

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then return true end
   
    player:addOutfit(player:getSex() == 0 and outfitFemale or outfitMale)
    player:removeOutfit(319)
    return true
end
I just did it now, it had a strange effect.
Caused a weird effect cause the citizen outfits are locked and when I step in the char gets the female citizen outfit, but 319 still there, and also I have the vocation outfits (that's ok)
no errors in console
I'm going to try with the custom outfits instead citizen
 
thank you very much for trying to help me!
I tested it and I'm getting this error in console:
Lua:
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerOutfit = player:getOutfit()
    playerOutfit.lookAddons = 0
    
    if player:getSex() == PLAYERSEX_FEMALE then
        playerOutfit.lookType = 905
    else
        playerOutfit.lookType = 906
    end

    player:setOutfit(playerOutfit)
    player:removeOutfit(319)
    return true
end
 
Solution
I will repeat myself again, you can't remove unlocked outfit. If you want to remove outfit, switch unlocked to no and add it via code on login.

Unlocked outfit will be always there on your character, doesn't matter what you call.
 
I will repeat myself again, you can't remove unlocked outfit. If you want to remove outfit, switch unlocked to no and add it via code on login.

Unlocked outfit will be always there on your character, doesn't matter what you call.

Lua:
function onStepIn(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if not player then
        return true
    end

    local playerOutfit = player:getOutfit()
    playerOutfit.lookAddons = 0

    if player:getSex() == PLAYERSEX_FEMALE then
        playerOutfit.lookType = 905
    else
        playerOutfit.lookType = 906
    end

    player:setOutfit(playerOutfit)
    player:removeOutfit(319)
    return true
end
I will repeat myself again, you can't remove unlocked outfit. If you want to remove outfit, switch unlocked to no and add it via code on login.

Unlocked outfit will be always there on your character, doesn't matter what you call.
omg finally I GET IT! THANK YOU VERY MUCH!!!!
SO!
@aqubjukr your script did it! Its working, change the outfit and revmoved the ghost.

So I'ill explain how I did it:

In the sample char on database I was using the female custom outfit 905 of my race and in the server on outfit.xml the ghost outfit was the only unlocked, that's why wasn't "added" by code
So in the databse sample I changed the female outfit for the ghost outfit and locked in outfits.xml
Now when the char enter for first time in the game it gain by creature script the 2 outfits (race and ghost) then I got the ghost by code
THEN
the aqubjukr script worked.

Now I'm getting a strange effect or bug, Idk really why this happend but when I choose a FEMALE it appears by default with citizen outfit and says "no outfit" in window, only the MALE chars are getting the ghost outfit by default of the sample char (it also says not outfit) but well, it's not such a terrible problem, I think I can managed somehow to make it intuitive for female players with voc doors and the sqm just behind the door.
SO! Thank you very much all who tryed to help me!

I'm thinking on release this system once is fully operative and tested cause I know there are lot of ppl trying to implement a race system without source editing
:) :)
special thanks to:
@M0ustafa @Nekiro @aqubjukr @Niebieski @Itutorial you all rulez
 
Last edited:
Back
Top