• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved setPlayerStorageValue issue

Geekout1245

New Member
Joined
Feb 21, 2019
Messages
1
Reaction score
0
I want 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 but outfit what i want to set saving in storage. TFS 0.3.6

Code:
function onEquip(cid, item, slot)
        local storage = 16007
        setPlayerStorageValue(cid, 16010, getCreatureOutfit(cid).lookType)
        
        
        if getPlayerVocation(cid) == 18 or getPlayerVocation(cid) == 19 or getPlayerVocation(cid) == 20 or getPlayerVocation(cid) == 21 or getPlayerVocation(cid) == 22 then
        local outfit = {lookType = 701, lookHead = 0 , lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}
                doSetCreatureOutfit(cid, outfit, -1)
                end
                if getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid == 8819 then
                setPlayerStorageValue(cid, 16011, 1)
                end
        return true
end



function onDeEquip(cid, item, slot)
        local storage = 16007
        if getPlayerStorageValue(cid, 16011) == 1 then
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
            local outfit = {lookType = getPlayerStorageValue(cid, 16010) , lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = 0}
            doSetCreatureOutfit(cid, outfit, -1)
            setPlayerStorageValue(cid, 16011, 0)

end
end
 
Solution
Why would you ask if the storage value equals 1 when you take off the item if the outfit you are wearing does not equal 1 when you store it. I doubt there is a looktype that has a value of 1.

The script you posted is conflicting its using 2 storages to set when the item is equipped and 1 setting when its deequipped. It just looks like you copied and pasted this from another script and crossed your fingers hoping it would work hehe.
LUA:
function isInArray(a, f)
    if type(a) == 'table' then
        for k, v in pairs(a) do
            if v == f then
                return true
            end
        end  
    end
    return false
end

o = {
    outfitStorage = 16011,
    vocations = {18, 19, 20, 21, 22},
}

function onEquip(cid, item...
Why would you ask if the storage value equals 1 when you take off the item if the outfit you are wearing does not equal 1 when you store it. I doubt there is a looktype that has a value of 1.

The script you posted is conflicting its using 2 storages to set when the item is equipped and 1 setting when its deequipped. It just looks like you copied and pasted this from another script and crossed your fingers hoping it would work hehe.
LUA:
function isInArray(a, f)
    if type(a) == 'table' then
        for k, v in pairs(a) do
            if v == f then
                return true
            end
        end  
    end
    return false
end

o = {
    outfitStorage = 16011,
    vocations = {18, 19, 20, 21, 22},
}

function onEquip(cid, item, slot)
    local s = getPlayerSlotItem(cid, slot)
    if s then
        if s.itemid ~= item.itemid then
            return true
        end
        if isInArray(o.vocations, getPlayerVocation(cid)) then
            local outfit = {lookType = 701, lookHead = 0 , lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 0}
            setPlayerStorageValue(cid, o.outfitStorage, getCreatureOutfit(cid).lookType)
            doSetCreatureOutfit(cid, outfit, -1)
        end
    end
    return true
end

function onDeEquip(cid, item, slot)
    local look = getPlayerStorageValue(cid, o.outfitStorage)
    if look ~= -1 then
        doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
        local outfit = {lookType = look, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = 0}
        doSetCreatureOutfit(cid, outfit, -1)
        setPlayerStorageValue(cid, o.outfitStorage, -1)
    end
    return true
end
 
Last edited:
Solution
Back
Top