Debug errors like a pro · Lesson 3/3 · 9 min
Isolate the problem and hunt down the lag
Divide and conquer to find the bug; and use resmon to find the resource eating your FPS.
Isolate: divide and conquer
If a long function fails and you don't know where, comment out half. Still failing? It's in the other half. Stops failing? It's in what you commented out. Repeat until you corner the line. You've got it in 4-5 steps.
Hunt the lag with resmon
# In the client console (F8):
resmon
# It lists every resource and how much CPU (ms) it uses per frame.
# Green < 1ms = good. Yellow/red = that resource is eating your FPS.resmon
- A resource above ~1-2ms while idle is suspicious (remember the dynamic Waits from the previous module).
- If a resource has spikes (hitches), it's usually a loop without Wait or a MySQL query every frame.
- Remove resources one by one to confirm which one causes the problem.
And when you're truly stuck: paste the error and the code into the Crxative-M chat. That's what it's for: it tells you the root cause and the fix without wasting your afternoon.
Practice what you learned
0/3En resmon, un recurso en VERDE (< 1ms por frame) significa que...
Pista
Piensa en un semáforo: verde es 'todo bien'.
Este hilo congela al cliente porque nunca descansa. Arréglalo añadiendo un Wait dentro del bucle.
Este código tiene un fallo:
CreateThread(function() while true do DibujarMarcador() endend)Reescríbelo corregido:
Pista
Un 'while true do' sin Wait monopoliza el hilo. Mete un Wait(0) (o mayor) al final del bucle.
Tu servidor va a tirones. Ordena los pasos para encontrar el recurso culpable.
Coloca las líneas en el orden correcto con las flechas.
Revisa su código: busca bucles sin Wait o MySQL por frameMira qué recurso está en amarillo o rojo (ms altos)Quita ese recurso y comprueba si mejora el rendimientoAbre la consola (F8) y escribe: resmonPista
Primero mides (resmon), luego identificas, luego aíslas, y al final corriges la causa.
Challenge: code it yourself
Your server is stuttering. Describe the step-by-step plan to find which resource is causing it.
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
resmon → look at ms per resource → isolate by removing resources → check Wait(0) and MySQL per frame.
Escribe aquí tu solución:
