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

Lua MonsterOutfit command

dewral

Veteran OT User
Joined
Dec 4, 2019
Messages
345
Solutions
10
Reaction score
365
Hello everyone!
Can someone give me a little hint how to make it work like
!outfit mummy
!outfit demon and etc.
I could just make it one by one but i wanna make it work with seperator and only 1 script xD

Lua:
local outfitsRefuse = {135, {161, 191}}
local storage = 997997
local value = 1

local function isInAltArray(array, value)
    for i = 1, #array do
        if type(array[i]) == 'table' then
            return (value < array[i][1] and value > array[i][2])
        elseif array[i] == value then
            return true
        end
    end
end

local function outfitSearch()
    local outfit = 65
    if not isInAltArray(outfitsRefuse, outfit) then
      return outfit
    end
    return outfitSearch()
end

function onSay(player, words, param)
    if player:getStorageValue(storage) ~= value then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have that command yet.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end
    player:setOutfit({lookType = outfitSearch()})
    player:getPosition():sendMagicEffect(CONST_ME_GROUNDSHAKER)
    return false
end
 
Solution
Lua:
local config = {
   outfits = {
      ["demon"] = 35,
      ["dark torturer"] = 234
   },
   storage = 1500
}

local availableOutfits = function()
   local ret = {}
   for name in pairs(config.outfits) do
      ret[#ret + 1] = name
   end
   return ret
end

function onSay(player, words, param)

   if player:getStorageValue(config.storage) ~= 1 then
      player:sendTextMessage(MESSAGE_INFO_DESCR, "You dont have this command yet.")
      player:getPosition():sendMagicEffect(CONST_ME_POFF)
      return false
   end

   param = param:gsub("%p", "")
   local outfit = config.outfits[param:lower()]

   if (#param == 0) then
      local outfits = availableOutfits()
      player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Available...
Lua:
local config = {
   outfits = {
      ["demon"] = 35,
      ["dark torturer"] = 234
   },
   storage = 1500
}

local availableOutfits = function()
   local ret = {}
   for name in pairs(config.outfits) do
      ret[#ret + 1] = name
   end
   return ret
end

function onSay(player, words, param)

   if player:getStorageValue(config.storage) ~= 1 then
      player:sendTextMessage(MESSAGE_INFO_DESCR, "You dont have this command yet.")
      player:getPosition():sendMagicEffect(CONST_ME_POFF)
      return false
   end

   param = param:gsub("%p", "")
   local outfit = config.outfits[param:lower()]

   if (#param == 0) then
      local outfits = availableOutfits()
      player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Available outfit"..(#outfits > 1 and "s" or "")..": "..table.concat(outfits, ", "))
      return false
   end     

   if not outfit then
      player:sendTextMessage(MESSAGE_INFO_DESCR, "This outfit does not exist.")
      player:getPosition():sendMagicEffect(CONST_ME_POFF)
      return false
   end

   if (outfit ~= player:getOutfit().lookType) then
      player:setOutfit({lookType = outfit})
   end
   player:getPosition():sendMagicEffect(CONST_ME_GROUNDSHAKER)
   return false
end
 
Solution
Lua:
local config = {
   outfits = {
      ["demon"] = 35,
      ["dark torturer"] = 234
   },
   storage = 1500
}

local availableOutfits = function()
   local ret = {}
   for name in pairs(config.outfits) do
      ret[#ret + 1] = name
   end
   return ret
end

function onSay(player, words, param)

   if player:getStorageValue(config.storage) ~= 1 then
      player:sendTextMessage(MESSAGE_INFO_DESCR, "You dont have this command yet.")
      player:getPosition():sendMagicEffect(CONST_ME_POFF)
      return false
   end

   param = param:gsub("%p", "")
   local outfit = config.outfits[param:lower()]

   if (#param == 0) then
      local outfits = availableOutfits()
      player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Available outfit"..(#outfits > 1 and "s" or "")..": "..table.concat(outfits, ", "))
      return false
   end    

   if not outfit then
      player:sendTextMessage(MESSAGE_INFO_DESCR, "This outfit does not exist.")
      player:getPosition():sendMagicEffect(CONST_ME_POFF)
      return false
   end

   if (outfit ~= player:getOutfit().lookType) then
      player:setOutfit({lookType = outfit})
   end
   player:getPosition():sendMagicEffect(CONST_ME_GROUNDSHAKER)
   return false
end
Like a charm :D thank you very much!
 
Like a charm :D thank you very much!
No problem :) If your plan is adding all outfits then you could use this one instead

Lua:
local config = {}
config.storage = 1500
config.exceptions = {"rat", "orc"} -- not available outfits name

function onSay(player, words, param)

   if player:getStorageValue(config.storage) ~= 1 then
      player:sendTextMessage(MESSAGE_INFO_DESCR, "You dont have this command yet.")
      player:getPosition():sendMagicEffect(CONST_ME_POFF)
      return false
   end

   param = param:gsub("%p", ""):lower()
   local monster = MonsterType(param)
   if not monster then
      player:sendTextMessage(MESSAGE_INFO_DESCR, "This monster outfit does not exist.")
      player:getPosition():sendMagicEffect(CONST_ME_POFF)
      return false
   end

   if isInArray(config.exceptions, param) then
      player:sendTextMessage(MESSAGE_INFO_DESCR, "This monster outfit is not available.")
      player:getPosition():sendMagicEffect(CONST_ME_POFF)
      return false
   end    

   local outfit = monster:getOutfit().lookType
   if (outfit ~= player:getOutfit().lookType) then
      player:setOutfit({lookType = outfit})
   end

   player:getPosition():sendMagicEffect(CONST_ME_GROUNDSHAKER)
   return false
end
 
Back
Top