Lua doPlayerRemoveOutfitId - problem with

Tadelho

New Member
Joined
Aug 12, 2007
Messages
38
Best answers
1
Reaction score
2
Hello, there. Is there any restriction to use the function doPlayerRemoveOutfitId(cid, id, addon) to remove an outfit that was manually added before with doPlayerAddOutfitId(cid, id, addon)?

By the way: I'm using TFS 0.4

Let me explain:

Players in my server starts only with the outfit ID 1 available. With the following script I can remove the the OutfitID 1 and Add a new outfitID27, and it works perfectly: the outfitID 27 is added and the outfitID 1 is removed.

Lua:
function onStepIn(cid, item, position, fromPosition)
    if item.actionid == 7470 and getPlayerGroupId(cid) < 3 then
        doPlayerAddOutfitId(cid, 27, 0)
        doPlayerRemoveOutfitId(cid, 1, 0)
        setPlayerStorageValue(cid, 8431, 1)
    end
   return true
end
But later I'm trying to repeat this process with this script to remove the new outfitid 27 and substitute it by another new outfitID available (forcing the player to use this new outfit), but just the new outfit is added and the old outfit ID 27 (added in the first script) is not removed.

Lua:
function onUse(cid, item, frompos, item2, topos)

local outfit = getCreatureOutfit(cid)

if item.uid == 9500 and queststatus == 1 then
if outfit.lookType == 160 then
                        doPlayerAddOutfitId(cid, 18, 0)
                        doPlayerRemoveOutfitId(cid, 27, 0)
                        setPlayerStorageValue(cid,9500,2)
            else return true
            end   
