UP, o verdadeiro problema que descobri é que as vocations tem suas respectivas outfits normais, mas qndo a vocation é acima de 10 ela começa do 1...
Por exemplo: Vocation 1 = Sanji, sua outfit é 424
... até vocation 10 normal ..
a partir da vocation 11 começa meu problema...
Vocation 11 = Buggy, sua outfit era pra ser a 9, porém copia a do sanji(424)
O que me parece é que ele usa o ultimo número para "ler" a outfit... se fosse vocation 12 ele copiaria o 2 no caso.
No script tem uma função index, tentei mecher mas não cheguei em nada pois não sei direito como funcina mesmo lendo varias vezes.
Segue o script e agradeço qualquer ajuda!
--------------------------------------------------------------------------------
-- Se falso, gm fica com outfit de player normal, incluindo as transformacoes. Costumo desativar so pra testar as magias
ATIVAR_GM_OUTFIT_ON_LOGIN = not getConfigValue('SERVER_MODO_DE_TESTES')
--------------------------------------------------------------------------------
CONST_GAMEMASTER_OUTFIT = 57 -- 220 (antigo
CONST_OUTFIT_SANJI = 424
CONST_OUTFIT_SANJI_ADDON = 425
CONST_OUTFIT_SANJI_FIRE = 485
CONST_OUTFIT_SANJI_FIRE_ADDON = 486
CONST_OUTFIT_LUFFY_KID = 65
CONST_OUTFIT_LUFFY_KID_ROSA = 65
CONST_OUTFIT_LUFFY = 350
CONST_OUTFIT_LUFFY_ROSA = 372
CONST_OUTFIT_LUFFY_GORDO = 270
CONST_OUTFIT_LUFFY_GORDO_ROSA = 271
CONST_OUTFIT_LUFFY_2 = 420
CONST_OUTFIT_LUFFY_2_ROSA = 60
CONST_OUTFIT_LUFFY_2_GORDO = 61
CONST_OUTFIT_LUFFY_2_GORDO_ROSA = 62
CONST_OUTFIT_SMOKER = 8
CONST_OUTFIT_SMOKER_SMOKE = 92
CONST_OUTFIT_SMOKER_2 = 96
CONST_OUTFIT_SMOKER_2_SMOKE = 94
OUTFIT_LIST = {
[1] = {424, 425}, -- sanji
[2] = {350, 420}, -- luffy
[3] = {422, 423}, -- zoro
[4] = {362, 428}, -- ace
[5] = {339, 427}, -- usopp
[6] = {341, 421}, -- nami
[7] = {323, 473, 474}, -- chopper
[8] = {8, 96}, -- smoker
[11] = {400}, --buggy
}
OUTFIT_PRICE = {
[1] = {15},
[2] = {15},
[3] = {15},
[4] = {15},
[5] = {15},
[6] = {15},
[7] = {5},
[8] = {15},
[11] = {15},
}
--------------------- Gerar automatico tabela do que voc é determinado outfit
OUTFIT_IS_ALLOWED = {} -- [outfit_id] = voc_base,
for voc, outfits in pairs(OUTFIT_LIST) do
for _, outfit_id in pairs(outfits) do
OUTFIT_IS_ALLOWED[outfit_id] = voc
end
end
---------------------
OUTFIT_PURCHASE_MANAGER = {
LIST = function (cid)
local base_voc = getPlayerBaseVocation(cid)
--if base_voc == 7 then -- chopper
-- local transf = getPlayerStorageValue(cid, STORAGE_CHOPPER_TRANSFORMATION)
-- return (OUTFIT_LIST[base_voc] or {})[transf] or {}
--end
return OUTFIT_LIST[base_voc] or {}
end,
GET_PRICE = function (cid, index)
return OUTFIT_PRICE[getPlayerBaseVocation(cid)][index - 1]
end,
PURCHASE = function (cid, index)
local price = OUTFIT_PRICE[getPlayerBaseVocation(cid)][index - 1]
if not price then
doPlayerSendCancel(cid, "[ERROR] INVALID OUTFIT")
return false
end
return doPlayerRemoveItem(cid, ITEM_VIP_COIN, price)
end,
ADD = function (cid, index) -- index da outfit_list
if index == 1 then
return true
end
if index < 1 or index > 10 then
return false
end
setPlayerStorageValue(cid, STORAGE_PURCHASE_OUTFIT_BASE + index, 1)
end,
HAS = function (cid, index)
if index < 1 or index > 10 then
return false
end
return index == 1 and true or getPlayerStorageValue(cid, STORAGE_PURCHASE_OUTFIT_BASE + index) == 1
end,
HAS_OUTFIT = function (cid, id_outfit)
local outfits = OUTFIT_LIST[getPlayerBaseVocation(cid)] or {}
for index, outfit in pairs(outfits) do
if id_outfit == outfit and OUTFIT_PURCHASE_MANAGER.HAS(cid, index) then
return true
end
end
return false
end,
}
TABLE_VOCATION_OUTFIT = {
[1] = 424, -- sanji
[2] = 350, -- luffy
[3] = 422, -- zoro
[4] = 362, -- ace
[5] = 339, -- usopp
[6] = 341, -- nami
[7] = 323, -- chopper
[8] = 8, -- smoker
[11] = 400 -- buggy
}
local TABLE_LUFFY_NORMAL_OUTFIT = -- convert normal to pink
{
[CONST_OUTFIT_LUFFY] = CONST_OUTFIT_LUFFY_ROSA,
[CONST_OUTFIT_LUFFY_KID] = CONST_OUTFIT_LUFFY_KID_ROSA,
[CONST_OUTFIT_LUFFY_GORDO] = CONST_OUTFIT_LUFFY_GORDO_ROSA,
}
local TABLE_LUFFY_PINK_OUTFIT = -- convert pink to normal
{
[CONST_OUTFIT_LUFFY_ROSA] = CONST_OUTFIT_LUFFY,
[CONST_OUTFIT_LUFFY_KID_ROSA] = CONST_OUTFIT_LUFFY_KID,
[CONST_OUTFIT_LUFFY_GORDO_ROSA] = CONST_OUTFIT_LUFFY_GORDO,
}
--------------------------------------------------------------------------------
local TABLE_TRANSFORMATION_OUTFITS = {
[CONST_OUTFIT_LUFFY_ROSA] = {
[CONST_OUTFIT_LUFFY] = CONST_OUTFIT_LUFFY_ROSA,
[CONST_OUTFIT_LUFFY_GORDO] = CONST_OUTFIT_LUFFY_GORDO_ROSA,
[CONST_OUTFIT_LUFFY_2] = CONST_OUTFIT_LUFFY_2_ROSA,
[CONST_OUTFIT_LUFFY_2_GORDO] = CONST_OUTFIT_LUFFY_2_GORDO_ROSA,
},
[CONST_OUTFIT_LUFFY] = {
[CONST_OUTFIT_LUFFY_ROSA] = CONST_OUTFIT_LUFFY,
[CONST_OUTFIT_LUFFY_GORDO_ROSA] = CONST_OUTFIT_LUFFY_GORDO,
[CONST_OUTFIT_LUFFY_2_ROSA] = CONST_OUTFIT_LUFFY_2,
[CONST_OUTFIT_LUFFY_2_GORDO_ROSA] = CONST_OUTFIT_LUFFY_2_GORDO,
},
[CONST_OUTFIT_LUFFY_GORDO] = {
[CONST_OUTFIT_LUFFY] = CONST_OUTFIT_LUFFY_GORDO,
[CONST_OUTFIT_LUFFY_ROSA] = CONST_OUTFIT_LUFFY_GORDO_ROSA,
[CONST_OUTFIT_LUFFY_2] = CONST_OUTFIT_LUFFY_2_GORDO,
[CONST_OUTFIT_LUFFY_2_ROSA] = CONST_OUTFIT_LUFFY_2_GORDO_ROSA,
},
[CONST_OUTFIT_LUFFY_2] = {
[CONST_OUTFIT_LUFFY] = CONST_OUTFIT_LUFFY_2,
[CONST_OUTFIT_LUFFY_ROSA] = CONST_OUTFIT_LUFFY_2_ROSA,
[CONST_OUTFIT_LUFFY_GORDO] = CONST_OUTFIT_LUFFY_2_GORDO,
[CONST_OUTFIT_LUFFY_GORDO_ROSA] = CONST_OUTFIT_LUFFY_2_GORDO_ROSA,
},
[CONST_OUTFIT_SMOKER_SMOKE] = {
[CONST_OUTFIT_SMOKER] = CONST_OUTFIT_SMOKER_SMOKE,
[CONST_OUTFIT_SMOKER_2] = CONST_OUTFIT_SMOKER_2_SMOKE,
},
[CONST_OUTFIT_SANJI_FIRE] = {
[CONST_OUTFIT_SANJI] = CONST_OUTFIT_SANJI_FIRE,
[CONST_OUTFIT_SANJI_ADDON] = CONST_OUTFIT_SANJI_FIRE_ADDON,
},
}
local OUTFIT_MANAGER_UIDS = {} -- [ [{id :: Int, time :: Int}] ]
local OUTFIT_MANAGER_EVENTS = {} -- [Int] -- salva os addevent
-- luffy
-- luffy rosa 30.000
-- luffy gordo 5.000
local function __private__update_outfit_manager(cid, remove)
if not isPlayer(cid) then
--print("NOT PLAYER KRA K K K")
return false
end
local outfits = OUTFIT_MANAGER_UIDS[cid] or {}
if #outfits == 0 and not remove then
--print("JA TA OK rsrsrsrs")
return true
end
-- Procurar o outfit temporario que acaba primeiro, e sera esse o tempo de addEvent
local time = nil
for index, outfit in pairs(outfits) do
if os.time() > outfit.time then
table.remove(OUTFIT_MANAGER_UIDS[cid], index)
--print("AGORA COM: " .. #OUTFIT_MANAGER_UIDS[cid])
if outfit.reset_on_end then
OUTFIT_MANAGER_UIDS[cid] = {}
doRemoveCondition(cid, CONDITION_OUTFIT)
setPlayerStorageValue(cid, STORAGE_IS_IN_TRANSFORMATION, -1)
if isChopper(cid) then
setPlayerStorageValue(cid, STORAGE_CHOPPER_TRANSFORMATION, 1)
local DLL = DLLClass:new(cid)
:addTransformation(1)
:send()
end
--print(">>REMOVI K K K K K END")
return true
end
else
if not time or outfit.time - os.time() < time then
time = outfit.time - os.time()
end
end
end
-- Reatualiza o outfit
local last_outfit = getCreatureDefaultOutfit(cid).lookType
for index, outfit in pairs(outfits) do
last_outfit = (TABLE_TRANSFORMATION_OUTFITS[outfit.id] or {})[last_outfit] or outfit.id
end
doSetCreatureOutfit(cid, {lookType = last_outfit}, -1)
if time then
--print("DAKI A " .. time)
addEvent(__private__update_outfit_manager, time, cid)
else
--print("FLW OTARIOS")
doRemoveCondition(cid, CONDITION_OUTFIT)
setPlayerStorageValue(cid, STORAGE_IS_IN_TRANSFORMATION, -1)
OUTFIT_MANAGER_EVENTS[cid] = nil
end
end
OUTFIT_MANAGER = {
get_last_outfit = function (cid)
local outfits = (OUTFIT_MANAGER_UIDS[cid] or {})
if #outfits > 0 then
return outfits[#outfits].id
else
return getCreatureOutfit(cid).lookType
end
end,
remove = function (cid, removed_looktype)
-- Remove
OUTFIT_MANAGER_UIDS[cid] = table.filter(OUTFIT_MANAGER_UIDS[cid] or {}, function (_, looktype) return looktype.id ~= removed_looktype end)
-- Parar algum evento caso exista e adicionar novamente
if OUTFIT_MANAGER_EVENTS[cid] then
stopEvent(OUTFIT_MANAGER_EVENTS[cid])
end
OUTFIT_MANAGER_EVENTS[cid] = addEvent(__private__update_outfit_manager, 0, cid, true)
end,
change = function (cid, id_outfit, time, is_real, is_chopper_transformation) -- is_real somente para os outfits que trocam pelo `Set Outfit`
if not id_outfit then
return print('[ERROR] OUTFIT_MANAGER.change ~ Invalid id_outfit') and false
elseif not time then
return print('[ERROR] OUTFIT_MANAGER.change ~ time must be a non nil value') and false
end
if is_real then
doCreatureChangeOutfit(cid, {lookType = id_outfit})
else
setPlayerStorageValue(cid, STORAGE_IS_IN_TRANSFORMATION, 1)
if is_chopper_transformation then
OUTFIT_MANAGER_UIDS[cid] = {}
else
OUTFIT_MANAGER_UIDS[cid] = OUTFIT_MANAGER_UIDS[cid] or {}
end
--print("AGORA: " .. os.time())
local transformation_table = {id = id_outfit, time = os.time() + time - 1, reset_on_end = is_chopper_transformation}
local found = table.filterFind(OUTFIT_MANAGER_UIDS[cid], function (_, value) return value.id == id_outfit end)
if found then
OUTFIT_MANAGER_UIDS[cid][found.index] = transformation_table
else
table.insert(OUTFIT_MANAGER_UIDS[cid], transformation_table)
end
end
-- Parar algum evento caso exista e adicionar novamente
if OUTFIT_MANAGER_EVENTS[cid] then
stopEvent(OUTFIT_MANAGER_EVENTS[cid])
end
OUTFIT_MANAGER_EVENTS[cid] = addEvent(__private__update_outfit_manager, 0, cid)
end,
}