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

C++ !save looktype

Fifflaren

Art of Conquest
Joined
Dec 11, 2018
Messages
154
Solutions
1
Reaction score
50
Im looking for a script that will save my looktype and !load looktype so why do I want this, I have a outfit doll that gives you a random looktype when clicked but the outfit you get isnt saved it gets removed when leaving the server, would be really nice if I could have like !save looktype so you could load and save etc :D thanks in advance <3
 
Solution
Perhaps you need to save and load the outfit when you need it.
per example: !outfit save
Then you change your outfit and colors, but it turns out that you do not like me and you want to have the outfit that you kept.
then use the command !outfit load

Talkactions.xml
Code:
    <!-- !outfit save | !outfit load -->
    <talkaction words="!outfit" event="script" value="outfitloadsave.lua"/>

outfitloadsave.lua
Code:
local storageOutfitSave = 666777
function doPlayerLoadOutfit(cid)
    local loadData = tostring(getCreatureStorage(cid, storageOutfitSave)) or "false"
    local outfit = loadstring("return " .. loadData)()
    return type(outfit) == "table" and doCreatureChangeOutfit(cid, outfit)
end
function doPlayerSaveOutfit(cid)...
Lua:
local outfits = {
    {549, 14112, "fdemonhunter", 2157, 1, "golden nugget"}, -- {outfit_id, storage, "outfit_name", itemid, count, "item_name"}
    {550, 14113, "fwarrior", 2157, 1, "golden nugget"},
    {551, 14114, "fbarbarian", 2157, 1, "golden nugget"},
    {562, 14144, "fassassin", 2157, 5, "golden nugget"},
    {563, 14146, "noblewoman", 2160, 1, "crystal coins"},
    {564, 14147, "fwizard", 2157, 10, "golden nugget"},
    {565, 14148, "fsummonerl",2157, 10, "golden nugget"},
    {552, 14115, "mwizard", 2157, 1, "golden nugget"},
    {553, 14116, "mdruid", 2157, 1, "golden nugget"},
    {554, 14117, "mpirate", 2157, 1, "golden nugget"},
    {555, 14119, "mwarrior", 2157, 1, "golden nugget"},
    {556, 14120, "mjester", 2157, 10, "golden nugget"},
    {557, 14121, "msummoner", 2157, 10, "golden nugget"},
    {546, 14131, "massassin", 2157, 20, "golden nugget"},
    {547, 14132, "magician", 2157, 1, "golden nugget"},
    {548, 14133, "mage", 2157, 100, "golden nugget"},
    {558, 14140, "mcitizen", 2157, 5, "golden nugget"},
    {559, 14141, "mshaman", 2157, 5, "golden nugget"},
    {561, 14142, "mnightmare", 2157, 5, "golden nugget"},
    {560, 14145, "mbarbarian", 2157, 5, "golden nugget"},
    {144, 14151, "elf", 2157, 100, "golden nugget"},
    {160, 14152, "dwarf", 2157, 100, "golden nugget"}
    
    
}
local vip_item_required_to_unlock_any_outfit_instead_of_regular_item = {"outfit doll", 5811}

local function changeOutfit(cid, new_outfit)
    local outfit = getCreatureOutfit(cid)
    tmp = outfit
    tmp.lookType = new_outfit
    tmp.lookHead = outfit.lookHead
    tmp.lookLegs = outfit.lookLegs
    tmp.lookBody = outfit.lookBody
    tmp.lookFeet = outfit.lookFeet
    tmp.lookAddons = outfit.lookAddons
    doCreatureChangeOutfit(cid, tmp)
    return true
end

