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

storage outfit

Mateus Robeerto

Excellent OT User
Joined
Jun 5, 2016
Messages
1,463
Solutions
76
Reaction score
838
Location
ლ(ಠ益ಠლ)
Hello Otland community, I managed to put a "storage" to buy clothes and deliver to the player, working ok... However, it only delivers one. I can't place another storage to deliver another outfit, without success... Can someone help me, please?

follow the video:


I chose the 'Nordic Chieftain' outfit, but he gave away the 'Formal Dress'. I tried to put several different functions in without success... I need to finish this store soon, for God's sake.

in creaturescript.. game_store.lua.

Lua:
local category3 = addCategory({
    type = "outfit",
    name = " News Outfits ",
    outfit = {
      type = 128, -- This type is for displaying an image for the store.

      rotating = false
    }
})

 -- for the player to choose the outfit and buy!
category3.addOutfit(9, {
storage = 535923,

    type = 1500, 

    rotating = true
}, "Nordic Chieftain", "esta e a sua nova roupa legal. Voce pode compra-lo aqui")

category3.addOutfit(9, {
storage = 535924,

    type = 1489, 

    rotating = true
}, "Ghost Blade", "esta e a sua nova roupa legal. Voce pode compra-lo aqui")


category3.addOutfit(9, {
storage = 535925,
    type = 1460, 
    rotating = true
}, "Formal Dress", "esta e a sua nova roupa legal. Voce pode compra-lo aqui")


this part to buy.
Lua:
function defaultItemBuyAction(player, offer)
  if player:addItem(offer["itemId"], offer["count"], false) then
    return true
  end
  return "Unable to add item! you have enough space?"
end

local config = {
    -- Nordic Chieftain
    storage = 535923,
    looktype = 1500,
    -- Ghost Blade
    storage = 535924,
    looktype = 1489,
    -- Formal Dress
    storage = 535925,
    looktype = 1460
}


function defaultOutfitBuyAction(player, offer)
  local outfit = offer['outfit']
 

  if player:getStorageValue(config.storage) < 1 then
      player:addOutfit(config.looktype)
     player:sendTextMessage(MESSAGE_INFO_DESCR, "You already own this outfit!")
    return false
  end
 

  local points = getPoints(player)
  if offer['cost'] > points or points < 1 then
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You don't have enough points to buy this outfit")
    return false
  end
 
  -- Remover pontos do jogador
 db.query("UPDATE `znote_accounts` SET `points` = `points` - " .. offer['cost'] .. " WHERE `id` = " .. player:getAccountId())
 
    player:setStorageValue(config.storage, 1)
      player:addOutfit(outfit)
     player:sendTextMessage(MESSAGE_INFO_DESCR, "Congratulations, you bought an outfit")

 

  db.asyncQuery("INSERT INTO `shop_history` (`account`, `player`, `date`, `title`, `cost`, `details`) VALUES ('" .. player:getAccountId() .. "', '" .. player:getGuid() .. "', NOW(), " .. db.escapeString(offer['title']) .. ", " .. db.escapeString(offer['cost']) .. ", " .. db.escapeString(json.encode(offer)) .. ")")
 
local outfitName = outfit.name or "Unknown Outfit"
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully purchased the outfit '" .. outfitName .. "'.")


  return true
end
 
