วิธีสร้าง FiveM Server ด้วย txAdmin Recipe ตั้งแต่ศูนย์จนเข้าเล่นได้
การสร้าง FiveM Server ด้วย txAdmin Recipe เป็นหนึ่งในวิธีที่ง่ายที่สุดสำหรับมือใหม่ เพราะ Recipe Deployer สามารถช่วยดาวน์โหลด Resources, สร้าง server.cfg, จัดโครงสร้าง Server และนำค่าต่าง ๆ ที่ผู้ใช้กรอกไปติดตั้งให้โดยอัตโนมัติ
สำหรับผู้ที่ต้องการเริ่มจาก Server เปล่าที่เป็นมาตรฐาน ควรเริ่มด้วย FiveM Basic Server (CFX Default) ก่อน แล้วจึงค่อยติดตั้ง ESX, QBCore, Qbox หรือ Resources อื่นเพิ่มเติมภายหลัง
ขั้นตอนโดยสรุปคือ
ดาวน์โหลด Recommended Artifact
↓
เปิด FXServer
↓
เข้า txAdmin
↓
สร้าง Server Profile
↓
เลือก Popular Recipes
↓
เลือก FiveM Basic Server
↓
Review Recipe
↓
สร้าง Server Registration Key
↓
ใส่ Input Parameters
↓
Run Recipe
↓
ตรวจ server.cfg
↓
Save & Run Server
↓
เข้า FiveM ทดสอบ
① ก่อนสร้าง FiveM Server ต้องเตรียมอะไร
ควรมีอย่างน้อย
คอมพิวเตอร์หรือ VPS
Windows หรือ Linux ที่รองรับ
Internet
Cfx.re Account
FXServer Artifact
txAdmin
Server Registration Key
พื้นที่เก็บ Server Data
ถ้าจะสร้าง RP Server ด้วย Framework อาจต้องมี Database เพิ่มด้วย
② txAdmin Recipe คืออะไร
Recipe คือไฟล์ YAML ที่บอก txAdmin ว่าต้องทำอะไรเพื่อ Deploy Server
เช่น
ดาวน์โหลด Repository
สร้าง Folder
แตก ZIP
Copy Resource
สร้าง server.cfg
ตั้ง Endpoint
ใส่ Server Key
เชื่อม Database
Import SQL
txAdmin จะ Execute Task ตามลำดับที่ Recipe กำหนด
③ ทำไมควรสร้าง Server ด้วย Recipe
ข้อดีคือช่วยลดขั้นตอน Manual
แทนที่จะต้อง
สร้าง Folder เอง
ดาวน์โหลด Resources เอง
Copy Config เอง
แก้ Path เอง
Import SQL เอง
Recipe สามารถทำหลายส่วนให้โดยอัตโนมัติ
จึงเหมาะกับทั้งมือใหม่และ Developer ที่ต้องสร้าง Environment ซ้ำ
④ ดาวน์โหลด FXServer Artifact ก่อน
เริ่มจาก Server Download ของ Cfx.re
เลือก
Latest Recommended
หรือ Recommended Build ปัจจุบันตามหน้า Download
ไม่ควรใช้ Artifact ที่ติดมากับ Server Pack เก่าหลายปี
⑤ แตก Artifact ไว้ที่ไหน
ตัวอย่าง Windows
C:\FXServer\server
ควรแยก Server Binary ออกจาก Server Data
แนวคิดคือ
C:\FXServer\server
= FXServer Binary
C:\FXServer\server-data
= Server Data / Resources / Config
ช่วยให้อัปเดต Artifact ในอนาคตง่ายขึ้น
⑥ เปิด FXServer อย่างไร
Windows FiveM แบบทั่วไปเปิด
FXServer.exe
เพื่อเริ่ม txAdmin ใน Monitor Mode
ถ้าเป็น GTAV Enhanced เอกสาร Cfx.re ปัจจุบันใช้ Executable ชื่อ
cfx-server.exe
ดังนั้นต้องใช้ไฟล์ให้ตรงกับ Server Platform ที่ติดตั้ง
⑦ เข้า txAdmin อย่างไร
หลังเปิด FXServer Browser มักเปิด txAdmin อัตโนมัติ
ถ้าไม่เปิด ให้เข้า
http://localhost:40120
เมื่อ Browser อยู่ในเครื่อง Server เดียวกัน
40120 คือ Default HTTP Port ของ txAdmin
⑧ ตั้ง txAdmin ครั้งแรก
ถ้ายังไม่เคย Setup จะมีขั้นตอนประมาณ
ใส่ PIN
↓
Link Cfx Account
↓
ตั้ง Backup Password
↓
Register
PIN จะปรากฏใน FXServer Console
ทำขั้นตอน Registration ให้เสร็จก่อนสร้าง Server
⑨ ตั้งชื่อ Server
หลัง Register แล้ว txAdmin จะเข้าสู่ Initial Server Configuration
ระบบจะให้ตั้ง
Server Name
ตัวอย่าง
My FiveM Server
หรือ
FiveM Development
สามารถแก้ชื่อที่แสดงจริงภายหลังผ่าน Configuration ได้
⑩ เลือก Deployment Type
เมื่อระบบถาม Deployment Type ให้เลือก
Popular Recipes
สำหรับการสร้าง Server ด้วย Recipe ที่มีอยู่แล้ว
เหมาะกว่าการเริ่ม Custom Configuration สำหรับมือใหม่
⑪ Popular Recipes มีอะไร
รายการสามารถเปลี่ยนได้ตามช่วงเวลา แต่ Repository ทางการของ txAdmin ปัจจุบันมี Recipe ยอดนิยม เช่น
FiveM Basic Server
ESX Legacy
Qbox
QBCore Framework
และ Template อื่นตามรายการที่ Cfx.re/ผู้พัฒนา Framework รองรับ
สำหรับบทความนี้เราจะใช้ Basic Server
⑫ มือใหม่ควรเลือก Recipe ไหน
เลือก
FiveM Basic Server (CFX Default)
หรือ CFX Default FiveM ที่หน้า UI แสดง
นี่คือ Server ขั้นพื้นฐานที่ไม่มี Framework RP ขนาดใหญ่ติดมาด้วย
เหมาะสำหรับพิสูจน์ก่อนว่า FiveM Server ทำงานถูกต้อง
⑬ ทำไมไม่ควรเริ่มด้วย ESX หรือ QBCore ทันที
สามารถทำได้ แต่จะเพิ่มตัวแปร เช่น
Database
Framework
Dependencies
SQL
Resources จำนวนมาก
ถ้าเปิด Server ไม่ได้ จะไม่รู้ว่าปัญหาอยู่ตรงไหน
สำหรับมือใหม่ควรใช้
CFX Default
↓
ทดสอบเข้าได้
↓
Backup
↓
ค่อยเพิ่ม Framework
จะ Debug ง่ายกว่า
⑭ Data Location คืออะไร
txAdmin จะถามตำแหน่งสำหรับ Deployment
นี่คือ Folder ที่ Recipe จะสร้าง Server Data ลงไป
สำหรับ Server ใหม่และมือใหม่ สามารถใช้ตำแหน่งที่ระบบแนะนำก่อน หากไม่มีเหตุผลต้องเปลี่ยน
ควรหลีกเลี่ยงการเลือก Folder ที่มี Production Server เดิมอยู่แล้ว
⑮ อย่า Deploy Recipe ทับ Server เดิม
ก่อนกด Save ตรวจ Path ให้ดี
สมมุติ Production อยู่ที่
C:\FXServer\production
ไม่ควรเลือก Folder นี้เป็น Target สำหรับ Recipe ใหม่โดยไม่ตั้งใจ
ควรสร้าง Folder แยก เช่น
C:\FXServer\development
เพื่อป้องกันไฟล์เดิมถูกเปลี่ยน
⑯ เข้า Recipe Deployer
หลังเลือก Recipe และ Data Location แล้ว กด
Go to Recipe Deployer
จากนั้นจะเข้าสู่ขั้นตอน Review Recipe
นี่เป็นจุดที่ควรดูว่า Recipe กำลังจะทำอะไร
⑰ Review Recipe คืออะไร
Recipe Deployer จะแสดง YAML ของ Recipe ให้ตรวจ
อาจพบ Action เช่น
download_github
download_file
remove_path
ensure_dir
write_file
ถ้าใช้ CFX Default จาก Source ทางการ ปกติสามารถดำเนินการตามคู่มือ Cfx.re ได้
แต่ Recipe จากบุคคลภายนอกควรอ่านให้ละเอียด
⑱ CFX Default Recipe ทำอะไรบ้าง
Recipe FiveM Basic Server ปัจจุบันทำสิ่งสำคัญ เช่น
ดาวน์โหลด cfx-server-data resources
↓
นำ Resources ไปยัง ./resources
↓
จัดการ Resource ที่ไม่ใช้
↓
ดาวน์โหลด server.cfg
จึงสร้าง Minimal FiveM Server ที่พร้อมนำไปเปิดได้
⑲ Recipe ทำ server.cfg ให้ไหม
ทำ
CFX Default Recipe ดาวน์โหลด Default server.cfg มาไว้ใน Target Folder
หลัง Deployment จึงควรมี
server.cfg
resources/
txAdmin ยังตรวจสองสิ่งนี้ตอนจบ Deployment เพื่อยืนยันโครงสร้างพื้นฐาน
⑳ กด Next หลัง Review Recipe
หากตรวจ Recipe แล้วถูกต้อง ให้กด
Next
ระบบจะเข้าสู่
Input Parameters
ตรงนี้จะรับค่าที่ Recipe จำเป็นต้องใช้
㉑ Server Registration Key คืออะไร
FiveM Server ต้องใช้ Server Registration Key เพื่อ Register กับระบบ Cfx.re
ใน Recipe มี Context Variable
svLicense
ใช้รับ Server Key ที่ผู้ใช้กรอก
จากนั้น Recipe Deployer สามารถนำค่าไปแทนใน server.cfg ให้
㉒ สร้าง Server Key ที่ไหน
ใน Input Parameters ของ txAdmin จะมี Link ไปยัง Cfx Portal ตามขั้นตอน Setup ทางการ
ดำเนินการประมาณ
เปิด Portal
↓
Login Cfx
↓
Create a key
↓
ตั้ง Display Name
↓
Generate
↓
Copy Key
นำ Key กลับมาใส่ใน Recipe Deployer
㉓ ตั้งชื่อ Server Key อย่างไรดี
ควรตั้งให้รู้ว่าใช้กับ Server ใด
ตัวอย่าง
FiveM Development
หรือ
FiveM Production
หลีกเลี่ยงชื่อกว้าง ๆ เช่น key1 หากมีหลาย Server เพราะภายหลังจะจำยาก
㉔ Server Key ต้องเก็บเป็นความลับ
ควร
อย่านำ Server Key จริงไปโพสต์ใน
Discord Public
Facebook
GitHub Public
Forum
Screenshot
Tutorial
หากแชร์ server.cfg ควรปิดบัง Key
ตัวอย่าง
sv_licenseKey "YOUR_SERVER_KEY"
㉕ ใส่ Server Key ใน Recipe
กลับมาที่ txAdmin แล้ววาง Key ใน Input Parameter ที่กำหนด
จากนั้นตรวจค่าก่อน Run
Recipe Deployer จะนำค่าที่กรอกไปอยู่ใน Context Variable สำหรับการ Deploy
㉖ serverName ถูกส่งเข้า Recipe ด้วย
txAdmin Recipe มี Context Variable
serverName
ซึ่งได้จากชื่อ Server ที่กำหนดตอน Setup
Recipe สามารถนำไปสร้างค่าใน server.cfg เช่น
sv_hostname
sv_projectName
ตาม Template
㉗ maxClients คืออะไร
Recipe Deployer มี Context Variable
maxClients
ใช้กำหนดจำนวน Player สูงสุดที่ Server Config จะใช้
CFX Recipe สามารถนำไปเขียนในลักษณะ
sv_maxclients
ได้
จำนวน Slot ที่ใช้งานจริงยังต้องเป็นไปตามสิทธิ์และ Configuration ของ Server
㉘ serverEndpoints คืออะไร
Recipe Deployer สามารถสร้าง Game Endpoint ให้ Server
Default มีแนวคิดเป็น
0.0.0.0:30120
แล้วนำไปสร้าง Configuration สำหรับ
endpoint_add_tcp
endpoint_add_udp
จึงไม่ต้องพิมพ์ Endpoint เองใน Basic Recipe ทุกครั้ง
㉙ OneSync ถูกกำหนดใน Recipe ได้ไหม
ได้
Recipe Metadata รองรับ
$onesync
CFX Default FiveM Recipe ปัจจุบันกำหนด OneSync ตาม Template ของ Recipe
Framework Recipe อื่นอาจกำหนด Requirement แตกต่างกัน
㉚ Framework Recipe อาจถาม Database
ถ้าเลือก ESX, QBCore หรือ Framework ที่ต้องใช้ Database อาจพบช่อง เช่น
Database Host
Database Port
Database Username
Database Password
Database Name
เพราะ Recipe รองรับ Database Context Variables
Basic CFX Server ไม่จำเป็นต้องมี RP Database เพื่อเริ่ม Server ขั้นพื้นฐาน
㉛ Recipe เชื่อม MySQL ได้อย่างไร
Recipe Engine รองรับ Action
connect_database
และ
query_database
เพื่อเชื่อม MySQL/MariaDB และ Run SQL ที่ Framework ต้องใช้
จึงสามารถสร้าง Table และ Import Schema เป็นส่วนหนึ่งของ Deployment ได้
㉜ ตรวจ Database ก่อน Run Framework Recipe
ถ้า Recipe ต้องใช้ Database ตรวจว่า
MySQL/MariaDB Running
Host ถูก
Port ถูก
Username ถูก
Password ถูก
User มี Permission
Database Server เข้าถึงได้
ถ้า Connection ไม่ผ่าน Recipe สามารถ Fail ระหว่าง Deployment ได้
㉝ กด Run Recipe
เมื่อ Input Parameters ถูกต้อง กด
Run Recipe
txAdmin จะเริ่ม Execute Tasks ตามลำดับ
ตัวอย่าง
Task 1 Download
↓
Task 2 Extract
↓
Task 3 Move
↓
Task 4 Configure
↓
Task 5 Database
อย่าปิด Server หรือ Browser แบบสุ่มระหว่าง Deploy
㉞ Recipe ทำงานตามลำดับไหม
ใช่
txAdmin Recipe Tasks ถูก Execute ตามลำดับ
หาก Task ใด Fail Chain จะหยุด
จึงควรอ่านข้อความ Error ของ Task นั้นก่อนกด Run ใหม่
นี่ช่วยให้หา Root Cause ง่ายขึ้น
㉟ Run Recipe แล้ว Error ทำอย่างไร
ดูว่า Error อยู่ Task ไหน
ตัวอย่าง
download_github failed
ให้ตรวจ Internet/Repository
หรือ
connect_database failed
ให้ตรวจ Database
อย่าลบ Server ทั้งหมดทันที
㊱ Download GitHub ไม่ผ่าน
ตรวจ
Internet
GitHub Availability
Repository URL
Branch/Tag
Permissions
Recipe Version
Recipe เก่าบางตัวอาจอ้าง Repository หรือ Branch ที่เปลี่ยนไปแล้ว
ดังนั้นควรใช้ Recipe ปัจจุบันจาก Source ที่เชื่อถือได้
㊲ Deployment สำเร็จดูจากอะไร
เมื่อ Recipe ทำงานครบ txAdmin จะตรวจ Target Folder
ควรพบอย่างน้อย
server.cfg
resources/
หากโครงสร้างพื้นฐานผ่าน ระบบจะเข้าสู่ขั้นตอน Configuration ต่อ
㊳ เปิด server.cfg หลัง Deploy
หลัง Recipe สำเร็จควรตรวจ server.cfg
สำหรับ Basic Server อาจมีค่า เช่น
sv_hostname
sets sv_projectName
sets sv_projectDesc
sv_licenseKey
sv_maxclients
endpoint_add_tcp
endpoint_add_udp
ensure
ไม่จำเป็นต้องแก้ทุกค่าในครั้งแรก
เป้าหมายคือให้ Server เปิดได้ก่อน
㊴ ตรวจ Server Key
ควรตรวจว่า Recipe นำ Key มาใส่ใน Configuration แล้ว
เช่น
sv_licenseKey "..."
หาก Key ผิด Server อาจไม่สามารถ Register ตามปกติได้
แต่เวลา Screenshot หรือโพสต์ถามปัญหา อย่าเปิดเผย Key จริง
㊵ ตรวจ Game Endpoint
Basic Configuration โดยทั่วไปจะมี Endpoint สำหรับ Game Server ในลักษณะ
endpoint_add_tcp "0.0.0.0:30120"
endpoint_add_udp "0.0.0.0:30120"
หากเปิด Server หลาย Instance ต้องหลีกเลี่ยง Game Port ชนกัน
เช่น Server ที่สองอาจต้องใช้ Port อื่นตาม Configuration ของคุณ
㊶ ตรวจ Resources ที่ Recipe ติดตั้ง
CFX Basic Recipe มี Resources ขั้นพื้นฐานสำหรับ Minimal Server
ไม่ควรคาดว่าจะได้
Police Job
EMS
Inventory
Phone
Garage
Housing
ทันที
สิ่งเหล่านี้เป็น Framework/Custom Resources ที่ต้องติดตั้งเพิ่มเติม
㊷ Save & Run Server
เมื่อ Config พร้อม กด
Save & Run Server
txAdmin จะบันทึก Configuration และเปิด FXServer Instance
หลังจากนั้น Dashboard ควรแสดง Server Running หากไม่มี Critical Error
นี่คือจุดที่ FiveM Server เริ่มทำงานจริง
㊸ ตรวจ Live Console
หลังเปิด Server ไปที่
Live Console
ตรวจ
Artifact Error
License Error
Resource Error
Dependency Error
Endpoint Error
Database Error
Warning
อย่าเพิ่งติดตั้ง Script เพิ่มจน Basic Server เปิดได้สะอาดพอสมควร
㊹ เข้า FiveM Server ทดสอบ
สำหรับ Local Server คู่มือ Cfx.re ปัจจุบันให้เปิด FiveM Client แล้วเลือก
Connect to [ComputerName] on LAN
หาก Server ปรากฏ
ถ้าไม่เห็น สามารถตรวจการเชื่อมต่อและ Direct Connect ตาม Environment ต่อไป
เป้าหมายคือให้ Client เข้า Server ได้จริง
㊺ ทดสอบ txAdmin In-game Menu
หลังเข้า Server แล้วกด
F8
พิมพ์
tx
แล้ว Enter
ถ้า Account/Permission ถูกต้อง txAdmin In-game Menu ควรแสดง
นี่ช่วยยืนยันว่าทั้ง Server และ txAdmin Integration ทำงาน
㊻ ก่อนลง Framework ให้ Backup
เมื่อ Basic Server ทำงานแล้ว ถือเป็นจุด Backup ที่ดี
ควร Backup
txData
server.cfg
resources
ถ้ามี Database แล้วให้ Backup Database ด้วย
จากนั้นจึงทดลองติดตั้ง Framework หรือ Resources เพิ่ม
㊼ ถ้าจะสร้าง ESX/QBCore ควรใช้ Recipe ใหม่ไหม
มีสองแนวทาง
ใช้ Framework Recipe
เหมาะกับ Server ใหม่ที่ต้องการ Deploy Framework ตั้งแต่ต้น
เพิ่ม Framework ด้วยตัวเอง
เหมาะกับผู้ดูแลที่ต้องการควบคุมโครงสร้างทีละส่วน
ไม่ควร Run Framework Recipe ทับ Basic Production Server แบบสุ่มโดยไม่รู้ว่า Recipe จะเปลี่ยนไฟล์ใด
㊽ Checklist สร้าง Server ด้วย txAdmin Recipe
ตรวจให้ครบ
Recommended Artifact
FXServer เปิดได้
txAdmin เข้าได้
Cfx Account Link แล้ว
Server Name ตั้งแล้ว
Popular Recipes
Recipe ถูกต้อง
Data Location ถูกต้อง
Server Key พร้อม
Review Recipe แล้ว
Database พร้อมถ้าต้องใช้
Run Recipe สำเร็จ
มี server.cfg
มี resources
Save & Run Server
Console ไม่มี Critical Error
Player เข้าได้
txAdmin Menu ใช้ได้
Backup แล้ว
หากครบทั้งหมดถือว่า Server พื้นฐานพร้อมต่อยอด
㊾ ข้อผิดพลาดที่มือใหม่เจอบ่อย
สิ่งที่ควรหลีกเลี่ยง ได้แก่
ใช้ Artifact เก่า
Deploy ผิด Folder
ใช้ Recipe จาก Source ไม่รู้จัก
เปิดเผย Server Key
ใส่ Database Password ผิด
Run Recipe ซ้ำโดยไม่อ่าน Error
เปิด Server หลายตัว Port ชน
ลง Framework หลายชุดพร้อมกัน
แก้
server.cfgหลายจุดก่อน Server เปิดครั้งแรกไม่ Backup หลัง Setup สำเร็จ
แก้ทีละส่วนจะหาสาเหตุง่ายกว่า
㊿ สรุปวิธีสร้าง FiveM Server ด้วย txAdmin Recipe
วิธีสร้าง FiveM Server ด้วย txAdmin Recipe แบบพื้นฐานสามารถจำเป็นขั้นตอนนี้
1. ดาวน์โหลด Recommended FXServer Artifact
2. Extract Server
3. เปิด FXServer
4. เข้า txAdmin
5. Link Cfx Account
6. ตั้ง Server Name
7. เลือก Popular Recipes
8. เลือก FiveM Basic Server (CFX Default)
9. เลือก Data Location
10. เข้า Recipe Deployer
11. Review Recipe
12. สร้าง Server Registration Key
13. ใส่ Key ใน Input Parameters
14. ใส่ Database ถ้า Recipe ต้องใช้
15. Run Recipe
16. รอ Deployment สำเร็จ
17. ตรวจ server.cfg
18. ตรวจ resources
19. Save & Run Server
20. ตรวจ Live Console
21. เปิด FiveM เข้า Server
22. ทดสอบ txAdmin Menu
23. Backup
สำหรับมือใหม่ comsiam แนะนำให้สร้าง FiveM Basic Server ให้เปิดและเข้าเล่นได้สำเร็จก่อน เพราะจะพิสูจน์ได้ว่า FXServer, Artifact, txAdmin, Server Key และ Game Endpoint ทำงานถูกต้อง
จากนั้นจึงค่อยเพิ่ม ESX, QBCore, Qbox, Database, รถ, Map และ Custom Resources ตามลำดับ แทนการนำ Server Pack ขนาดใหญ่มาลงตั้งแต่ครั้งแรกแล้วไม่รู้ว่าปัญหาเกิดจากส่วนใด
Recipe มีประโยชน์มากเพราะทำให้การสร้าง Server เป็นกระบวนการที่ทำซ้ำได้ แต่ผู้ดูแลยังต้องเข้าใจว่า Recipe กำลัง Download อะไร แก้ไฟล์อะไร และใช้ Database อย่างไร
เมื่อใช้ Recipe จาก Source ที่เชื่อถือได้ ตรวจ Config หลัง Deploy และ Backup ก่อนต่อยอด ผู้ดูแล FiveM Server ของ comsiam จะมี Server Foundation ที่สะอาดและแก้ปัญหาได้ง่ายกว่าในระยะยาว
Comments
Post a Comment