else return true
end
return true
end
The new addition is working fine, but I want to make this outfitID 27 unavailable anymore, but I just cant. :(

Can anyone help me again?

UPDATE: I've tried to duplicate the command setting a storagevalue and repeating the command again in an "onLogin" function (properly registered in creaturescripts.xml), but it's still not working.

Lua:
function onLogin(cid)
    if getPlayerStorageValue(cid, 8432) == 1 then
        setPlayerStorageValue(cid, 8432, -1)
        doPlayerRemoveOutfitId(cid, 27, 0)
        doPlayerSendOutfitWindow(cid)
    end
return TRUE  
end
 
Last edited:

Apollos

Dude who does stuff
Joined
Apr 22, 2009
Messages
746
Best answers
110
Reaction score
493
Location
United States
Try this:

Lua:
function onUse(cid, item, frompos, item2, topos)
    local outfit = getCreatureOutfit(cid)
    if item.uid == 9500 and queststatus == 1 then
        if outfit.lookType == 160 then
            doPlayerAddOutfitId(cid, 18, 0)
            doPlayerRemoveOutfitId(cid, 27)
            setPlayerStorageValue(cid,9500,2)
        end   
    end
    return true
end
 

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,172
Best answers
174
Reaction score
2,235
You'll want to make sure they aren't wearing the outfit I'd assume.
I copy pasted this from a wedding outfit script
Lua:
local v = getCreatureOutfit(cid)
if isInArray({328, 329}, v.lookType) then
   v.lookType = getPlayerSex(cid) == 0 and 136 or 128
   doCreatureChangeOutfit(cid, v)
end
doPlayerRemoveOutfitId(cid, 34)
 
Last edited:
OP
T

Tadelho

New Member
Joined
Aug 12, 2007
Messages
38
Best answers
1
Reaction score
2
Try this:

Lua:
function onUse(cid, item, frompos, item2, topos)
    local outfit = getCreatureOutfit(cid)
    if item.uid == 9500 and queststatus == 1 then
        if outfit.lookType == 160 then
            doPlayerAddOutfitId(cid, 18, 0)
            doPlayerRemoveOutfitId(cid, 27)
            setPlayerStorageValue(cid,9500,2)
        end 
    end
    return true
end
It's not working yet, @Apollos :(

@Xikini , actually I want to eliminate even the possibility of player to see the outfitID 27 in that "change outfit window". It worked well to eliminate the first one, but this outfitd added later I can't remove. :(
 

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,172
Best answers
174
Reaction score
2,235
It's not working yet, @Apollos :(

@Xikini , actually I want to eliminate even the possibility of player to see the outfitID 27 in that "change outfit window". It worked well to eliminate the first one, but this outfitd added later I can't remove. :(
If you never want them to see the outfit, why add it at all?
My above post is in case the player is currently wearing the outfit.
 
OP
T

Tadelho

New Member
Joined
Aug 12, 2007
Messages
38
Best answers
1
Reaction score
2
If you never want them to see the outfit, why add it at all?
My above post is in case the player is currently wearing the outfit.
@Xikini
Well, it's just temporary, you know? The player starts the game without the outfitID 27, then I make him use it as a regular outfit as he starts a long quest. When he completes it, he gets a new outfit and losses the old one. In other words: at this momment he should get the outfitID 18 and don't be able to change to the outfitID 27 anymore. :p
 

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,172
Best answers
174
Reaction score
2,235
@Xikini
Well, it's just temporary, you know? The player starts the game without the outfitID 27, then I make him use it as a regular outfit as he starts a long quest. When he completes it, he gets a new outfit and losses the old one. In other words: at this momment he should get the outfitID 18 and don't be able to change to the outfitID 27 anymore. :p
Exactly the reason for my above post. lmao
-> If they are wearing the outfit to be removed, change their outfit to the default citizen outfit.
-> remove the outfit from player.
-> add a new outfit to player.
-> send outfit window.
 
OP
T

Tadelho

New Member
Joined
Aug 12, 2007
Messages
38
Best answers
1
Reaction score
2
Exactly the reason for my above post. lmao
-> If they are wearing the outfit to be removed, change their outfit to the default citizen outfit.
-> remove the outfit from player.
-> add a new outfit to player.
-> send outfit window.
@Xikini , it didn't work, unfortunately. The player still can access the outfitID27 in the outfit window.
 

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,172
Best answers
174
Reaction score
2,235
@Xikini , it didn't work, unfortunately. The player still can access the outfitID27 in the outfit window.
post your outfits.xml if the below script doesn't work.

Fully working on 0.3.7
Lua:
local config = {
   removeOutfitId = 1,
   newOutfitId = 2,
   newFemaleOutfit = 137,
   newMaleOutfit = 129
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
   doPlayerAddOutfitId(cid, config.newOutfitId, 0)
   local v = getCreatureOutfit(cid)
   v.lookType = getPlayerSex(cid) == 0 and config.newFemaleOutfit or config.newMaleOutfit
   doCreatureChangeOutfit(cid, v)
   doPlayerRemoveOutfitId(cid, config.removeOutfitId)
   return true
end
 
OP
T

Tadelho

New Member
Joined
Aug 12, 2007
Messages
38
Best answers
1
Reaction score
2
All my outfits in .xml follows exactly this same pattern:

Code:
    <outfit id="28" premium="yes" default="0">
        <list gender="0-1" lookType="146" name="Human" requirement="none" speed="6">
        </list>
    </outfit>
@Xikini
Only the "id", "lookType" and "name" are different, of course. I'm not sure how add/removeoutditID works exactly, but something says me that this "0" value for "default" is changed when I add a new outfit giving the player access to the outfit, right? And it was supposed to be "0" again when the outfit is removed, or maybe I'm wrong?
 

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,172
Best answers
174
Reaction score
2,235
All my outfits in .xml follows exactly this same pattern:

Code:
    <outfit id="28" premium="yes" default="0">
        <list gender="0-1" lookType="146" name="Human" requirement="none" speed="6">
        </list>
    </outfit>
@Xikini
Only the "id", "lookType" and "name" are different, of course. I'm not sure how add/removeoutditID works exactly, but something says me that this "0" value for "default" is changed when I add a new outfit giving the player access to the outfit, right? And it was supposed to be "0" again when the outfit is removed, or maybe I'm wrong?
That's what I believe the function does as well, but like you, I'm not entirely certain what it does exactly.

mine is nearly identical to yours.
Code:
<outfit id="1" premium="yes" default="0">
    <list gender="0" lookType="136" name="Citizen">   </list>
    <list gender="1" lookType="128" name="Citizen">   </list>
</outfit>
As for my previous posts script,
You can just make the new female/male outfit looktypes the same id, if you don't feel like changing the script.
If my script doesn't work, I have no further help for you at this point.
I don't know what the issue might be.
 
Top