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

item that activates outfit

Ranzor

Pixel Art
Joined
Apr 7, 2016
Messages
68
Reaction score
28
Location
Germany
I need to create an item that when placed in the inventory it activates a new outfit to the player and when it is removed from the inventory the player returns his outfit from before

-The Forgotten Server 0.4
 
Last edited:
I need to create an item that when placed in the inventory it activates a new outfit to the player and when it is removed from the inventory the player returns his outfit from before

-The Forgotten Server 0.4

"Inventory" is a very vague term. It could be any of the body part slots, or it could be backpack. Maybe it's ammo slot? Who knows.
So you have to specify that when making such a request.

Also, when you say "activates an outfit", this is once again vague, because this could be interpreted as:
* Transforms player's outfit into something else
* Makes a new Outfit available to player in the Set Outfit window.

With that said, here are some codes:

Change player appearance when item is equipped and change back when de-equipped:
lua script:
Lua:
function onEquip(cid, item, slot, boolean)
    local outfitToTransformInto = 24
    local m = getCreatureOutfit(cid)
    local outfit = {lookType = outfitToTransformInto, lookHead = m.lookHead, lookAddons = m.lookAddons, lookLegs = m.lookLegs, lookBody = m.lookBody, lookFeet = m.lookFeet}
    doSetCreatureOutfit(cid, outfit, -1)
return true
end

function onDeEquip(cid, item, slot, boolean)
    doRemoveCondition(cid, CONDITION_OUTFIT)
return true
end

yJQLK2r.gif


Unlock new outfit in Set Outfit window while item is equipped:

In outfits.xml, where your outfit's ID is, add quest="somestorage", where somestorage is a storage key that has to be set to value "1" in order for this outfit to be wearable.
Code:
    <outfit id="12" quest="29012">
        <list gender="0" lookType="155" name="Pirate"/>
        <list gender="1" lookType="151" name="Pirate"/>
    </outfit>

Script that will add this storage to player/remove it from him upon equip/deequip:
Lua:
function onEquip(cid, item, slot, boolean)
    setPlayerStorageValue(cid, 29012, 1)
return true
end

function onDeEquip(cid, item, slot, boolean)
    setPlayerStorageValue(cid, 29012, -1)
return true
end

For both codes you will need a movements.xml to link the script to some item ID:
Code:
    <moveevent type="Equip" itemid="2129" slot="neck" event="script" value="costumeAmulet.lua"/>
    <moveevent type="DeEquip" itemid="2129" slot="neck" event="script" value="costumeAmulet.lua"/>
 
"Inventory" is a very vague term. It could be any of the body part slots, or it could be backpack. Maybe it's ammo slot? Who knows.
So you have to specify that when making such a request.

Also, when you say "activates an outfit", this is once again vague, because this could be interpreted as:
* Transforms player's outfit into something else
* Makes a new Outfit available to player in the Set Outfit window.

With that said, here are some codes:

Change player appearance when item is equipped and change back when de-equipped:
lua script:
Lua:
function onEquip(cid, item, slot, boolean)
    local outfitToTransformInto = 24
    local m = getCreatureOutfit(cid)
    local outfit = {lookType = outfitToTransformInto, lookHead = m.lookHead, lookAddons = m.lookAddons, lookLegs = m.lookLegs, lookBody = m.lookBody, lookFeet = m.lookFeet}
    doSetCreatureOutfit(cid, outfit, -1)
return true
end

function onDeEquip(cid, item, slot, boolean)
    doRemoveCondition(cid, CONDITION_OUTFIT)
return true
end

yJQLK2r.gif


Unlock new outfit in Set Outfit window while item is equipped:

In outfits.xml, where your outfit's ID is, add quest="somestorage", where somestorage is a storage key that has to be set to value "1" in order for this outfit to be wearable.
Code:
    <outfit id="12" quest="29012">
        <list gender="0" lookType="155" name="Pirate"/>
        <list gender="1" lookType="151" name="Pirate"/>
    </outfit>

Script that will add this storage to player/remove it from him upon equip/deequip:
Lua:
function onEquip(cid, item, slot, boolean)
    setPlayerStorageValue(cid, 29012, 1)
return true
end

function onDeEquip(cid, item, slot, boolean)
    setPlayerStorageValue(cid, 29012, -1)
return true
end

For both codes you will need a movements.xml to link the script to some item ID:
Code:
    <moveevent type="Equip" itemid="2129" slot="neck" event="script" value="costumeAmulet.lua"/>
    <moveevent type="DeEquip" itemid="2129" slot="neck" event="script" value="costumeAmulet.lua"/>
How could I do this with the addon?
example, when you place the item addon 1 appears
 
Back
Top