Final project: a 24/7 store with QBCore · Lesson 1/4 · 6 min

Design the store

Before typing, define what it does and what files you need. A good plan is half the battle.

We're going to build a real resource that brings the whole course together: a 24/7 store. The player walks up to the clerk, opens a menu, picks an item and, if they have money, takes it. All validated on the server.

Scope (what it does and what it does NOT)

  • There's a store zone (qb-target) at some Config coordinates.
  • On interaction a menu opens (qb-menu or ox_lib) with the products.
  • On selection, the client ASKS to buy; the server checks money and delivers the item.
  • Prices and items come from Config on the server, never from the client.

Files

text
tienda_247/
├── fxmanifest.lua
├── config.lua    -- coords + catalog (item, price)
├── client.lua    -- qb-target + menu
└── server.lua    -- validated purchase callback

Structure

Designing first avoids 90% of the mess. Server-authoritative from minute zero: the client opens the menu and asks; the server decides whether to charge and deliver.

Practice what you learned

0/3
Test

En la tienda 24/7, ¿quién decide el precio y si se cobra al jugador?

Ordena el código

Ordena el flujo de una compra en la tienda, desde que el jugador interactúa hasta que recibe el item.

Coloca las líneas en el orden correcto con las flechas.

El jugador elige un item y el cliente manda su NOMBRE al servidor
El jugador interactúa con la zona qb-target del dependiente
El servidor entrega el item y notifica al jugador
El servidor busca el precio en Config, comprueba el dinero y cobra
El cliente abre el menú con los productos de Config
Pista

Cliente: target → menú → pedir. Servidor: validar → cobrar → entregar.

Rellena los huecos

Completa la estructura de archivos del recurso de la tienda: el archivo donde van las coordenadas y el catálogo.

1tienda_247/
2├── fxmanifest.lua
3├── -- coords + catálogo (item, precio)
4├── client.lua
5└── server.lua
Pista

Es un archivo compartido (shared_script) con la tabla Config.

Challenge: code it yourself

Write in 3 lines what the server decides and what the client does in this store.

Write it yourself in your editor (VS Code) and test it on your server. You learn here by doing it, not by copying.

See hint

Client: target + menu + ask. Server: check money, charge and deliver the item.

Escribe aquí tu solución:

How was this lesson?