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

[Module] game_shop

Resolved Script:

Code:
function getPremiumPoints(cid)
    local player = Player(cid)
    local query = db.storeQuery("SELECT `premium_points` FROM `accounts` WHERE `id` =" ..player:getAccountId()..";")
   
    if query ~= false then
        local points = result.getNumber(query, 'premium_points')
        print("Has points:" ..points)
        result.free(query)
        return points
    else
        print("Internal database load error.")
        return 0
    end   
end

local function addPlayerPremiumPoints(cid, count)
    db.query('UPDATE accounts SET premium_points = premium_points+'.. count ..' WHERE id = ' .. getAccountNumberByPlayerName(getCreatureName(cid)))
    print("Points have been set. Now has: " ..getPremiumPoints(cid))
end

function onSay(cid, words, param, channel)
local player = Player(cid)
local cost = 10

    if (getPremiumPoints(cid) >= cost) then
        player:addItem(10135, 1)
         addPlayerPremiumPoints(cid, -cost)
         player:sendTextMessage(MESSAGE_INFO_DESCR, "You have " ..getPremiumPoints(cid).." remaining")
    else
         player:sendTextMessage(MESSAGE_INFO_DESCR, "You only have " .. getPremiumPoints(cid) .. " out of " ..cost.. " required points.")
     end
end

with OTX 3.7
 
Last edited:
Sí, puedes hacerlo fácilmente. Cambie el tipo de contenedor principal principal de "Panel" a "ScrollablePanel" y adjunte una barra de desplazamiento vertical. Ejemplo de los 2:


[código] Panel desplazable
id: panel principal
barra de desplazamiento vertical: mainPanelScrollbar
//definir más atributos aquí

Barra de desplazamiento vertical
id: barra de desplazamiento del panel principal
anclas.superior: padre.superior
anclas.fondo: padre.fondo
anclas.derecha: padre.derecha
paso: 24
desplazamiento de píxeles: verdadero [/ código]

Puede aplicar lo mismo a la lista en el lado izquierdo, luego adjunte un elemento UIWidget con fuente de imagen: /ruta/a/foto para su imagen de "Tienda". Ancle su parte superior a la parte inferior de este panel desplazable izquierdo.

Scrollbar It doesn't work my shop panel


Lua:
AddonButton < UIButton
  width: 97
  height: 121
  margin-left: 20
  margin-bottom: 20

ScrollablePanel
  ScrollablePanel
    id: mainPanelScrollbar
    vertical-scrollbar: mainPanelScrollbar

  VerticalScrollBar
    id: mainPanelScrollbar
    anchors.top: parent.top
    anchors.bottom: parent.bottom
    anchors.right: parent.right
    margin-left:-20
    minimum: 0
    maximum: 100
    step: 12
    pixels-scroll: true

  AddonButton
    id: box1
    image-source: /modules/game_shop/images/buttonimg/addon_espaceex
    anchors.top: parent.top
    anchors.left: parent.left
    @onClick: modules.game_shop.buyExpaceEx()
  AddonButton
    id: box2
    image-source: /modules/game_shop/images/buttonimg/addon_barbarian
    anchors.top: prev.top
    anchors.left: prev.right
    @onClick: modules.game_shop.buyBarbarian()
  AddonButton
    id: box3
    image-source: /modules/game_shop/images/buttonimg/addon_snakeness
    anchors.top: prev.top
    anchors.left: prev.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box4
    image-source: /modules/game_shop/images/buttonimg/addon_theking
    anchors.top: prev.top
    anchors.left: prev.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box5
    image-source: /modules/game_shop/images/buttonimg/addon_aqua
    anchors.top: prev.top
    anchors.left: prev.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box6
    image-source: /modules/game_shop/images/buttonimg/addon_vikitrig
    anchors.top: box1.bottom
    anchors.left: parent.left
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box7
    image-source: /modules/game_shop/images/buttonimg/addon_lancer
    anchors.top: box2.bottom
    anchors.left: box1.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box8
    image-source: /modules/game_shop/images/buttonimg/addon_exploshion
    anchors.top: box3.bottom
    anchors.left: box2.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box9
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box4.bottom
    anchors.left: box3.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box10
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box5.bottom
    anchors.left: box4.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box11
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box6.bottom
    anchors.left: parent.left
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box12
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box7.bottom
    anchors.left: box1.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box13
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box8.bottom
    anchors.left: box2.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box14
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box9.bottom
    anchors.left: box3.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box15
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box10.bottom
    anchors.left: box4.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box16
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box11.bottom
    anchors.left: parent.left
    @onClick: modules.game_shop.buyBeggar()


222222222.gif
 
Scrollbar It doesn't work my shop panel


Lua:
AddonButton < UIButton
  width: 97
  height: 121
  margin-left: 20
  margin-bottom: 20

