The most optimized lock door that you can found made for fivem standalone.
Now there is an other way of doing this system using NATIVE, since i'm not working anymore on fivem i really insist to use the new way of doing it. here is a good tutorial : https://forum.cfx.re/t/guide-lock-doors-like-a-boss-how-to-use-gtas-built-in-door-locking-system/
issue know with my version is that if you run or move to fast in front a closed door you can go through even if it's closed seem because of the radius check so up it if needed.