function onSay(cid, words, param, channel)
    param = param:lower()
    if param == '' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Use '!outfit info' for a list of available commands.")
        return true
    end
    
    if param == 'info' then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Available commands..\n-> Use '!outfit change' to change to a random outfit.\n-> Use '!outfit outfit_name' to swap to a specific outfit. \n-> -> Example '!outfit demonhunter'\n-> Use '!outfit list' to show a list of all outfits you own.\n-> Use '!outfit all' to show a list of all outfits available.\n-> Use '!outfit unlock, outfit_name' in order to unlock an outfit.\n-> There is always an item required to unlock an outfit.\n-> If you don't have the item, the system will tell you what item you are missing.")
        return true
    end
    
    if param == 'change' then
        local random_outfits = {}
        for i = 1, #outfits do
            if getPlayerStorageValue(cid, outfits[i][2]) == 1 then
                table.insert(random_outfits, i)
            end
        end
        if #random_outfits < 1 then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you don't own any outfits to change into.")
            return true
        end
        local rand = math.random(#random_outfits)
        changeOutfit(cid, outfits[random_outfits[rand]][1])
        return true
    end
    
    if param == 'list' then
        local text = ""
        for i = 1, #outfits do
            if getPlayerStorageValue(cid, outfits[i][2]) == 1 then
                if text ~= "" then
                    text = text .. ", "
                end
                text = text .. "".. outfits[i][3] .. ""
            end
        end
        if text == "" then
            text = "none"
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Outfits you own: " .. text .. ".")
        return true
    end
    
    if param == 'all' then
        local text = ""
        for i = 1, #outfits do
            if text ~= "" then
                text = text .. ", "
            end
            text = text .. "".. outfits[i][3] .. ""
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "List of all outfits: " .. text .. ".")
        return true
    end
    
    for i = 1, #outfits do
        if outfits[i][3] == param then
            if getPlayerStorageValue(cid, outfits[i][2]) == 1 then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Outfit swapped to " .. param .. ".")
                changeOutfit(cid, outfits[i][1])
            else
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Outfit not unlocked. say !outfit unlock,NAME example !outfit unlock,mwizard Requires " .. outfits[i][5] .. " " .. outfits[i][6] .. ", or 1 " .. vip_item_required_to_unlock_any_outfit_instead_of_regular_item[1] .. ".")
            end
            return true
        end
    end
    
    local t = string.explode(param, ",")
    if t[1] == 'unlock' then
        for i = 1, #outfits do
            if outfits[i][3] == t[2] then
                if getPlayerStorageValue(cid, outfits[i][2]) ~= 1 then
                    if getPlayerItemCount(cid, outfits[i][4]) >= outfits[i][5] or getPlayerItemCount(cid, vip_item_required_to_unlock_any_outfit_instead_of_regular_item[2]) >= 1 then
                        if getPlayerItemCount(cid, outfits[i][4]) >= outfits[i][5] then
                            doPlayerRemoveItem(cid, outfits[i][4], outfits[i][5])
                        else
                            doPlayerRemoveItem(cid, vip_item_required_to_unlock_any_outfit_instead_of_regular_item[2], 1)
                        end
                        setPlayerStorageValue(cid, outfits[i][2], 1)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Outfit " .. t[2] .. " unlocked!")
                        changeOutfit(cid, outfits[i][1])
                    else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You require " .. outfits[i][5] .. " " .. outfits[i][6] .. " or 1 " .. vip_item_required_to_unlock_any_outfit_instead_of_regular_item[1] .. " to unlock this outfit.")
                    end
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Outfit already unlocked.")
                end
                return true
            end
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Outfit ' " .. t[2] .. " ' doesn't exist. Please use '!outfit unlock, outfit_name' to unlock an outfit. If you are unsure of the outfit's spelling use '!outfit all' to see all outfits available.")
        return true
    end
    
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Unknown command used. Use '!outfit info' for a list of available commands.")
    return true
end

this is code @Xikini wrote for me it works via talkaction but maybe you can see how he attaches outfits anyways when players logout the outfits stay on them with this script.
 
I'm quite proud of that local
"vip_item_required_to_unlock_any_outfit_instead_of_regular_item"
It's very descriptive.
Yeah, then there is that boring outfits one... What a wasted opportunity, table_with_required_item_to_unlock_an_outfit.
 
Ehmm Im really not catching on I cant get it to work :I
and would it be possible to add looktypes as orc etc.
 
orc yes just change the numbers in the table beside outfit names :) from monsters files

