• 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
You can use player:removeOutfit() to remove player outfit.
having this error in console :(

Lua:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/warden_outfit1.lua:onStepIn
data/movements/scripts/warden_outfit1.lua:6: attempt to index global 'player' (a nil value)

this is the script:
Lua:
local storage = 40020

function onStepIn(cid, item, fromPosition, itemEx, toPosition)

   if(getPlayerStorageValue(cid, storage) == -1) then
   player:removeOutfit(319)
   else
     doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "There is nothing else.")
   end
   return true
end
 
Last edited:
Lua:
local storage = 40020
function onStepIn(creature, item, position, fromPosition)
   local player = creature:getPlayer()
    if not player then
        return true
    end
   if player:getStorageValue(storage) == -1 then
   player:removeOutfit(319)
   else
   player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'There is nothing else.')
   end
   return true
end
 
Last edited:
Lua:
local storage = 40020

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

   if (player:getStorageValue(storage) == -1) then
   player:removeOutfit(319)
   else
   player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'There is nothing else.')
   end
   return true
end
thanks for the answer @M0ustafa! Still not working ;/ this time no errors in console
I have additional details:
the outfit 319 is the only unlocked outfit by defect, when you entrer for fist tome and press ok in the color palete window I saw that the vocation outfits and 319 are "set" in the player, (now testing I also included the outfit 319 in the script of the vocation outfits to see it was there the setting problem but makes no difference)
maybe the storage part in the script is not necessary, could be that the problem?
 
Are you sure your player has this storage? 40020? Where or how he gets it?
omg the player didn't had the storage, just now I did a movement to gain the storage so now the char have it, but now I see this error in console of the remove outfit script when the char steps in:

Lua:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/remove_outfit_storage.lua:onStepIn
data/movements/scripts/remove_outfit_storage.lua:4: attempt to index global 'creature' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/movements/scripts/remove_outfit_storage.lua:4: in function <data/movements/scripts/remove_outfit_storage.lua:3>
 
omg the player didn't had the storage, just now I did a movement to gain the storage so now the char have it, but now I see this error in console of the remove outfit script when the char steps in:

Lua:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/remove_outfit_storage.lua:onStepIn
data/movements/scripts/remove_outfit_storage.lua:4: attempt to index global 'creature' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/movements/scripts/remove_outfit_storage.lua:4: in function <data/movements/scripts/remove_outfit_storage.lua:3>
Lua:
local storage = 40020

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

    if player:getStorageValue(storage) == -1 then
        player:removeOutfit(319)
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'There is nothing else.')
    end
    return true
end
 
Last edited:
I edited the script above should be working now or use Niebieski one.
 
I edited the script above should be working now or use Niebieski one.
Lua:
local storage = 40020

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

    if player:getStorageValue(storage) == -1 then
        player:removeOutfit(319)
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'There is nothing else.')
    end
    return true
end

still getting error:
Lua:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/remove_outfit_storage.lua:onStepIn
data/movements/scripts/remove_outfit_storage.lua:4: attempt to index global 'creature' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/movements/scripts/remove_outfit_storage.lua:4: in function <data/movements/scripts/remove_outfit_storage.lua:3>

I was thinking maybe the problem is on a lib / core function or something like that that I should add or modify?
 
I dont understand at all what you want

If someone pass a special ground with actionID the outfit should be removed? Thats all??
yes! that's all XD
removed and not able to use it by the char anymore.
Doesn't have to be with the storage id in fact. just remove the outfit automatically.
The thing is I need to have the outfit first or the other custom vocation outfits don't load proprely, once that's done I need to eliminate that outfit
thats all
Post automatically merged:

On both? Niebieski's and mine?
yes :U
in both, same error

EDIT:
I realize that Niebieski's doesn't show error, but don't remove the outfit
 
Last edited:
SO if hes as explain
Outfit = 319
and he pass the Tile
what outfit should he have after he passed the ground?
905 female / 906 male
EDIT:
it would be nice to change the outfit automatically but not 100% nessesary, if you read the the first post I was thinking only to open the change outfit color palete window when the script is executed and change there the outfit deleting the "old outfit" cache
 
Last edited:
still getting error:
Lua:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/remove_outfit_storage.lua:onStepIn
data/movements/scripts/remove_outfit_storage.lua:4: attempt to index global 'creature' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/movements/scripts/remove_outfit_storage.lua:4: in function <data/movements/scripts/remove_outfit_storage.lua:3>

I was thinking maybe the problem is on a lib / core function or something like that that I should add or modify?
No way you are getting an error with „creature” in my version as its not declared anywhere in my script, if you cant even copy a script properly I will not waste my time anymore.
 
No way you are getting an error with „creature” in my version as its not declared anywhere in my script, if you cant even copy a script properly I will not waste my time anymore.
@M0ustafa
@Niebieski

hey man you don't need to be rude.
I tested both script and didn't work.
the console error that I posted was from the M0ustafa script.
yours doesn't show error in console, in fact is executing cause i'm receiving the "there is nothing else" message but the outfit still there, so is not removing it, so doesn't work.
Have to understand I've doing lots of tests all day long tryng to make it work .
Thanks anyway
 
Last edited:
Try this, its a long shot it just does addons too but it might work.

Lua:
local storage = 40020

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

    if player:getStorageValue(storage) == -1 then
        player:removeOutfit(319)
        player:removeOutfit(319, 1)
        player:removeOutfit(319, 2)
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'There is nothing else.')
    end
    return true
end
 
Try this, its a long shot it just does addons too but it might work.

Lua:
local storage = 40020

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

    if player:getStorageValue(storage) == -1 then
        player:removeOutfit(319)
        player:removeOutfit(319, 1)
        player:removeOutfit(319, 2)
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'There is nothing else.')
    end
    return true
end
@Itutorial thank you very much for trying, still not working, I received the "There is nothing else". message but the outfit still there ;(

is this one btw:
319.png
 
Maybe cause 319 looktype isn't an outfit? Someone correct me if I'm wrong :D
Also, seems like script can't find storage; make sure storage is registered in your character.
 
Maybe cause 319 looktype isn't an outfit? Someone correct me if I'm wrong :D
I was thinking the same, but I don't know really the behaivor or the difference between a "char outfit" and "monster outfit/looktype"
In fact I was looking in object builder if there was some difference or key to change but I haven't discovered nothing yet
 
Back
Top