Final project: your first ATM · Lesson 1/4 · 6 min

Design the ATM

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 together everything from the course: an ATM. The player approaches, presses E, sees their balance and can deposit or withdraw money from the bank.

Scope (what it does and what it does NOT)

  • There are ATMs at certain coordinates (Config).
  • Near one, 'Press E' appears and pressing it opens it.
  • The player sees their bank and cash balance.
  • They can deposit (cash → bank) and withdraw (bank → cash), validated on the server.
  • No fancy NUI for now: we'll keep it simple and solid. You improve the interface later.

Files

text
mi_cajero/
├── fxmanifest.lua
├── config.lua
├── client.lua   -- zone + E key
└── server.lua   -- validated deposit/withdraw

Structure

Designing first avoids 90% of the mess. You know which files you touch, what the server decides and what the client does. Server-authoritative from minute zero.

Practice what you learned

0/3
Test

En el cajero, ¿quién comprueba el saldo y mueve el dinero de verdad?

Pista

¿Qué parte puede manipular un tramposo?

Rellena los huecos

Completa el config.lua con la tecla E (38) y la distancia de uso.

1Config = {}
2Config.Tecla = -- E
3Config.Distancia =
Pista

La tecla E es el control 38; una distancia de ~1.5 metros va bien para un cajero.

Ordena el código

Ordena el flujo completo de un retiro, desde que el jugador llega hasta que ve el resultado.

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

-- 5) El cliente muestra el resultado al jugador
-- 1) El jugador se acerca al cajero
-- 4) El servidor valida el saldo y mueve el dinero
-- 3) Al pulsar E, el cliente pide al servidor
-- 2) El cliente detecta la cercania y muestra 'Pulsa E'
Pista

Primero detectar, luego pedir, el servidor decide y el cliente solo muestra.

Challenge: code it yourself

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

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: detect proximity and ask. Server: check balance and move the money.

Escribe aquí tu solución:

How was this lesson?