ScrollablePanel
  ScrollablePanel
    id: mainPanelScrollbar
    vertical-scrollbar: mainPanelScrollbar

  VerticalScrollBar
    id: mainPanelScrollbar
    anchors.top: parent.top
    anchors.bottom: parent.bottom
    anchors.right: parent.right
    margin-left:-20
    minimum: 0
    maximum: 100
    step: 12
    pixels-scroll: true

  AddonButton
    id: box1
    image-source: /modules/game_shop/images/buttonimg/addon_espaceex
    anchors.top: parent.top
    anchors.left: parent.left
    @onClick: modules.game_shop.buyExpaceEx()
  AddonButton
    id: box2
    image-source: /modules/game_shop/images/buttonimg/addon_barbarian
    anchors.top: prev.top
    anchors.left: prev.right
    @onClick: modules.game_shop.buyBarbarian()
  AddonButton
    id: box3
    image-source: /modules/game_shop/images/buttonimg/addon_snakeness
    anchors.top: prev.top
    anchors.left: prev.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box4
    image-source: /modules/game_shop/images/buttonimg/addon_theking
    anchors.top: prev.top
    anchors.left: prev.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box5
    image-source: /modules/game_shop/images/buttonimg/addon_aqua
    anchors.top: prev.top
    anchors.left: prev.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box6
    image-source: /modules/game_shop/images/buttonimg/addon_vikitrig
    anchors.top: box1.bottom
    anchors.left: parent.left
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box7
    image-source: /modules/game_shop/images/buttonimg/addon_lancer
    anchors.top: box2.bottom
    anchors.left: box1.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box8
    image-source: /modules/game_shop/images/buttonimg/addon_exploshion
    anchors.top: box3.bottom
    anchors.left: box2.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box9
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box4.bottom
    anchors.left: box3.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box10
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box5.bottom
    anchors.left: box4.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box11
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box6.bottom
    anchors.left: parent.left
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box12
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box7.bottom
    anchors.left: box1.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box13
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box8.bottom
    anchors.left: box2.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box14
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box9.bottom
    anchors.left: box3.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box15
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box10.bottom
    anchors.left: box4.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box16
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box11.bottom
    anchors.left: parent.left
    @onClick: modules.game_shop.buyBeggar()


222222222.gif
I have the same error, i got this on terminal.

ERROR: lua function callback failed: /modules/corelib/ui/uiscrollarea.lua:47: attempt to call method 'setMinimum' (a nil value)
stack traceback:
[C]: in function 'setMinimum'
/modules/corelib/ui/uiscrollarea.lua:47: in function 'updateScrollBars'
/modules/corelib/ui/uiscrollarea.lua:82: in function 'setVerticalScrollBar'
/modules/corelib/ui/uiscrollarea.lua:19: in function </modules/corelib/ui/uiscrollarea.lua:16>

but i dont know what to do anymore
 
Scrollbar It doesn't work my shop panel


Lua:
AddonButton < UIButton
  width: 97
  height: 121
  margin-left: 20
  margin-bottom: 20

ScrollablePanel
  ScrollablePanel
    id: mainPanelScrollbar
    vertical-scrollbar: mainPanelScrollbar

  VerticalScrollBar
    id: mainPanelScrollbar
    anchors.top: parent.top
    anchors.bottom: parent.bottom
    anchors.right: parent.right
    margin-left:-20
    minimum: 0
    maximum: 100
    step: 12
    pixels-scroll: true

  AddonButton
    id: box1
    image-source: /modules/game_shop/images/buttonimg/addon_espaceex
    anchors.top: parent.top
    anchors.left: parent.left
    @onClick: modules.game_shop.buyExpaceEx()
  AddonButton
    id: box2
    image-source: /modules/game_shop/images/buttonimg/addon_barbarian
    anchors.top: prev.top
    anchors.left: prev.right
    @onClick: modules.game_shop.buyBarbarian()
  AddonButton
    id: box3
    image-source: /modules/game_shop/images/buttonimg/addon_snakeness
    anchors.top: prev.top
    anchors.left: prev.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box4
    image-source: /modules/game_shop/images/buttonimg/addon_theking
    anchors.top: prev.top
    anchors.left: prev.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box5
    image-source: /modules/game_shop/images/buttonimg/addon_aqua
    anchors.top: prev.top
    anchors.left: prev.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box6
    image-source: /modules/game_shop/images/buttonimg/addon_vikitrig
    anchors.top: box1.bottom
    anchors.left: parent.left
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box7
    image-source: /modules/game_shop/images/buttonimg/addon_lancer
    anchors.top: box2.bottom
    anchors.left: box1.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box8
    image-source: /modules/game_shop/images/buttonimg/addon_exploshion
    anchors.top: box3.bottom
    anchors.left: box2.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box9
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box4.bottom
    anchors.left: box3.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box10
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box5.bottom
    anchors.left: box4.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box11
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box6.bottom
    anchors.left: parent.left
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box12
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box7.bottom
    anchors.left: box1.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box13
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box8.bottom
    anchors.left: box2.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box14
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box9.bottom
    anchors.left: box3.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box15
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box10.bottom
    anchors.left: box4.right
    @onClick: modules.game_shop.buyBeggar()
  AddonButton
    id: box16
    image-source: /modules/game_shop/images/buttonimg/addon_beggar
    anchors.top: box11.bottom
    anchors.left: parent.left
    @onClick: modules.game_shop.buyBeggar()


222222222.gif
HELP!
 

Similar threads

Back
Top