it works simple
/outfit info
/outfit all
/outfit unlock,mage
:) and then to change to unlocked outfits /outfit mage
{ORCOUTFITID, 14113, "orc", 2157, 1, "golden nugget"},
u can either change gold nugget to something or add all storage ids to player on login first time :)
 
orc yes just change the numbers in the table beside outfit names :) from monsters files

it works simple
/outfit info
/outfit all
/outfit unlock,mage
:) and then to change to unlocked outfits /outfit mage
{ORCOUTFITID, 14113, "orc", 2157, 1, "golden nugget"},
u can either change gold nugget to something or add all storage ids to player on login first time :)
Ohh ye the orc thing was kinda obv XD thanks anyways but I cant get the /outfit info etc to work :I what should I add in .xml for it to work?
 
nevermind I found it I was just stupid :p thanks guys <3 all love to you all
i will leave solution for others
<talkaction words="/outfit" event="script" value="outfits.lua"/>
if u can change thread name to custom outfits for player it might help people searching for particular thing :)
 
i will leave solution for others
<talkaction words="/outfit" event="script" value="outfits.lua"/>
if u can change thread name to custom outfits for player it might help people searching for particular thing :)
Well I dont know how to change the thread name :(
 
Perhaps you need to save and load the outfit when you need it.
per example: !outfit save
Then you change your outfit and colors, but it turns out that you do not like me and you want to have the outfit that you kept.
then use the command !outfit load

Talkactions.xml
Code:
    <!-- !outfit save | !outfit load -->
    <talkaction words="!outfit" event="script" value="outfitloadsave.lua"/>

outfitloadsave.lua
Code:
local storageOutfitSave = 666777
function doPlayerLoadOutfit(cid)
    local loadData = tostring(getCreatureStorage(cid, storageOutfitSave)) or "false"
    local outfit = loadstring("return " .. loadData)()
    return type(outfit) == "table" and doCreatureChangeOutfit(cid, outfit)
end
function doPlayerSaveOutfit(cid)
    local saveData = "{"
    for key, value in pairs(getCreatureOutfit(cid)) do
        saveData = string.format("%s%s=%u,", saveData, key, value)
    end
    return doCreatureSetStorage(cid, storageOutfitSave, saveData .. "}")
end
function onSay(cid, words, param, channel)
    if param == "save" then
        doPlayerSaveOutfit(cid)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_YELLOW)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have saved the outfit successfully.")
    elseif param == "load" then
        if doPlayerLoadOutfit(cid) then
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_BLUE)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have loaded the outfit successfully.")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have any outfit stored.")
        end
    end
    return true
end
 
Last edited:
Solution
Perhaps you need to save and load the outfit when you need it.
per example: !outfit save
Then you change your outfit and colors, but it turns out that you do not like me and you want to have the outfit that you kept.
then use the command !outfit load

Talkactions.xml
Code:
    <!-- !outfit save | !outfit load -->
    <talkaction words="!outfit" event="script" value="outfitloadsave.lua"/>

outfitloadsave.lua
Code:
local storageOutfitSave = 666777
function doPlayerLoadOutfit(cid)
    local loadData = tostring(getCreatureStorage(cid, storageOutfitSave)) or "false"
    local outfit = loadstring("return " .. loadData)()
    return type(outfit) == "table" and doCreatureChangeOutfit(cid, outfit)
end
function doPlayerSaveOutfit(cid)
    local saveData = "{"
    for key, value in pairs(getCreatureOutfit(cid)) do
        saveData = string.format("%s%s=%u,", saveData, key, value)
    end
    return doCreatureSetStorage(cid, storageOutfitSave, saveData .. "}")
end
function onSay(cid, words, param, channel)
    if param == "save" then
        doPlayerSaveOutfit(cid)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_YELLOW)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have saved the outfit successfully.")
    elseif param == "load" then
        if doPlayerLoadOutfit(cid) then
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_BLUE)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have loaded the outfit successfully.")
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You do not have any outfit stored.")
        end
    end
    return true
end
does that work for outfits like ORC? cuz if it does I freaky love you <3
 
Back
Top