Solution
I belive it’s related to the way how it converts arrays to json and how it count elements (#array) so try define it like:

Lua:
category3.addOutfit(9, {
    mount = 0,
    feet = 114,
    legs = 114,
    body = 116,
    type = 1490,
    lookType = { 1490, 1489 },
    auxType = 0,
    addons = 0,
    head = 2,
    rotating = true
}, "Nordic Chieftain", "This is your cool new outfit. You can buy it here")

And add like:
Lua:
local sex = player:getSex()
local lookType = outfit.lookType[sex + 1]
local addons = outfit.addons

player:addOutfitAddon(lookType, addons)

Or add for both always:
Lua:
local addons = outfit.addons

for _, lookType in ipairs(outfit.lookType) do
    player:addOutfitAddon(lookType, addons)
end
which one is? can you share please?
My script, which has a 'storage' system for buying and delivering, is working. But there's also another guy's script that's already ready to use on the server. You can choose whichever you prefer, but I recommend using the other guy's script as it's working fine.



Sorry for the confusion. Here I will make it clearer to facilitate understanding and improve communication.


The guy who posted the script is @VagosClubTM , and it's working for normal deliveries. However, I wasn't happy with his script.


and my script that is working to deliver normally because each outfit has a storage system to deliver normally.. and lursky found the solution on how to deliver male and female... I tested it and it worked fine... so that's simple.. sorry for the delay confusion

Lua:
function defaultOutfitBuyAction(player, offer)
    local outfit = offer['outfit']

    if player:getStorageValue(outfit['storage']) > 0 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Você já possui este outfit!")
        return false
    end

    local points = getPoints(player)
    if offer['cost'] > points or points < 1 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Você não possui pontos suficientes para comprar este outfit")
        return false
    end

    db.query("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. offer['cost'] .. " WHERE `id` = " .. player:getAccountId())

    -- Add the outfit based on player's sex
    local sex = player:getSex()
    local lookType = outfit.lookType[sex + 1]
    local addons = outfit.addons

    player:addOutfit(lookType, addons)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "Você comprou seu novo outfit!")

    player:setStorageValue(outfit['storage'], 1)

    db.asyncQuery("INSERT INTO `shop_history` (`account`, `player`, `date`, `title`, `cost`, `details`) VALUES ('" .. player:getAccountId() .. "', '" .. player:getGuid() .. "', NOW(), " .. db.escapeString(offer['title']) .. ", " .. db.escapeString(offer['cost']) .. ", " .. db.escapeString(json.encode(offer)) .. ")")

    return true
end

Lua:
category3.addOutfit(9, {
storage = 535923,
    mount = 0,
    feet = 114,
    legs = 114,
    body = 116,
    type = 1490, ---This 'type' is just to show image
    lookType = { 1490, 1489 }, female e male
    auxType = 0,
    addons = 0,
    head = 2,
    rotating = true
}, "Nordic Chieftain", "Esta é a sua nova roupa legal. Você pode comprá-la aqui")
Post automatically merged:

edited post.
 
Last edited:
My script, which has a 'storage' system for buying and delivering, is working. But there's also another guy's script that's already ready to use on the server. You can choose whichever you prefer, but I recommend using the other guy's script as it's working fine.



Sorry for the confusion. Here I will make it clearer to facilitate understanding and improve communication.


The guy who posted the script is @VagosClubTM , and it's working for normal deliveries. However, I wasn't happy with his script.


and my script that is working to deliver normally because each outfit has a storage system to deliver normally.. and lursky found the solution on how to deliver male and female... I tested it and it worked fine... so that's simple.. sorry for the delay confusion

Lua:
function defaultOutfitBuyAction(player, offer)
    local outfit = offer['outfit']

    if player:getStorageValue(outfit['storage']) > 0 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Você já possui este outfit!")
        return false
    end

    local points = getPoints(player)
    if offer['cost'] > points or points < 1 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Você não possui pontos suficientes para comprar este outfit")
        return false
    end

    db.query("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. offer['cost'] .. " WHERE `id` = " .. player:getAccountId())

    -- Add the outfit based on player's sex
    local sex = player:getSex()
    local lookType = outfit.lookType[sex + 1]
    local addons = outfit.addons

    player:addOutfit(lookType, addons)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "Você comprou seu novo outfit!")

    player:setStorageValue(outfit['storage'], 1)

    db.asyncQuery("INSERT INTO `shop_history` (`account`, `player`, `date`, `title`, `cost`, `details`) VALUES ('" .. player:getAccountId() .. "', '" .. player:getGuid() .. "', NOW(), " .. db.escapeString(offer['title']) .. ", " .. db.escapeString(offer['cost']) .. ", " .. db.escapeString(json.encode(offer)) .. ")")

    return true
end

Lua:
category3.addOutfit(9, {
storage = 535923,
    mount = 0,
    feet = 114,
    legs = 114,
    body = 116,
    type = 1490, ---This 'type' is just to show image
    lookType = { 1490, 1489 }, female e male
    auxType = 0,
    addons = 0,
    head = 2,
    rotating = true
}, "Nordic Chieftain", "Esta é a sua nova roupa legal. Você pode comprá-la aqui")
Post automatically merged:

edited post.
:D cool
 
I did what you say but i don't receive the outfit, points are removed and a message that i have obtained xxx appears but there's no outfit
Lua:
-- BETA VERSION, net tested yet
-- Instruction:
-- creaturescripts.xml      <event type="extendedopcode" name="Shop" script="shop.lua" />
-- and in login.lua         player:registerEvent("Shop")
-- create sql table shop_history
-- set variables
-- set up function init(), add there items and categories, follow examples
-- set up callbacks at the bottom to add player item/outfit/whatever you want

local SHOP_EXTENDED_OPCODE = 201
local SHOP_OFFERS = {}
local SHOP_CALLBACKS = {}
local SHOP_CATEGORIES = nil
local SHOP_BUY_URL = "http://otland.net" -- can be empty
local SHOP_AD = { -- can be nil
  image = "https://s3.envato.com/files/62273611/PNG%20Blue/Banner%20blue%20468x60.png",
  url = "http://************",
  text = ""
}
local MAX_PACKET_SIZE = 50000

--[[ SQL TABLE

CREATE TABLE `shop_history` (
  `id` int(11) NOT NULL,
  `account` int(11) NOT NULL,
  `player` int(11) NOT NULL,
  `date` datetime NOT NULL,
  `title` varchar(100) NOT NULL,
  `cost` int(11) NOT NULL,
  `details` varchar(500) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

ALTER TABLE `shop_history`
  ADD PRIMARY KEY (`id`);
ALTER TABLE `shop_history`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

]]--

function init()
  --  print(json.encode(g_game.getLocalPlayer():getOutfit())) -- in console in otclient, will print current outfit and mount
 
  SHOP_CATEGORIES = {}

  local category1 = addCategory({
    type="item",
    item=ItemType(2160):getClientId(),
    count=100,
    name="Items"
  })
  local category2 = addCategory({
    type="outfit",
    name="Outfits",
    outfit={
        mount=0,
        feet=114,
        legs=114,
        body=116,
        type=143,
        auxType=0,
        addons=3,
        head=2,
        rotating=true
    }
  })
  local category3 = addCategory({
    type="image",
    image="http://************/images/137.png",
    name="Category with http image"
  })
  local category4 = addCategory({
    type="image",
    image="/data/images/game/states/electrified.png",
    name="Category with local image"
  })
 
 
  category1.addItem(1, 2160, 1, "1 Crystal coin", "description of cristal coin")
  category1.addItem(5, 2160, 5, "5 Crystal coin", "description of cristal coin")
  category1.addItem(50, 2160, 50, "50 Crystal coin", "description of cristal coin")
  category1.addItem(90, 2160, 100, "100 Crystal coin", "description of cristal coin")
  category1.addItem(200, 2493, 1, "Demon helmet1", "woo\ndemon helmet\nnice, you should buy it")
  category1.addItem(1, 2160, 1, "1 Crystal coin1", "description of cristal coin")
  category1.addItem(5, 2160, 5, "5 Crystal coin1", "description of cristal coin")
  category1.addItem(50, 2160, 50, "50 Crystal coin1", "description of cristal coin")
  category1.addItem(90, 2160, 100, "100 Crystal coin1", "description of cristal coin")
  category1.addItem(200, 2493, 1, "Demon helmet2", "woo\ndemon helmet\nnice, you should buy it")
  category1.addItem(1, 2160, 1, "1 Crystal coin3", "description of cristal coin")
  category1.addItem(5, 2160, 5, "5 Crystal coin3", "description of cristal coin")
  category1.addItem(50, 2160, 50, "50 Crystal coin3", "description of cristal coin")
  category1.addItem(90, 2160, 100, "100 Crystal coin3", "description of cristal coin")
  category1.addItem(200, 2493, 1, "Demon helmet3", "wooxD\ndemon helmet\nnice, you should buy it")
 
   category2.addOutfit(100, {
storage = 535923,
    mount = 0,
    feet = 114,
    legs = 114,
    body = 116,
    type = 100, ---This 'type' is just to show image
    lookType = { 100, 100 }, --female e male
    auxType = 0,
    addons = 0,
    head = 2,
    rotating = true
}, "Nordic Chieftain", "Esta é a sua nova roupa legal. Você pode comprá-la aqui")
   
    category4.addImage(10000, "/data/images/game/states/haste.png", "Offer with local image", "another local image\n/data/images/game/states/haste.png")
    category4.addImage(10000, "http://************/images/freezing.png", "Offer with remote image and custom buy action", "blalasdasd image\nhttp://************/images/freezing.png", customImageBuyAction)
end

function addCategory(data)
  data['offers'] = {}
  table.insert(SHOP_CATEGORIES, data)
  table.insert(SHOP_CALLBACKS, {})
  local index = #SHOP_CATEGORIES
  return {
    addItem = function(cost, itemId, count, title, description, callback)    
      if not callback then
        callback = defaultItemBuyAction
      end
      table.insert(SHOP_CATEGORIES[index]['offers'], {
        cost=cost,
        type="item",
        item=ItemType(itemId):getClientId(), -- displayed
        itemId=itemId,
        count=count,
        title=title,
        description=description
      })
      table.insert(SHOP_CALLBACKS[index], callback)
    end,
    addOutfit = function(cost, outfit, title, description, callback)
      if not callback then
        callback = defaultOutfitBuyAction
      end
      table.insert(SHOP_CATEGORIES[index]['offers'], {
        cost=cost,
        type="outfit",
        outfit=outfit,
        title=title,
        description=description
      })  
      table.insert(SHOP_CALLBACKS[index], callback)
    end,
    addImage = function(cost, image, title, description, callback)
      if not callback then
        callback = defaultImageBuyAction
      end
      table.insert(SHOP_CATEGORIES[index]['offers'], {
        cost=cost,
        type="image",
        image=image,
        title=title,
        description=description
      })
      table.insert(SHOP_CALLBACKS[index], callback)
    end
  }
end

function getPoints(player)
  local points = 0
  local resultId = db.storeQuery("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. player:getAccountId())
  if resultId ~= false then
    points = result.getDataInt(resultId, "premium_points")
    result.free(resultId)
  end
  return points
end

function getStatus(player)
  local status = {
    ad = SHOP_AD,
    points = getPoints(player),
    buyUrl = SHOP_BUY_URL
  }
  return status
end

function sendJSON(player, action, data, forceStatus)
  local status = nil
  if not player:getStorageValue(1150001) or player:getStorageValue(1150001) + 10 < os.time() or forceStatus then
      status = getStatus(player)
  end
  player:setStorageValue(1150001, os.time())
 

  local buffer = json.encode({action = action, data = data, status = status})
  local s = {}
  for i=1, #buffer, MAX_PACKET_SIZE do
     s[#s+1] = buffer:sub(i,i+MAX_PACKET_SIZE - 1)
  end
  local msg = NetworkMessage()
  if #s == 1 then
    msg:addByte(50)
    msg:addByte(SHOP_EXTENDED_OPCODE)
    msg:addString(s[1])
    msg:sendToPlayer(player)
    return
  end
  -- split message if too big
  msg:addByte(50)
  msg:addByte(SHOP_EXTENDED_OPCODE)
  msg:addString("S" .. s[1])
  msg:sendToPlayer(player)
  for i=2,#s - 1 do
    msg = NetworkMessage()
    msg:addByte(50)
    msg:addByte(SHOP_EXTENDED_OPCODE)
    msg:addString("P" .. s[i])
    msg:sendToPlayer(player)
  end
  msg = NetworkMessage()
  msg:addByte(50)
  msg:addByte(SHOP_EXTENDED_OPCODE)
  msg:addString("E" .. s[#s])
  msg:sendToPlayer(player)
end

function sendMessage(player, title, msg, forceStatus)
  sendJSON(player, "message", {title=title, msg=msg}, forceStatus)
end

function onExtendedOpcode(player, opcode, buffer)
  if opcode ~= SHOP_EXTENDED_OPCODE then
    return false
  end
  local status, json_data = pcall(function() return json.decode(buffer) end)
  if not status then
    return false
  end

  local action = json_data['action']
  local data = json_data['data']
  if not action or not data then
    return false
  end

  if SHOP_CATEGORIES == nil then
    init()  
  end

  if action == 'init' then
    sendJSON(player, "categories", SHOP_CATEGORIES)
  elseif action == 'buy' then
    processBuy(player, data)
  elseif action == "history" then
    sendHistory(player)
  end
  return true
end

function processBuy(player, data)
  local categoryId = tonumber(data["category"])
  local offerId = tonumber(data["offer"])
  local offer = SHOP_CATEGORIES[categoryId]['offers'][offerId]
  local callback = SHOP_CALLBACKS[categoryId][offerId]
  if not offer or not callback or data["title"] ~= offer["title"] or data["cost"] ~= offer["cost"] then
    sendJSON(player, "categories", SHOP_CATEGORIES) -- refresh categories, maybe invalid
    return sendMessage(player, "Error!", "Invalid offer")    
  end
  local points = getPoints(player)
  if not offer['cost'] or offer['cost'] > points or points < 1 then
    return sendMessage(player, "Error!", "You don't have enough points to buy " .. offer['title'] .."!", true)  
  end
  local status = callback(player, offer)
  if status == true then  
    db.query("UPDATE `accounts` set `premium_points` = `premium_points` - " .. offer['cost'] .. " WHERE `id` = " .. player:getAccountId())
    db.asyncQuery("INSERT INTO `shop_history` (`account`, `player`, `date`, `title`, `cost`, `details`) VALUES ('" .. player:getAccountId() .. "', '" .. player:getGuid() .. "', NOW(), " .. db.escapeString(offer['title']) .. ", " .. db.escapeString(offer['cost']) .. ", " .. db.escapeString(json.encode(offer)) .. ")")
    return sendMessage(player, "Success!", "You bought " .. offer['title'] .."!", true)
  end
  if status == nil or status == false then
    status = "Unknown error while buying " .. offer['title']
  end
  sendMessage(player, "Error!", status)
end

function sendHistory(player)
  if player:getStorageValue(1150002) and player:getStorageValue(1150002) + 10 > os.time() then
    return -- min 10s delay
  end
  player:setStorageValue(1150002, os.time())
 
  local history = {}
  local resultId = db.storeQuery("SELECT * FROM `shop_history` WHERE `account` = " .. player:getAccountId() .. " order by `id` DESC")

  if resultId ~= false then
    repeat
      local details = result.getDataString(resultId, "details")
      local status, json_data = pcall(function() return json.decode(details) end)
      if not status then  
        json_data = {
          type = "image",
          title = result.getDataString(resultId, "title"),
          cost = result.getDataInt(resultId, "cost")
        }
      end
      table.insert(history, json_data)
      history[#history]["description"] = "Bought on " .. result.getDataString(resultId, "date") .. " for " .. result.getDataInt(resultId, "cost") .. " points."
    until not result.next(resultId)
    result.free(resultId)
  end
 
  sendJSON(player, "history", history)
end

-- BUY CALLBACKS
-- May be useful: print(json.encode(offer))

function defaultItemBuyAction(player, offer)
  -- todo: check if has capacity
  if player:addItem(offer["itemId"], offer["count"], false) then
    return true
  end
  return "Can't add item! Do you have enough space?"
end

function defaultOutfitBuyAction(player, offer)
    local outfit = offer['outfit']

    if player:getStorageValue(outfit['storage']) > 0 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Você já possui este outfit!")
        return false
    end

    local points = getPoints(player)
    if offer['cost'] > points or points < 1 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Você não possui pontos suficientes para comprar este outfit")
        return false
    end

    db.query("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. offer['cost'] .. " WHERE `id` = " .. player:getAccountId())

    -- Add the outfit based on player's sex
    local sex = player:getSex()
    local lookType = outfit.lookType[sex + 1]
    local addons = outfit.addons

    player:addOutfit(lookType, addons)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "Você comprou seu novo outfit!")

    player:setStorageValue(outfit['storage'], 1)

    db.asyncQuery("INSERT INTO `shop_history` (`account`, `player`, `date`, `title`, `cost`, `details`) VALUES ('" .. player:getAccountId() .. "', '" .. player:getGuid() .. "', NOW(), " .. db.escapeString(offer['title']) .. ", " .. db.escapeString(offer['cost']) .. ", " .. db.escapeString(json.encode(offer)) .. ")")

    return true
end

function defaultImageBuyAction(player, offer)
  return "default image buy action is not implemented"
end

function customImageBuyAction(player, offer)
  return "custom image buy action is not implemented. Offer: " .. offer['title']
end

edit: my bad the script works ! o: THANK you
 
Last edited:
My script, which has a 'storage' system for buying and delivering, is working. But there's also another guy's script that's already ready to use on the server. You can choose whichever you prefer, but I recommend using the other guy's script as it's working fine.



Sorry for the confusion. Here I will make it clearer to facilitate understanding and improve communication.


The guy who posted the script is @VagosClubTM , and it's working for normal deliveries. However, I wasn't happy with his script.


and my script that is working to deliver normally because each outfit has a storage system to deliver normally.. and lursky found the solution on how to deliver male and female... I tested it and it worked fine... so that's simple.. sorry for the delay confusion

Lua:
function defaultOutfitBuyAction(player, offer)
    local outfit = offer['outfit']

    if player:getStorageValue(outfit['storage']) > 0 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Você já possui este outfit!")
        return false
    end

    local points = getPoints(player)
    if offer['cost'] > points or points < 1 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Você não possui pontos suficientes para comprar este outfit")
        return false
    end

    db.query("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. offer['cost'] .. " WHERE `id` = " .. player:getAccountId())

    -- Add the outfit based on player's sex
    local sex = player:getSex()
    local lookType = outfit.lookType[sex + 1]
    local addons = outfit.addons

    player:addOutfit(lookType, addons)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "Você comprou seu novo outfit!")

    player:setStorageValue(outfit['storage'], 1)

    db.asyncQuery("INSERT INTO `shop_history` (`account`, `player`, `date`, `title`, `cost`, `details`) VALUES ('" .. player:getAccountId() .. "', '" .. player:getGuid() .. "', NOW(), " .. db.escapeString(offer['title']) .. ", " .. db.escapeString(offer['cost']) .. ", " .. db.escapeString(json.encode(offer)) .. ")")

    return true
end

Lua:
category3.addOutfit(9, {
storage = 535923,
    mount = 0,
    feet = 114,
    legs = 114,
    body = 116,
    type = 1490, ---This 'type' is just to show image
    lookType = { 1490, 1489 }, female e male
    auxType = 0,
    addons = 0,
    head = 2,
    rotating = true
}, "Nordic Chieftain", "Esta é a sua nova roupa legal. Você pode comprá-la aqui")
Post automatically merged:

edited post.
Reviving the post,

It works for deliver female or male, but what about addons ? 1/2/3, no number it works and doesnt deliver any addon.
About mounts ?
mount = 850, type = 850, looktype, tried 0, 0, 850, 850,
It doesnt deliver the mount.
 
Reviving the post,

It works for deliver female or male, but what about addons ? 1/2/3, no number it works and doesnt deliver any addon.
About mounts ?
mount = 850, type = 850, looktype, tried 0, 0, 850, 850,
It doesnt deliver the mount.
Regarding men's and women's outfits, delivery works normally. Actually, I haven't tested the addons yet. As for mounts, have you added them to your script yet? If not, just add them here.

Lua:
   local category5 = addCategory({
    type = "outfit",
    name = "Novas Montarias",
    outfit = {
      type = 1441,

      rotating = false
    }
  })
 
category5.addOutfit(250, {
    storage = 536925,
    mount = 20,
    type = 392,
    mountId = 20,
    rotating = true,
    name = "War Horse" -- Provide the name of the outfit or mount here
},

Lua:
function defaultOutfitBuyAction(player, offer)
    local outfit = offer['outfit']
    local mountId = outfit['mount']
 
    if player:getStorageValue(outfit['storage']) > 0 then
        local message = "Você já possui esta " .. outfit['name'] .. "!"
        player:sendTextMessage(MESSAGE_INFO_DESCR, message)
        return false
    end
 
    local points = getPoints(player)
    if offer['cost'] > points or points < 1 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Você não possui pontos suficientes para comprar este outfit")
        return false
    end
 
    db.query("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. offer['cost'] .. " WHERE `id` = " .. player:getAccountId())
 
    if outfit['lookType'] then
        local sex = player:getSex()
        local lookType = outfit['lookType'][sex + 1]
        local addons = outfit['addons']

        player:addOutfitAddon(lookType, addons)
        player:addOutfit(outfit['type'], addons)
    end
    
    player:setStorageValue(outfit['storage'], 1)
    
    local message = "Você comprou o " .. outfit['name'] .. "!"
    player:sendTextMessage(MESSAGE_INFO_DESCR, message)
    
    if mountId > 0 then
        player:addMount(mountId)
        player:setStorageValue(outfit['storage'], 1)
    end
 
    db.asyncQuery("INSERT INTO `shop_history` (`account`, `player`, `date`, `title`, `cost`, `details`) VALUES ('" .. player:getAccountId() .. "', '" .. player:getGuid() .. "', NOW(), " .. db.escapeString(offer['title']) .. ", " .. db.escapeString(offer['cost']) .. ", " .. db.escapeString(json.encode(offer)) .. ")")
 
    return true
end

About 'type', it is only used to display the image. You must set the 'mountId' so that the player receives the mount normally.
 
Regarding men's and women's outfits, delivery works normally. Actually, I haven't tested the addons yet. As for mounts, have you added them to your script yet? If not, just add them here.

Lua:
   local category5 = addCategory({
    type = "outfit",
    name = "Novas Montarias",
    outfit = {
      type = 1441,

      rotating = false
    }
  })
 
category5.addOutfit(250, {
    storage = 536925,
    mount = 20,
    type = 392,
    mountId = 20,
    rotating = true,
    name = "War Horse" -- Provide the name of the outfit or mount here
},

Lua:
function defaultOutfitBuyAction(player, offer)
    local outfit = offer['outfit']
    local mountId = outfit['mount']
 
    if player:getStorageValue(outfit['storage']) > 0 then
        local message = "Você já possui esta " .. outfit['name'] .. "!"
        player:sendTextMessage(MESSAGE_INFO_DESCR, message)
        return false
    end
 
    local points = getPoints(player)
    if offer['cost'] > points or points < 1 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Você não possui pontos suficientes para comprar este outfit")
        return false
    end
 
    db.query("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. offer['cost'] .. " WHERE `id` = " .. player:getAccountId())
 
    if outfit['lookType'] then
        local sex = player:getSex()
        local lookType = outfit['lookType'][sex + 1]
        local addons = outfit['addons']

        player:addOutfitAddon(lookType, addons)
        player:addOutfit(outfit['type'], addons)
    end
   
    player:setStorageValue(outfit['storage'], 1)
   
    local message = "Você comprou o " .. outfit['name'] .. "!"
    player:sendTextMessage(MESSAGE_INFO_DESCR, message)
   
    if mountId > 0 then
        player:addMount(mountId)
        player:setStorageValue(outfit['storage'], 1)
    end
 
    db.asyncQuery("INSERT INTO `shop_history` (`account`, `player`, `date`, `title`, `cost`, `details`) VALUES ('" .. player:getAccountId() .. "', '" .. player:getGuid() .. "', NOW(), " .. db.escapeString(offer['title']) .. ", " .. db.escapeString(offer['cost']) .. ", " .. db.escapeString(json.encode(offer)) .. ")")
 
    return true
end

About 'type', it is only used to display the image. You must set the 'mountId' so that the player receives the mount normally.

Is there a reason why you guys use storage instead of checking by player:hasMount or player:hasOutfit?
 
Is there a reason why you guys use storage instead of checking by player:hasMount or player:hasOutfit?
I configured the warehouse to receive correctly, without it it would not be delivered correctly. I haven't used the functions you mentioned yet, but I will soon try to remove the warehouse and set it up for testing. I actually don't use this store because of the limit. I chose to use another custom store that allows you to add many mounts and outfits and still use these functions, such as 'player:hasMount' or 'player:hasOutfit'. It was good.
 
I configured the warehouse to receive correctly, without it it would not be delivered correctly. I haven't used the functions you mentioned yet, but I will soon try to remove the warehouse and set it up for testing. I actually don't use this store because of the limit. I chose to use another custom store that allows you to add many mounts and outfits and still use these functions, such as 'player:hasMount' or 'player:hasOutfit'. It was good.

Which shop do u use?
 
I was the one who downloaded and adapted it to 'coins/premium_coins', and it worked normally.

The default OTClient store does not allow you to add mounts and costumes, as there is no addition limit, only for the use of some normal items. It's ready and everything is fine. The other one, the custom store, isn't ready yet, but I'll fix it soon. LOL
 
Regarding men's and women's outfits, delivery works normally. Actually, I haven't tested the addons yet. As for mounts, have you added them to your script yet? If not, just add them here.

Lua:
   local category5 = addCategory({
    type = "outfit",
    name = "Novas Montarias",
    outfit = {
      type = 1441,

      rotating = false
    }
  })
 
category5.addOutfit(250, {
    storage = 536925,
    mount = 20,
    type = 392,
    mountId = 20,
    rotating = true,
    name = "War Horse" -- Provide the name of the outfit or mount here
},

Lua:
function defaultOutfitBuyAction(player, offer)
    local outfit = offer['outfit']
    local mountId = outfit['mount']
 
    if player:getStorageValue(outfit['storage']) > 0 then
        local message = "Você já possui esta " .. outfit['name'] .. "!"
        player:sendTextMessage(MESSAGE_INFO_DESCR, message)
        return false
    end
 
    local points = getPoints(player)
    if offer['cost'] > points or points < 1 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "Você não possui pontos suficientes para comprar este outfit")
        return false
    end
 
    db.query("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. offer['cost'] .. " WHERE `id` = " .. player:getAccountId())
 
    if outfit['lookType'] then
        local sex = player:getSex()
        local lookType = outfit['lookType'][sex + 1]
        local addons = outfit['addons']

        player:addOutfitAddon(lookType, addons)
        player:addOutfit(outfit['type'], addons)
    end
   
    player:setStorageValue(outfit['storage'], 1)
   
    local message = "Você comprou o " .. outfit['name'] .. "!"
    player:sendTextMessage(MESSAGE_INFO_DESCR, message)
   
    if mountId > 0 then
        player:addMount(mountId)
        player:setStorageValue(outfit['storage'], 1)
    end
 
    db.asyncQuery("INSERT INTO `shop_history` (`account`, `player`, `date`, `title`, `cost`, `details`) VALUES ('" .. player:getAccountId() .. "', '" .. player:getGuid() .. "', NOW(), " .. db.escapeString(offer['title']) .. ", " .. db.escapeString(offer['cost']) .. ", " .. db.escapeString(json.encode(offer)) .. ")")
 
    return true
end

About 'type', it is only used to display the image. You must set the 'mountId' so that the player receives the mount normally.
Yep, i just add a ) that you forget on the script, pressing buy on mount, nothing happens.
 
With this script, the points do not appear, with the previous script, it does not let me buy the outfits, do you know why that happens? I use tfs 1.2
You need to understand the schema of your database. For example, if you're using Znote, it uses 'znote_accounts' and 'points'. If it's Gesior, it uses 'accounts' and 'premium_points', and so on. Check your game store script and look for this line. Change it according to your website to display points correctly.
 
Back
Top