FiveM Loading Screen ค้าง แก้อย่างไร โหลด 100% แล้วไม่เข้าเกม
ปัญหา FiveM Loading Screen ค้าง, โหลดถึง 100% แล้วไม่เข้าเกม, หน้า Loading ไม่ยอมหาย, จอดำหลัง Loading Screen หรือค้างหน้าเข้าเซิร์ฟเวอร์ ไม่ควรแก้ด้วยการล้าง Cache หรือเปลี่ยน Loading Screen ทันที เพราะต้นเหตุอาจอยู่คนละ Layer ตั้งแต่ Client Connection → Resource Loading → NUI → loadProgress → Character/Spawn → Manual Shutdown
FiveM ใช้ Loading Screen เป็น NUI Frame พิเศษ และเมื่อเปิด loadscreen_manual_shutdown 'yes' หน้า Loading NUI จะไม่ปิดเองหลังโหลด Game Data แต่ต้องถูกปิดด้วย SHUTDOWN_LOADING_SCREEN_NUI.
ดังนั้นอาการ
100%แต่หน้าโหลดไม่หาย
อาจไม่ได้หมายความว่า “FiveM ยังโหลดอยู่” เสมอไป แต่อาจเป็น Loading Screen NUI ที่ไม่ได้ถูก Shutdown
บทความนี้จาก comsiam จะไล่หาต้นเหตุแบบเป็นขั้นตอนเพื่อให้รู้ว่าปัญหาค้างอยู่ตรงไหนจริง
① แยกก่อนว่า Loading Screen ค้างแบบไหน
อาการหลัก ๆ แบ่งได้เป็น
① ยังไม่เห็น Custom Loading Screen② Custom Loading Screen ขึ้นแต่เปอร์เซ็นต์ไม่เดิน③ ค้างที่เปอร์เซ็นต์ใดเปอร์เซ็นต์หนึ่ง④ โหลดถึง 100% แต่หน้าไม่หาย⑤ Loading Screen หายแล้วจอดำ⑥ เข้าเกมแล้วแต่ Loading Screen ยังทับอยู่⑦ Character Selection ไม่ขึ้น⑧ Player ไม่ Spawn⑨ Loading Screen หายแต่เพลงยังเล่น
แต่ละอาการมี Root Cause คนละกลุ่ม
② ถ้ายังไม่เห็น Custom Loading Screen เลย
ให้ตรวจ
Resource Startfxmanifest.lualoadscreenHTML PathResource FilesConnection
ก่อน
FiveM Resource Manifest ใช้ loadscreen เพื่อกำหนด HTML File ของ Loading Screen และ Local Resource Files ต้องถูกเพิ่มเข้า Resource Packfile หาก Client ต้องใช้ไฟล์เหล่านั้น.
③ ถ้าค้างก่อนเข้า Custom Loading Screen
กรณีนี้อาจยังไม่ใช่ปัญหา HTML/CSS/JavaScript ของ Loading Screen
ให้แยก
FiveM ClientConnectionServerFirewallAntivirus
ออกจาก Custom Loadscreen ก่อน
Cfx.re มีเอกสาร Client Issues และ Server Issues แยกสำหรับปัญหาที่เกิดก่อน Resource/UI ของ Server ทำงาน.
④ เปิด F8 ก่อนแก้
FiveM Client Console เปิดด้วย
F8
และ Cfx.re ระบุว่า Console Commands ใช้สำหรับพัฒนาและ Debug Resource Issues ได้.
ดู Error ที่เกิดขณะ
ConnectingLoading ResourceOpening NUISpawning
ก่อนเปลี่ยนไฟล์แบบสุ่ม
⑤ ถ้า HTML ขึ้น แปลว่าอะไร
หาก Custom Background, Logo หรือข้อความปรากฏ
แปลอย่างน้อยว่า
Loading Screen Resource↓loadscreen↓HTML
เริ่มทำงานแล้ว
ดังนั้นถ้า Progress ไม่เดิน ควรตรวจ JavaScript/Event Layer ต่อ ไม่ต้องย้อนแก้ทุกอย่างตั้งแต่ Manifest ทันที
⑥ Loading Progress ของ FiveM คืออะไร
FiveM มี Event ชื่อ
loadProgress
ซึ่งถูกส่งเมื่อ Loading Progress เปลี่ยน และมีค่า
loadFraction
ตั้งแต่ 0 ถึง 1.
เช่น
0.25 = 25%0.50 = 50%0.75 = 75%1.00 = 100%
⑦ JavaScript สำหรับตรวจ loadProgress
ตัวอย่าง
window.addEventListener('message', function(event) {if (event.data.eventName !== 'loadProgress') {return;}console.log('loadFraction:',event.data.loadFraction);});
รูปแบบ Event Data ของ FiveM มี eventName: 'loadProgress' และ loadFraction.
⑧ Progress Bar ไม่เดิน แต่ Console มีค่าเปลี่ยน
ถ้า Console แสดง
0.350.400.550.80
แสดงว่า FiveM ส่ง Progress Event เข้ามาแล้ว
ให้ตรวจ
JavaScriptDOM SelectorCSS WidthPercentage Calculation
แทน Server Loading
⑨ Progress Bar อยู่ 0 แต่ loadFraction เปลี่ยน
ตัวอย่าง Bug
HTML มี
<div id="progress-bar"></div>
แต่ JavaScript ใช้
document.getElementById('loading-bar')
ชื่อไม่ตรงกัน
FiveM Event ทำงาน แต่ UI ไม่ Update
⑩ วิธีทำ Progress แบบถูกต้อง
window.addEventListener('message', function(event) {if (event.data.eventName !== 'loadProgress') {return;}const fraction = event.data.loadFraction;const percent = Math.floor(fraction * 100);document.getElementById('progress-bar').style.width = percent + '%';document.getElementById('progress-text').textContent = percent + '%';});
เพราะ loadFraction เป็น Fraction ระหว่าง 0–1.
⑪ อย่าใช้เปอร์เซ็นต์ปลอมแก้ปัญหา
เช่น
setInterval(function() {progress++;}, 100);
ทำให้
UI = 100%
ไม่ได้บอกว่า FiveM โหลดเสร็จจริง
ถ้าต้องการ Progress ที่สัมพันธ์กับ FiveM ให้ใช้ loadProgress.
⑫ ค้างที่ 30%, 50% หรือ 80% หมายความว่าอะไร
จากมุมของ Loading Screen หมายความเพียงว่า loadProgress ยังไม่ได้รายงานค่าที่สูงขึ้นต่อ
แต่ไม่ควรสรุปทันทีว่า HTML เป็นสาเหตุ
ต้องดูร่วมกับ
F8Server ConsoleResource LoadingClient Connection
เพราะ loadProgress เป็นเพียง Event ที่รายงาน Progress State มายัง UI.
⑬ ค้าง 100% สำคัญที่สุด
ถ้า
loadFraction = 1.0
แต่ Loading Screen ยังทับหน้าจอ
ให้ตรวจ
loadscreen_manual_shutdownSHUTDOWN_LOADING_SCREEN_NUISpawn FlowCharacter Flow
ก่อน
เพราะ Manual Shutdown จะป้องกัน Loading Screen NUI จากการปิดเองหลัง Game Data Load.
⑭ loadscreen_manual_shutdown คืออะไร
ใน fxmanifest.lua
loadscreen_manual_shutdown 'yes'
หมายความว่า Resource ต้องควบคุมการปิด Loading Screen NUI เอง
Cfx.re ระบุว่าหลังเปิด Option นี้ สามารถปิดด้วย SHUTDOWN_LOADING_SCREEN_NUI.
⑮ ตรวจ fxmanifest.lua ก่อน
ค้นหา
loadscreen_manual_shutdown 'yes'
ถ้ามี
นี่คือจุดแรกที่ต้องถามว่า
แล้ว Code ส่วนไหนเป็นคน Shutdown?
⑯ ตัวอย่าง Manifest ที่ใช้ Manual Shutdown
fx_version 'cerulean'game 'gta5'loadscreen 'html/index.html'loadscreen_manual_shutdown 'yes'client_script 'client.lua'files {'html/index.html','html/style.css','html/app.js'}
loadscreen_manual_shutdown เป็น Manifest Directive ที่ FiveM รองรับปัจจุบัน.
⑰ Native Manual Shutdown รุ่นเก่าอย่าใช้
FiveM มี Native เก่าชื่อ
SET_MANUAL_SHUTDOWN_LOADING_SCREEN_NUI
แต่ Cfx.re ระบุว่า Native นี้ Deprecated และไม่ทำงานแล้ว และให้ใช้ loadscreen_manual_shutdown ใน fxmanifest แทน.
นี่สำคัญมากหากใช้ Tutorial FiveM รุ่นเก่า
⑱ SHUTDOWN_LOADING_SCREEN_NUI คืออะไร
FiveM มี Native
SHUTDOWN_LOADING_SCREEN_NUI
สำหรับปิด loadingScreen NUI Frame.
ใน Lua ใช้
ShutdownLoadingScreenNui()
⑲ ถ้าลืม ShutdownLoadingScreenNui จะเกิดอะไรขึ้น
เมื่อใช้ Manual Shutdown
Flow อาจกลายเป็น
Game Data Loaded↓Player พร้อม↓Gameplay เริ่ม↓แต่ Loading NUI ยังอยู่
ผู้เล่นจึงเห็นหน้าโหลดค้างแม้เกมด้านหลังพร้อมแล้ว
นี่เป็นผลโดยตรงจากการให้ Resource ควบคุม Loading NUI Lifetime เอง.
⑳ วิธีทดสอบว่าติดตรง Shutdown หรือไม่
สำหรับ Test Server สามารถสร้างคำสั่งชั่วคราว
RegisterCommand('closeloading', function()ShutdownLoadingScreenNui()end)
ถ้าพิมพ์คำสั่งแล้ว Loading Screen หายทันที
แสดงว่าควรตรวจ Shutdown Flow เป็นลำดับแรก
㉑ แต่ไม่ควรใช้คำสั่งนี้เป็นวิธีแก้ถาวร
คำสั่งด้านบนใช้เพื่อ Debug
Production Server ต้องรู้ว่า
เมื่อไร Player พร้อมจริง
แล้วเรียก Shutdown จาก State/Event ที่ถูกต้อง
ไม่ใช่ให้ผู้เล่นพิมพ์คำสั่งเอง
㉒ SHUTDOWN_LOADING_SCREEN ต่างจาก SHUTDOWN_LOADING_SCREEN_NUI อย่างไร
FiveM มี
SHUTDOWN_LOADING_SCREEN
สำหรับปิด Game Loading Screen และเปลี่ยนเข้าสู่ Normal Game View โดย Cfx.re ระบุว่าควรใช้โดย spawnmanager หรือ Resource ลักษณะเดียวกันหลัง Player โหลดและ Spawn แล้ว.
ส่วน
SHUTDOWN_LOADING_SCREEN_NUI
เน้นปิด loadingScreen NUI Frame.
อย่าสับสนสอง Layer นี้
㉓ Loading Screen NUI กับ Game Loading Screen ไม่ใช่สิ่งเดียวกันทั้งหมด
นี่เป็นเหตุผลที่บางครั้ง Developer ปิด NUI แล้วแต่ยังเห็น Transition/Game Loading อื่นอยู่
หรือในทางกลับกัน
Gameplay พร้อมแล้วแต่ NUI ยังทับอยู่
ต้องดูว่า Code กำลังควบคุม Layer ไหนอยู่.
㉔ Loading Screen ควรปิดเมื่อไร
Cfx.re ระบุว่า SHUTDOWN_LOADING_SCREEN ควรถูกใช้โดย Spawn Manager หรือ Resource ลักษณะเดียวกัน หลัง Loading และ Player Spawn.
สำหรับ Custom Server จึงควรเชื่อมกับ State จริง เช่น
Player Data ReadyCharacter ReadySpawn Ready↓Shutdown
㉕ อย่าใช้ Wait(10000) แล้วคิดว่า Player พร้อม
ตัวอย่างที่ไม่เหมาะเป็น Logic หลัก
Wait(10000)ShutdownLoadingScreenNui()
เหตุผลคือ
10 วินาทีผ่าน
ไม่ได้พิสูจน์ว่า
Player Spawn สำเร็จ
ควรผูก Shutdown กับ Character/Spawn Event ที่ Server ใช้งานจริง โดย spawnmanager เองถูกออกแบบมาให้ควบคุมว่า Player จะ Spawn เมื่อไรและที่ไหน.
㉖ Spawnmanager คืออะไร
spawnmanager เป็น Base Resource ของ Cfx.re ที่จัดการการ Spawn ของ Player และเปิดให้กำหนดได้ว่า Player จะ Spawn เมื่อไรและที่ไหน.
ดังนั้น Server ที่มี Custom Multicharacter/Spawn System ต้องดูว่าระบบใดเป็น Owner ของ Spawn Flow
㉗ Loading Screen 100% แต่ Player ยังไม่ Spawn
ตรวจ
Character DataSpawn EventSpawnmanagerCustom Spawn ResourceFramework Player Loaded
ก่อน
หน้าโหลดอาจกำลังรอ State ฝั่ง Gameplay ไม่ใช่ Resource Files อีกแล้ว
㉘ Character Selection ไม่ขึ้นหลัง Loading
Flow อาจเป็น
Loading Screen↓ควรเปิด Character Selection↓Character Resource Error↓ไม่มีหน้า Character↓Loading Screen ยังอยู่
กรณีนี้ Root Cause อาจเป็น Character Resource ไม่ใช่ Loading Screen HTML
㉙ Multicharacter Server ต้องกำหนด State ชัด
ตัวอย่าง
CONNECTING↓LOADING↓CHARACTER_SELECT↓SPAWNING↓READY↓GAMEPLAY
แล้วกำหนดว่า Loading Screen จะถูกปิดตรง State ใด
หากหลาย Resources เป็นคนสั่ง State พร้อมกัน จะ Debug ยากมาก
㉚ Loading Screen หายแล้วจอดำ
ถ้า NUI หาย แต่หน้าจอเป็นสีดำ
แสดงว่า Loading NUI ไม่ใช่สิ่งเดียวที่ต้องตรวจแล้ว
ให้ดู
Player SpawnCameraScreen FadeCharacter ResourcePedPosition
โดยเฉพาะ Spawn System เพราะ Cfx.re แยก spawnmanager เป็น Resource สำหรับควบคุม Player Spawn โดยเฉพาะ.
㉛ อย่าเปิด Loading Screen กลับมาเพื่อปิดบังจอดำ
หาก Root Cause คือ Player ไม่ Spawn
การยืด Loading Screen ให้นานขึ้นแค่ซ่อนปัญหา
ต้องแก้ Spawn/Character Flow
㉜ เข้าเกมแล้วแต่ Loading Screen ยังทับอยู่
นี่เป็นอาการคลาสสิกของ
Manual NUI Shutdown
ให้ทดสอบ ShutdownLoadingScreenNui() และตรวจ Event ที่ควรเรียกมัน.
㉝ Loading Screen หายเร็วเกินไป
กรณีตรงข้าม
ถ้า Shutdown เกิดก่อน
Character Data ReadyPlayer SpawnCamera Ready
ผู้เล่นอาจเห็น
Map โหลดไม่เสร็จPed ยังไม่พร้อมจอดำCamera แปลก
จึงควร Shutdown ตาม State จริง ไม่ใช่เร็วที่สุดเท่าที่ทำได้
㉞ Manual Shutdown เหมาะกับอะไร
Official Loading Screen Documentation ระบุว่า Manual Shutdown สามารถใช้กับ
Custom Fade-outEarly-game Spawn Selection UI
ได้.
ดังนั้น Feature นี้เหมาะเมื่อ Server ต้องควบคุม Transition จริง ๆ
㉟ ถ้าไม่ต้องใช้ Manual Shutdown ควรปิดไหม
ถ้า Resource ไม่ได้ต้องการ
Custom Spawn TransitionCharacter Selection IntegrationCustom Fade
การลด Complexity เป็นสิ่งที่ควรพิจารณา
เพราะเปิด Manual Mode แล้ว Resource ต้องรับผิดชอบ NUI Shutdown เอง.
㊱ Loading Screen ค้างเพราะ JavaScript ได้ไหม
ได้
NUI ของ FiveM เป็น HTML-based UI บน Chromium Embedded Framework ดังนั้น JavaScript Error สามารถทำให้ Progress, Animation หรือ UI State ไม่อัปเดตได้.
แต่ JavaScript Error ไม่ได้หมายความว่า Game Loading หยุดเสมอไป
㊲ เปิด NUI DevTools อย่างไร
Cfx.re ระบุว่าสามารถเปิด NUI Developer Tools ด้วย
nui_devTools
จาก F8 Console เมื่อ Developer Mode เปิดใช้งาน.
ใช้ตรวจ
ConsoleJavaScript ErrorsDOMCSSNetwork
㊳ ถ้า Progress Bar ค้างแต่ loadProgress Console ยังวิ่ง
นี่เป็น UI Bug
ให้ดู
DOM ElementCSSJS Handler
ไม่ต้องไป Restart Database หรือ Server Framework ก่อน
㊴ ถ้า loadProgress Event หยุดจริง
ดู F8 และ Server Console ต่อ
เพราะ UI เพียงรับ Event ที่ FiveM ส่งมา
ถ้า Event ไม่เดินต่อ สาเหตุอาจอยู่ก่อน Presentation Layer นั้น นี่เป็นการอนุมานจากบทบาทของ loadProgress ซึ่งเป็น Event รายงาน Progress ไม่ใช่ตัวทำ Loading เอง.
㊵ Background โหลดไม่เสร็จทำให้ดูเหมือนค้าง
ถ้า HTML แสดงแต่
BackgroundMusicVideoFonts
ยังไม่มา
ให้ตรวจ Asset Loading แยก
FiveM Manifest ใช้ file/files เพิ่ม Local Assets เข้า Resource Packfile สำหรับ Client.
㊶ ลืมใส่ไฟล์ใน files
ตัวอย่าง Manifest
files {'html/index.html','html/style.css','html/app.js','html/background.webp'}
ถ้า Local Asset ที่หน้า Loadscreen ต้องใช้ไม่อยู่ใน Resource Packfile อาจทำให้ UI โหลดไม่ครบ.
㊷ External Assets ทำให้หน้าโหลดดูค้างได้ไหม
มีโอกาสหากหน้า Loading Screen พึ่งไฟล์หรือบริการภายนอกที่ตอบช้า
สำหรับ Debug ให้ทำ A/B Test
External Video OFFExternal Font OFFExternal Music OFF
แล้วดูว่า Core Loading Screen ยังมีปัญหาหรือไม่
㊸ อย่าสับสน UI Asset ช้ากับ Server Resource ช้า
แยก
HTML/Media Loading
ออกจาก
FiveM Game/Resource Loading
โดยใช้ loadProgress, F8 และ NUI DevTools ช่วยดูแต่ละ Layer.
㊹ Video Background กระตุกไม่ได้แปลว่า Server ค้าง
หาก
Video กระตุกแต่ loadProgress เดิน
อาจเป็น NUI/Media Rendering Problem
ไม่ใช่หลักฐานว่า FXServer หยุดทำงาน
NUI ใช้ Chromium-based Web UI จึงมี Rendering Layer ของตัวเอง.
㊺ เพลงเล่นแต่เปอร์เซ็นต์ค้าง
แปลเพียงว่า Audio/UI Process ยังทำงาน
ต้องตรวจ loadProgress Event และ Connection/Resource State ต่อ
อย่าใช้เพลงเล่นได้เป็นหลักฐานว่า Loading Process ทั้งหมดปกติ
㊻ Loading Screen หายแต่เพลงยังเล่น
ตรวจ JavaScript Audio Lifecycle
เช่น
audio.pause();audio.currentTime = 0;
ใน Transition Logic หาก Resource ออกแบบให้จัดการ Audio เอง
กรณีนี้เป็น Web UI Cleanup มากกว่า Game Loading State
㊼ Fade Out ค้างทำให้เหมือนหน้าโหลดไม่ปิด
ตัวอย่าง Flow
Player Ready↓Send Fade Message↓CSS Fade↓ควร Shutdown NUI
ถ้า Fade Message ทำงานแต่ขั้น Shutdown ไม่เกิด Loading Screen อาจเหลือ Element โปร่งใสทับ Gameplay อยู่
Manual Shutdown Documentation ระบุว่าสามารถใช้ Feature นี้เพื่อทำ Custom Fade-out ได้.
㊽ อย่าใช้ CSS opacity: 0 แทน Shutdown
การทำ
opacity: 0;
เพียงซ่อน UI
ไม่ได้ปิด loadingScreen NUI Frame
หากใช้ Manual Shutdown ควรปิด Frame ด้วย SHUTDOWN_LOADING_SCREEN_NUI หลัง Transition เสร็จ.
㊾ Loading Screen โปร่งใสแต่ยังรับ Input
ถ้า UI Frame ยังมีชีวิตอยู่ แม้ Visual ถูกซ่อนด้วย CSS State ก็อาจเกิด Interaction/Lifecycle ผิดจากที่ตั้งใจ
แนวทางที่ถูกต้องคือ Cleanup UI State แล้ว Shutdown Frame เมื่อไม่ต้องใช้งานแล้ว.
㊿ Resource Start Order เกี่ยวได้ไหม
ถ้า Custom Loading/Character System อาศัย Events จาก Resource อื่น
ต้องตรวจว่า Dependency นั้นพร้อมก่อน Flow ที่รออยู่
โดยเฉพาะ
FrameworkCharacterSpawnSession
หาก Loading Screen รอ Event ที่ไม่เคยเกิด มันสามารถค้างจาก Logic ของ Resource ได้
51. Event ชื่อผิดทำให้ Loading Screen ค้าง
ตัวอย่าง Client รอ
RegisterNetEvent('myserver:playerReady',function()ShutdownLoadingScreenNui()end)
แต่ Server Trigger
myserver:playerLoaded
สองชื่อไม่ตรงกัน
Result:
Player Readyแต่ Shutdown Event ไม่เคยเข้า
52. เพิ่ม print เพื่อดู Event
ตัวอย่าง
RegisterNetEvent('myserver:playerReady',function()print('[LOADSCREEN] playerReady received')ShutdownLoadingScreenNui()end)
จากนั้นเปิด F8
ถ้าไม่มี Log ให้ตรวจ Event Flow ก่อน NUI
53. onClientResourceStart ช่วย Debug ได้ไหม
FiveM มี Client Resource Events เช่น onClientResourceStart และ onClientResourceStop.
สามารถใช้ Log เพื่อยืนยันว่า Resource ที่ควบคุม Loading Screen เริ่มทำงานจริงหรือไม่
54. ตัวอย่าง Debug Resource Start
AddEventHandler('onClientResourceStart',function(resourceName)if resourceName ==GetCurrentResourceName()thenprint('[LOADSCREEN] resource started')endend)
ช่วยแยกปัญหา
Resource ไม่ Start
ออกจาก
Resource Start แต่ Logic ไม่ทำงาน
55. Loading Screen ค้างเฉพาะผู้เล่นบางคน
ให้แยก Client-specific Issue จาก Server-wide Issue
ถ้า
ทุกคนค้าง
ให้สงสัย Resource/Server Flow มากขึ้น
ถ้า
คนเดียวค้าง
ให้ตรวจ Client Console, Connection และ Client Environment เพิ่ม
Cfx.re มี Client Issues Documentation แยกสำหรับปัญหาฝั่งเครื่องผู้เล่น.
56. ทุกคนค้างพร้อมกันหลังอัปเดต Resource
นี่เป็นเบาะแสแรงว่า Update ล่าสุดควรถูกตรวจ
เช่น
Loading ScreenMulticharacterFrameworkSpawn Resource
ทำ A/B Test กับ Version ก่อนหน้าแทนการให้ผู้เล่นทุกคนล้าง Cache
57. ค้างหลังเปลี่ยน Loading Screen ใหม่
ถ้า Server เดิม
Old Loadscreen→ เข้าได้
แล้วเปลี่ยนเป็น
New Loadscreen→ ค้าง
ตรวจโดยเฉพาะ
loadscreen_manual_shutdownclient.luaCustom EventsExternal Assets
ก่อน
58. Loading Screen ที่ซื้อมาอาจมี Spawn Logic
อย่าคิดว่า Resource Loading Screen ทุกตัวมีแค่ HTML
บางตัวอาจมี
Client LuaManual ShutdownFramework IntegrationCharacter Events
จึงควรอ่าน fxmanifest.lua และ Client Scripts ก่อนติดตั้ง
59. ปัญหาหลัง Rename Resource
หาก Script สร้าง Event/Path/Resource Name แบบ Hard-coded
การเปลี่ยนชื่อ Folder อาจทำให้ Integration ผิด
หากปัญหาเริ่มหลัง Rename ให้ย้อนชื่อเดิมเพื่อ A/B Test
60. Loading Screen ค้างหลัง Restart Resource
ต้องระวัง Lifecycle
Loading Screen ถูกออกแบบสำหรับช่วง Initial Connection เป็นหลัก
การ Restart Resource ระหว่าง Player อยู่ในเกมอาจไม่จำลอง Connection Lifecycle แบบเริ่มใหม่ทั้งหมด
ดังนั้นทดสอบ Production Flow ด้วยการ Reconnect จริงด้วย
61. Restart Server กับ Restart Loading Resource ไม่เหมือนกัน
การ
restart loadscreen
ทดสอบ Resource Lifecycle
แต่การ
Reconnect Player
ทดสอบ Connection + Loading Screen Lifecycle
ปัญหาบางอย่างปรากฏเฉพาะตอน Connect
62. ใช้ connect จาก F8 ทดสอบได้
Cfx.re Server Issues Documentation แนะนำ Direct Connect ผ่าน F8 ด้วยคำสั่ง connect IP:Port สำหรับตรวจการเชื่อมต่อโดยตรง.
เหมาะกับ Test Server ที่คุณควบคุม
63. Server Console ต้องดูด้วย
F8 บอกปัญหา Client
แต่ Character/Framework/Server Events อาจ Error อยู่ฝั่ง Server
ดังนั้นต้องดู
Client F8+Server Console
พร้อมกัน
โดยเฉพาะตอน Player Connecting/Loading/Spawning
64. ถ้า Server Script Error ก่อน Player Ready
Loading Screen อาจเป็นเพียงหน้าสุดท้ายที่ผู้เล่นเห็น
แต่ Root Cause อยู่ที่ Script ซึ่งควรส่ง
Player Ready
แล้วไม่เคยส่ง
จึงต้อง Debug Event Chain ไม่ใช่แก้ CSS
65. Profiler จำเป็นไหม
ถ้าปัญหาเป็น “ค้างจริง ๆ” เพราะ Resource ใช้เวลาประมวลผลสูงผิดปกติ สามารถใช้ FiveM Profiler ช่วยหา Code/Threads ที่ใช้เวลามากได้
Cfx.re แนะนำเริ่มด้วย
profiler record 500
เพื่อเก็บ Frames สำหรับวิเคราะห์.
66. แต่ Profiler ไม่ใช่ขั้นแรกทุกครั้ง
ถ้า Error ชัดเจนว่า
ShutdownLoadingScreenNuiไม่เคยถูกเรียก
ไม่จำเป็นต้อง Profile ก่อน
ใช้เครื่องมือให้ตรงกับปัญหา
67. วิธี Debug Loading Screen ค้างแบบเร็วที่สุด
ขั้นที่ 1 — เปิด F8
ดู Client Errors.
ขั้นที่ 2 — ดู Progress Event
Log
loadFraction
ว่าขยับถึง 1.0 หรือไม่.
ขั้นที่ 3 — ถ้าไม่ถึง 1.0
ตรวจ Resource/Connection/Client Errors ต่อ
ขั้นที่ 4 — ถ้าถึง 1.0
ตรวจ
loadscreen_manual_shutdown
ทันที.
ขั้นที่ 5 — ถ้าเปิด Manual Shutdown
ค้นหา
ShutdownLoadingScreenNui
ใน Resource.
ขั้นที่ 6 — ใส่ Log ใน Player Ready Event
ตรวจว่า Event ถูก Trigger หรือไม่
ขั้นที่ 7 — ตรวจ Character/Spawn
spawnmanager มีหน้าที่ควบคุม Player Spawn จึงควรตรวจ Spawn Flow หากหน้าโหลดรอ Player Ready.
ขั้นที่ 8 — เปิด NUI DevTools
ตรวจ JavaScript/CSS ผ่าน nui_devTools.
ขั้นที่ 9 — ลด External Assets
ทดสอบ Video/Music/Fonts ออกชั่วคราว
ขั้นที่ 10 — A/B Test Version เดิม
ถ้าปัญหาเกิดหลัง Update
68. ตารางสรุป FiveM Loading Screen ค้าง
| อาการ | จุดที่ควรตรวจ |
|---|---|
| Custom Loading ไม่ขึ้น | Resource / Manifest |
| HTML ขึ้นแต่ Progress 0 | JS / loadProgress |
| Progress ค้างกลางทาง | F8 / Resource / Connection |
| ถึง 100% แต่ไม่หาย | Manual Shutdown |
| เข้าเกมแล้ว Loading ยังทับ | Shutdown NUI |
| Loading หายแล้วจอดำ | Spawn / Character / Camera |
| Character Selection ไม่ขึ้น | Character Resource |
| Fade เสร็จแต่หน้ายังค้าง | NUI Shutdown |
| Background ไม่มา | Resource Files / Path |
| Video กระตุก | NUI/Media |
| เพลงยังเล่นหลังเข้าเกม | Audio Cleanup |
| ค้างเฉพาะบางคน | Client-specific issue |
| ทุกคนค้างหลัง Update | Server/Resource Regression |
| Resource ใหม่ค้าง ตัวเก่าไม่ค้าง | New Loadscreen Logic |
69. Checklist fxmanifest.lua
☐ loadscreen ถูก☐ HTML Path ถูก☐ files ครบ☐ client_script ถูก☐ loadscreen_manual_shutdown ตรวจแล้ว☐ ไม่ใช้ Manual Shutdown Native รุ่นเก่า
ปัจจุบัน Cfx.re ให้ใช้ loadscreen_manual_shutdown แทน Deprecated Manual Shutdown Native.
70. Checklist JavaScript
☐ ไม่มี Console Error☐ message listener ทำงาน☐ eventName = loadProgress☐ loadFraction เปลี่ยน☐ DOM ID ถูก☐ Progress Calculation ถูก☐ Fade Event ถูก☐ Audio Cleanup ถูก
loadProgress ส่ง loadFraction ตั้งแต่ 0 ถึง 1.
71. Checklist Manual Shutdown
☐ เปิด Manual Shutdown โดยตั้งใจ☐ Player Ready Event มีจริง☐ Event ถูก Trigger☐ Client รับ Event☐ ShutdownLoadingScreenNui ถูกเรียก☐ Shutdown ไม่เร็วเกิน Spawn☐ Fade แล้ว Shutdown จริง
SHUTDOWN_LOADING_SCREEN_NUI มีหน้าที่ปิด Loading Screen NUI Frame โดยตรง.
72. Checklist Spawn
☐ Character Loaded☐ Player Data Ready☐ Ped พร้อม☐ Spawn Event ทำงาน☐ Coordinates ถูก☐ Camera State ถูก☐ Screen Fade State ถูก☐ Gameplay เริ่มแล้ว
spawnmanager ถูกออกแบบมาสำหรับการกำหนดเวลาและสถานที่ Spawn ของ Player จึงเป็นหนึ่งใน Layer ที่ควรตรวจเมื่อ Loading Screen รอ Spawn State.
73. ตัวอย่าง Manual Shutdown ที่อ่านง่าย
fxmanifest.lua
fx_version 'cerulean'game 'gta5'loadscreen 'html/index.html'loadscreen_manual_shutdown 'yes'client_script 'client.lua'files {'html/index.html','html/style.css','html/app.js'}
Client
RegisterNetEvent('myserver:playerReady',function()print('[LOADSCREEN] playerReady')ShutdownLoadingScreenNui()end)
ชื่อ Event เป็นเพียงตัวอย่าง ส่วน Manual Shutdown Directive และ SHUTDOWN_LOADING_SCREEN_NUI เป็นระบบที่ FiveM รองรับ.
74. ตัวอย่าง Debug Progress
window.addEventListener('message',function(event) {if (event.data.eventName=== 'loadProgress') {console.log('[LOADSCREEN]',event.data.loadFraction);}});
ถ้าค่าสุดท้ายคือ
1
แต่หน้ายังค้าง ให้เปลี่ยนโฟกัสการ Debug ไปที่ Shutdown/Spawn Flow.
75. ตัวอย่าง Fade แล้ว Shutdown
Flow ที่ดีกว่า
Player Ready↓Send Fade Command↓CSS Fade Out↓Fade Complete↓Shutdown Loading NUI
เพราะ Manual Shutdown ถูกออกแบบมาให้ใช้กับ Custom Fade Transition ได้.
76. อย่าทำ Loading Screen เป็นคนตัดสิน Gameplay State
Loading UI ควรรับสถานะจากระบบหลัก
เช่น
Character System↓PLAYER READY↓Loading Screen ปิด
ไม่ควรให้ JavaScript เดาเองว่า
เปอร์เซ็นต์ = 100↓Character ต้องพร้อม
เพราะ loadProgress เป็น Loading Progress Event ไม่ใช่ Character Ready Event.
77. อย่าแก้ด้วย Cache ก่อนดู Error
ถ้า Root Cause คือ
loadscreen_manual_shutdown 'yes'
แต่ไม่มี
ShutdownLoadingScreenNui()
การล้าง Cache ไม่แก้ Logic นี้
เริ่มจาก Code และ Lifecycle ก่อน
78. อย่าลบ Loading Screen ทันที
หากหน้าโหลดค้างเพราะ
Character Event ไม่มา
เปลี่ยน Loading Screen ใหม่ก็อาจค้างเหมือนเดิม
เพราะ Root Cause อยู่ Resource อื่น
79. อย่าลด Video Quality ถ้าปัญหาคือ 100% ค้าง
Video Optimization ช่วยเรื่อง UI Rendering/Asset Size
แต่ถ้า
loadFraction = 1.0Player Spawn แล้วLoading NUI ยังอยู่
ให้แก้ Shutdown Logic
อย่าผสมสองปัญหาเข้าด้วยกัน
80. สูตรจำง่ายเมื่อ FiveM Loading Screen ค้าง
CONNECT↓LOAD↓PROGRESS↓CHARACTER↓SPAWN↓SHUTDOWN↓GAMEPLAY
ถามทีละขั้นว่า
หยุดตรงไหน?
แล้วแก้เฉพาะ Layer นั้น
สรุป FiveM Loading Screen ค้าง แก้อย่างไร
ถ้า FiveM Loading Screen ค้าง สิ่งแรกที่ควรทำคือแยกว่า Progress ของ FiveM ยังเดินอยู่หรือไม่
Loading Screen ได้รับ
loadProgress
พร้อม
loadFraction
ตั้งแต่ 0–1 ดังนั้นสามารถ Log ค่านี้เพื่อตรวจว่า FiveM รายงาน Loading Progress ถึง 1.0 แล้วหรือยัง.
ถ้า Progress ยังไม่ถึง 100% ให้ตรวจ F8, Connection, Resource Loading และ Server Console ต่อ เพราะ Loading Screen เป็นเพียง UI ที่รับ Progress State มาจาก FiveM.
แต่ถ้า Progress ถึง 100% แล้ว Loading Screen ยังไม่หาย ให้ตรวจทันทีว่า fxmanifest.lua มี
loadscreen_manual_shutdown 'yes'
หรือไม่ เพราะ Option นี้ทำให้ Loading Screen NUI ไม่ปิดเองหลัง Game Data Load.
ถ้ามี ต้องมี Flow ที่เรียก
ShutdownLoadingScreenNui()
เมื่อ Player/Character พร้อม เพราะ SHUTDOWN_LOADING_SCREEN_NUI มีหน้าที่ปิด loadingScreen NUI Frame โดยตรง.
อย่าใช้ Native Manual Shutdown รุ่นเก่าจาก Tutorial เก่า เพราะ Cfx.re ระบุว่า SET_MANUAL_SHUTDOWN_LOADING_SCREEN_NUI ถูก Deprecated และให้ใช้ loadscreen_manual_shutdown ใน Resource Manifest แทน.
ถ้า Loading Screen หายแล้วจอดำหรือ Character ไม่ขึ้น ให้ตรวจ Spawn/Character Layer เพราะ spawnmanager เป็น Resource ที่จัดการว่า Player จะ Spawn เมื่อไรและที่ไหน.
ถ้า Progress UI ไม่ขยับแต่ Game ยังโหลด ให้เปิด NUI Developer Tools ผ่าน nui_devTools จาก F8 เมื่อ Developer Mode เปิด และตรวจ JavaScript, DOM และ CSS.
ถ้า โหลดค้างหลังเปลี่ยน Loading Screen ใหม่ ให้ A/B Test ตัวเก่ากับตัวใหม่ โดยเน้นตรวจ fxmanifest.lua, Manual Shutdown, Client Events และ External Assets ก่อน
และถ้า ทุกอย่างดูถูกแต่ Resource ใช้เวลาประมวลผลผิดปกติ FiveM มี Profiler ซึ่งสามารถเริ่มจาก profiler record 500 เพื่อช่วยหาว่า Code/Thread ใดใช้เวลามาก.
แนวทางของ comsiam คืออย่ามองคำว่า “Loading Screen ค้าง” เป็นปัญหาเดียว แต่ให้แยกเป็น Connection → Progress → Character → Spawn → NUI Shutdown เพราะอาการที่ผู้เล่นเห็นเหมือนกันอาจมี Root Cause ต่างกันโดยสิ้นเชิง โดยเฉพาะอาการโหลดถึง 100% แล้วไม่เข้าเกม ซึ่งควรตรวจ Manual Shutdown และ Spawn Flow ก่อนล้าง Cache หรือเปลี่ยน Loading Screen ใหม่ทั้งชุด
Comments
Post a Comment