local config = {
saveitem = 2143, -- item id to save
savestorage = 2345, -- save storage
saveex = 30, -- exhausted after save in secods
loaditem = 2144, -- item id to load
loadstorage = 5432, -- load storage
loadex = 30 -- exhasted after load in seconds
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == config.loaditem then
if getPlayerStorageValue(cid, config.loadstorage) > os.time() then
return doPlayerSendTextMessage(cid, 19, "You can use this command only all "..config.loadex.." seconds.")
end
local result = db.getResult("SELECT `outfit` FROM `players` WHERE `name` = '"..getCreatureName(cid).."';")
if result:getID() == -1 then
return true
end
saved_outfit = string.explode(result:getDataString("outfit"), "-")
result:free()
local outfit = {
lookType = saved_outfit[1],
lookHead = saved_outfit[2],
lookBody = saved_outfit[3],
lookLegs = saved_outfit[4],
lookFeet = saved_outfit[5],
lookAddons = saved_outfit[6]
}
setPlayerStorageValue(cid, config.loadstorage, os.time() + config.loadex)
if outfit.lookType == 0 then
return doPlayerSendTextMessage(cid, 19, "Use "..getItemNameById(config.saveitem).." to save an outfit.")
end
doCreatureChangeOutfit(cid, outfit)
doPlayerSendTextMessage(cid, 19, "Outfit loaded.")
elseif item.itemid == config.saveitem then
if getPlayerStorageValue(cid, config.savestorage) > os.time() then
return doPlayerSendTextMessage(cid, 19, "You can use this command only all "..config.saveex.." seconds.")
end
local outfit = getCreatureOutfit(cid)
setPlayerStorageValue(cid, config.savestorage, os.time() + config.saveex)
db.executeQuery("UPDATE `players` SET `outfit` = '"..outfit.lookType.."-"..outfit.lookHead.."-"..outfit.lookBody.."-"..outfit.lookLegs.."-"..outfit.lookFeet.."-"..outfit.lookAddons.."' WHERE `name` = '"..getCreatureName(cid).."';")
doPlayerSendTextMessage(cid, 19, "Outfit saved, use "..getItemNameById(config.loaditem).." to load it.")
end
return true
end