วิธีติดตั้ง ox_core FiveM แบบถูกต้องสำหรับ Server ใหม่

การติดตั้ง ox_core แตกต่างจากการลง Script FiveM ทั่วไป เพราะ ox_core เป็น Framework หลัก สำหรับจัดการ Player, Character, Groups, Accounts, Vehicles และ Persistence ของ Server

โครงสร้างพื้นฐานที่ควรเข้าใจก่อนคือ

FXServer
↓
MariaDB
↓
oxmysql
↓
ox_lib
↓
ox_core
↓
Gameplay Resources

หากต้องการระบบ RP ที่สมบูรณ์ขึ้น อาจเพิ่ม

ox_inventory
ox_target
Appearance
Phone
Banking
Doorlock
Fuel
Voice

ตาม Requirement ของ Server

สิ่งสำคัญคือควรสร้าง Clean ox_core Base ให้ทำงานก่อน แล้วจึงเพิ่ม Jobs, Phone, Housing, Police หรือ Paid Scripts ภายหลัง

① สิ่งที่ต้องเตรียมก่อนติดตั้ง ox_core

ควรมี

  • FiveM FXServer รุ่นปัจจุบัน

  • txAdmin

  • Cfx Account

  • Server Registration Key

  • MariaDB

  • oxmysql

  • ox_lib

  • ox_core

  • FiveM Client สำหรับทดสอบ

ถ้าจะพัฒนา Resource จาก Source เอง ควรมี

Git
Node.js
Bun

ตาม Current Development Guide

แต่ถ้าเป็นผู้ใช้งานทั่วไป การใช้ Release ที่ Build พร้อมแล้วง่ายกว่า

② ox_core ต้องใช้ Database หรือไม่

ต้องใช้

เพราะ Framework ต้องบันทึกข้อมูล Persistent เช่น

Users
Characters
Groups
Accounts
Licenses
Statuses
Vehicles

Architecture คือ

ox_core
↓
oxmysql
↓
MariaDB

ถ้า Database ไม่พร้อม การติดตั้ง Framework ยังไม่ถือว่าสมบูรณ์

③ ox_core ใช้ MariaDB เวอร์ชันไหน

Documentation ปัจจุบันระบุให้ติดตั้ง

MariaDB 11.4+

ดังนั้นสำหรับ Server ใหม่ควรเริ่มด้วย MariaDB รุ่นที่ Current Documentation รองรับ

ไม่ควรใช้ Database Server รุ่นเก่าจาก Server Pack หรือ Tutorial FiveM เก่าโดยไม่ตรวจ Version

④ ทำไม MariaDB Version ถึงสำคัญ

Current ox_core Database Schema ใช้ SQL Features ที่ทันสมัยหลายอย่าง เช่น

JSON
Generated Columns
Foreign Keys
Indexes

ถ้า Database Version ไม่รองรับ อาจเกิด

SQL syntax error
Migration error
Table creation error
Index error

แล้วทำให้ดูเหมือนว่า ox_core เสีย ทั้งที่จริงปัญหาอยู่ Database Layer

⑤ สร้าง Database สำหรับ ox_core

ตัวอย่าง

Database:
overextended

User:
fivem

Password:
StrongPassword

Current install.sql ใช้ชื่อ Database เริ่มต้นว่า

overextended

แต่สามารถเปลี่ยนชื่อได้ตาม Deployment ที่ใช้

สำหรับ Production ควรสร้าง Database User แยก

ไม่ควรใช้

root

กับ FXServer โดยไม่จำเป็น

⑥ Database User ควรเป็นแบบไหน

แนะนำโครงสร้าง

MariaDB
├── root
│   └── ใช้ดูแล Database
│
└── fivem
    └── ใช้กับ FXServer

ให้ User ของ FiveM มี Permissions ที่ระบบต้องใช้กับ Database นั้น

ข้อดีคือหาก Credential ของ FXServer รั่ว ความเสียหายไม่ควรขยายไปทุก Database บนเครื่องโดยไม่จำเป็น

⑦ อย่าใช้ root แบบไม่มี Password

Development Server ชั่วคราวอาจพบ Config ประเภท

root
password ว่าง

แต่ Production ไม่ควรใช้

อย่างน้อยควรมี

Dedicated DB User
Strong Password
Firewall
Backup
Limited Network Exposure

เพราะ Database มีข้อมูล Player และ Economy สำคัญทั้งหมด

⑧ ติดตั้ง FXServer

ดาวน์โหลด FiveM Server Artifact ปัจจุบันจาก Cfx.re

จากนั้น

Download
↓
Extract
↓
Run FXServer
↓
txAdmin Setup

ไม่ควรใช้ Artifact เก่าจาก Ready Server Pack โดยไม่ตรวจ Version

Framework และ Dependencies สมัยใหม่อาจต้องการ Server Build ใหม่กว่า

⑨ txAdmin ต้องติดตั้งแยกหรือไม่

โดยปกติไม่ต้อง

txAdmin รวมมากับ FXServer รุ่นปัจจุบัน

เมื่อเปิด FXServer จะสามารถตั้ง Server ผ่าน Browser ได้

จากนั้นทำ

Link Cfx Account
↓
สร้าง Server Profile
↓
Deploy Server

⑩ ox_core มี txAdmin Recipe หรือไม่

มี Official txAdmin Recipe

แต่มีรายละเอียดสำคัญที่ควรรู้

Documentation ระบุว่า Recipe ช่วยให้ติดตั้ง ox_core ได้รวดเร็ว

อย่างไรก็ตาม Repository ของ Recipe เองระบุว่า Recipe นี้ให้ไว้เพื่อความสะดวก และ แนะนำการติดตั้งแบบ Git/Manual มากกว่า สำหรับ Server ที่ต้องการ Version Control และ Merge Changes อย่างเป็นระบบ

ดังนั้นสามารถมองได้ว่า

ต้องการ Setup เร็ว
→ txAdmin Recipe

ต้องการ Development/Production Workflow ที่ควบคุม Version ดี
→ Manual + Git

⑪ วิธีใช้ txAdmin Recipe

ใน txAdmin ให้เลือก Deployment แบบ

Remote URL Template

แล้วใช้ Official ox_core Recipe

Recipe จะจัดการส่วนสำคัญหลายอย่าง เช่น

Database Connection
SQL Import
ox_core
oxmysql
ox_lib
ox_inventory
Resources เพิ่มเติม
server.cfg

ช่วยลดการประกอบ Resource ด้วยมือ

⑫ Recipe เปิด OneSync ให้หรือไม่

Current Official Recipe กำหนด

$onesync: on

ไว้ใน Recipe

จึงสร้าง Server Base ที่เปิด OneSync ตาม Framework Architecture

ไม่ควรนำ server.cfg เก่ามาทับแล้วปิด OneSync โดยไม่เข้าใจผลกระทบ

⑬ Recipe กำหนดขั้นต่ำของ FXServer ด้วย

Current Recipe มี

$minFxVersion: 12913

ใน Snapshot ปัจจุบัน

นั่นหมายความว่า Recipe สามารถกำหนด Minimum FXServer Build ได้

ค่าดังกล่าวอาจเปลี่ยนในอนาคต จึงควรใช้ Current Recipe แทนจำตัวเลขนี้เป็นค่าถาวร

⑭ Recipe ติดตั้ง ox_core อย่างไร

Current Recipe ดาวน์โหลด Release ของ

ox_core

แล้วแตกไปไว้ใน Resource Group

จากนั้นแก้ Database Name ใน

ox_core/sql/install.sql

ให้ตรงกับ Database ที่ txAdmin ใช้

แล้ว Run SQL ให้อัตโนมัติ

จึงไม่ควร Import install.sql ซ้ำโดยไม่ตรวจว่ Recipe ทำไปแล้วหรือยัง

⑮ Recipe ติดตั้ง oxmysql หรือไม่

ติดตั้ง

Current Recipe ดาวน์โหลด Release ของ

oxmysql

ให้อัตโนมัติ

จึงไม่ควรมีหลายชุด เช่น

oxmysql
oxmysql-old
oxmysql-new

อยู่ใน Resources และ Start ปะปนกัน

ควรมี Version Lineage ที่ชัดเจน

⑯ Recipe ติดตั้ง ox_lib หรือไม่

ติดตั้ง

ox_lib เป็น Dependency หลักของ ox_core

ดังนั้น Stack พื้นฐานจาก Recipe จะมี

oxmysql
ox_lib
ox_core

อยู่แล้ว

⑰ ox_inventory จำเป็นกับ ox_core หรือไม่

ไม่ได้เป็น Requirement เดียวกับ oxmysql และ ox_lib

Documentation จัด ox_inventory เป็น Optional Dependency ที่แนะนำอย่างมาก

แต่ Current txAdmin Recipe ติดตั้ง ox_inventory ให้ด้วย เพื่อสร้าง RP Base ที่ใช้งานได้มากขึ้น

ดังนั้น

ox_core
≠
ox_inventory

แม้ Recipe จะใส่ทั้งสองตัว

⑱ Optional Dependencies มีอะไรอีก

Documentation ปัจจุบันยกตัวอย่าง

ox_inventory
npwd
illenium-appearance

เป็น Optional Dependencies ที่แนะนำ

แนวคิดของ Framework คือ

ox_core
→ Framework

ox_inventory
→ Inventory

NPWD
→ Phone

Appearance Resource
→ Character Appearance

ไม่รวมทุก Feature ไว้ใน Core ตัวเดียว

⑲ Current Recipe ลง Resource อะไรเพิ่ม

จาก Current Recipe/Server Configuration สามารถพบ Resources เช่น

ox_target
ox_inventory
ox_banking
ox_commands
ox_doorlock
ox_fuel
NPWD
pma-voice
illenium-appearance

และ Resources ประกอบอื่นตาม Recipe Version

รายการสามารถเปลี่ยนได้ในอนาคต

จึงควรตรวจ Current Recipe ก่อน Deploy Production

⑳ Start Order สำคัญมาก

Current Official Recipe ใช้ลำดับสำคัญประมาณ

start oxmysql
start ox_lib
start ox_core
start ox_target
start illenium-appearance
start ox_inventory

แล้วจึง Resources อื่น

แนวคิดสำคัญคือ

Database
↓
Library
↓
Framework
↓
Target / Appearance
↓
Inventory
↓
Gameplay

อย่า Start Custom Jobs ก่อน Framework และ Dependencies พร้อม

㉑ mysql_connection_string ตั้งอย่างไร

ใน server.cfg จะมี

set mysql_connection_string "..."

ค่าจริงต้องตรงกับ

Host
Port
Username
Password
Database

ของ MariaDB Server

ถ้า Connection String ผิด oxmysql จะเชื่อม Database ไม่สำเร็จ

แล้ว Framework Layer ด้านบนอาจ Error ตามมา

㉒ อย่าเปิดเผย Database Password

อย่าโพสต์

set mysql_connection_string "..."

ที่มี Credential จริงลง Discord หรือ Forum สาธารณะ

ถ้าต้องขอความช่วยเหลือให้ซ่อน

Password
Hostname ถ้า Sensitive
Tokens
sv_licenseKey
Webhook

ก่อน

㉓ install.sql ทำอะไร

Current

ox_core/sql/install.sql

สร้าง Database Structures ที่ Framework ต้องใช้

เช่น

users
characters
character_groups
ox_groups
ox_group_grades
accounts
accounts_access
accounts_transactions
vehicles
licenses
statuses

และ Relationships อื่น

ดังนั้น SQL เป็นส่วนสำคัญของ Framework ไม่ใช่ไฟล์ตัวเลือกที่ข้ามได้

㉔ อย่า Import install.sql ซ้ำแบบสุ่ม

ถ้าใช้ txAdmin Recipe แล้ว SQL ถูก Run ไปแล้ว

ไม่ควร Import ใหม่ทุกครั้งที่ Framework Error

เพราะ Error อาจไม่ได้เกี่ยวกับ Database Schema

ให้ตรวจ Database ก่อนว่า Tables มีอยู่แล้วหรือไม่

㉕ ถ้าติดตั้ง Manual ต้อง Run install.sql ไหม

ต้องเตรียม Schema ตาม Documentation/Current Release

สำหรับ Manual Installation ให้ใช้ SQL ที่มากับ ox_core Version นั้น

ไม่ควรใช้

install.sql

จาก Version อื่น

เพราะ Schema และ Core Code ต้องตรงกัน

㉖ ติดตั้ง Manual ต้องลงอะไรตามลำดับ

พื้นฐานคือ

① MariaDB

② oxmysql

③ ox_lib

④ ox_core

จากนั้น Optional Stack เช่น

⑤ ox_target

⑥ Appearance

⑦ ox_inventory

⑧ Phone

⑨ Banking / Doorlock / Fuel

⑩ Custom Resources

ตาม Dependencies จริง

㉗ ควร Download Release หรือ Source

สำหรับผู้ใช้ทั่วไปควรใช้

Latest Release

ที่ Build พร้อมแล้ว

Documentation อนุญาตให้

Download Release
หรือ
Build Source

ถ้าไม่ต้องแก้ Source การใช้ Release ง่ายกว่าและลดปัญหา Build Assets ไม่ครบ

㉘ ถ้าจะ Build ox_core จาก Source

Current Documentation ใช้ Workflow ประมาณ

git clone <ox_core repository>
cd ox_core
bun i
bun run build

จึงต้องมี Development Tools เช่น

Git
Node.js
Bun

ครบ

ถ้าไม่ต้องพัฒนา Framework เอง ไม่จำเป็นต้องเพิ่มความซับซ้อนส่วนนี้

㉙ ทำไม Download Source ZIP แล้วอาจไม่เหมือน Release

Modern FiveM Resources บางตัวมี Build Process

เช่น

Source
↓
Dependencies
↓
Build
↓
Production Files

ดังนั้น

GitHub Source ZIP

กับ

Release ZIP

อาจไม่ได้พร้อมใช้ในระดับเดียวกัน

สำหรับ Production ให้ใช้ Distribution ที่ Project แนะนำ

㉚ ตั้งค่า ox_core ผ่านอะไร

Current ox_core ใช้

Convars

เป็นหลัก

ตัวอย่าง

ox:debug
ox:characterSlots
ox:plateFormat
ox:deathSystem
ox:hospitalBlips
ox:characterSelect
ox:spawnLocation
ox:defaultVehicleStore

ดังนั้นควรตั้งค่าผ่าน server.cfg หรือ Config ที่ exec เข้ามา

ไม่ใช่แก้ Source Core ทุกครั้ง

㉛ ตั้ง Locale

Current Official Recipe มีตัวอย่าง

setr ox:locale "en"

ถ้าต้องการ Locale อื่น ให้ตรวจว่า Resource แต่ละตัวมี Translation รองรับหรือไม่

การเปลี่ยน Locale ของ Core ไม่ได้ทำให้ Third-party Scripts ทุกตัวเปลี่ยนภาษาตาม

㉜ ox:characterSelect คืออะไร

Current Core มี

ox:characterSelect

สำหรับ Built-in Character Registration/Selection Behavior

ถ้าเปิด

true

Framework สามารถจัดการ Character Flow ที่เกี่ยวข้องได้ตาม Core Design

อย่ารีบลง Multicharacter Resource อื่นซ้อนก่อนตรวจ Feature นี้

㉝ ox:characterSlots คืออะไร

ใช้กำหนดจำนวน Character Slots

ตัวอย่าง

setr ox:characterSlots 3

ถ้าต้องการให้ Player มีหลาย Character

แต่ต้องตรวจ Character Selector ที่ใช้อยู่ด้วย

อย่าเปลี่ยนเพียง Convar แล้วคาดว่า UI ภายนอกทุกตัวจะรองรับอัตโนมัติ

㉞ ox:spawnLocation คืออะไร

เป็น Default Spawn Location สำหรับ Character ใหม่

สามารถกำหนด Coordinates ผ่าน Configuration

แนวคิดคือ

Create Character
↓
Spawn
↓
Default Location

หากใช้ Spawn Selector ภายนอก ต้องตรวจ Integration เพื่อไม่ให้สองระบบพยายาม Spawn Player พร้อมกัน

㉟ ox:deathSystem คืออะไร

Current Core มี Built-in Death/Respawn System

ควบคุมด้วย

ox:deathSystem

ถ้าใช้ Medical/Death Script ภายนอกควรตรวจว่า Framework Death System ต้องเปิดหรือปิดอย่างไร

อย่าเปิด Death Systems สองชุดโดยไม่รู้ว่า Events และ Player State ชนกันหรือไม่

㊱ ox:plateFormat คืออะไร

ใช้ควบคุมรูปแบบ Vehicle Plate

ตัวอย่าง Configuration สามารถกำหนด Pattern ตาม Server

มีประโยชน์เพราะ ox_core มี Vehicle Persistence ของตัวเอง

Plate จึงเกี่ยวข้องกับ Vehicle Ecosystem มากกว่าแค่ข้อความบนรถ

㊲ ox:defaultVehicleStore คืออะไร

ใช้กำหนด Vehicle Store เริ่มต้นสำหรับรถที่ Framework ต้องจัดการเมื่อ Resource เริ่มทำงาน

Default ปัจจุบันมีแนวคิด

impound

ถ้า Server ใช้ Custom Garage/Impound ต้องเข้าใจค่า Core นี้ก่อน

ไม่เช่นนั้นรถอาจไปอยู่ Store ที่ไม่ตรงกับ Custom Resource

㊳ ตั้ง Permissions ของ ox_lib

Current ox_lib Installation Guide ต้องการ ACE Permissions สำหรับ Resource ในงานบางประเภท

ตัวอย่าง

add_ace resource.ox_lib command.add_ace allow
add_ace resource.ox_lib command.remove_ace allow
add_ace resource.ox_lib command.add_principal allow
add_ace resource.ox_lib command.remove_principal allow

Current ox_core Recipe มี Permissions เหล่านี้อยู่ด้วย

ถ้าติดตั้ง Manual อย่ามองข้าม Permission Configuration

㊴ เปิด Server ครั้งแรกต้องดูอะไร

เมื่อ Start Server ให้ดู Console ตั้งแต่เริ่ม

ตรวจ

oxmysql
↓
ox_lib
↓
ox_core

ว่าผ่านทั้งหมด

ถ้าเจอ Error ที่ oxmysql

อย่าเริ่ม Debug ox_core ก่อน

เพราะ Database Layer อยู่ต่ำกว่า Framework

㊵ ตรวจ oxmysql ก่อน

ถ้า Database เชื่อมไม่ได้ อาจเห็น

Access denied
Connection refused
Unknown database
Authentication error

ตรวจ

MariaDB Running?
Host?
Port?
Username?
Password?
Database?
Permissions?

ให้ครบ

อย่าแก้ ox_core Source เพื่อแก้ Database Connection Error

㊶ ตรวจ ox_lib

ถ้า ox_lib ไม่ Start Framework/Resources ที่พึ่งมันจะได้รับผลกระทบ

ตรวจ

Folder ถูก?
Release ถูก?
fxmanifest.lua มี?
Console Error?

และ Permissions ตาม Documentation

㊷ ตรวจ ox_core

เมื่อ Dependencies พร้อมแล้วให้ตรวจ

start ox_core

หรือให้ server.cfg Start ตามลำดับ

สิ่งที่ต้องไม่มีคือ Critical Errors เช่น

Database Error
Missing dependency
SQL Error
Module Error

เพียงเห็น

Started resource ox_core

ยังไม่เพียงพอ

ต้องทดสอบ Gameplay Flow ด้วย

㊸ เข้า Server และสร้าง Character

หลัง Core Start แล้ว

ทดสอบ

Connect
↓
Character Registration
↓
Character Creation
↓
Spawn

ถ้า Character Flow ใช้งานไม่ได้ อย่าเพิ่งลง Phone หรือ Housing เพิ่ม

ต้องแก้ Core Character Flow ก่อน

㊹ ทดสอบ Character Persistence

หลังสร้าง Character

Create
↓
Spawn
↓
Disconnect
↓
Reconnect
↓
Character เดิมยังอยู่

ถ้า Character หายหลัง Reconnect ให้ตรวจ

Database
Identifiers
Character Save
SQL Errors

นี่เป็น Base Test ที่สำคัญมาก

㊺ ตรวจ users Table

เมื่อ Player เข้า Server Framework ควรสร้างหรือเชื่อม User Data ตาม Architecture

Current Schema มี

users

สำหรับข้อมูลระดับ User

อย่าใช้ source เป็น Persistent User Identity แทน Database Identity ของ Framework

㊻ ตรวจ characters Table

หลังสร้าง Character ควรมี Record ใน

characters

ที่สัมพันธ์กับ User

ตรวจข้อมูล เช่น

charId
userId
stateId
firstName
lastName
position

ตาม Schema

ไม่จำเป็นต้องแก้ค่าเหล่านี้ด้วยมือหาก Framework Flow ทำงานปกติ

㊼ ทดสอบ Multiple Characters ถ้าเปิด

ถ้าตั้ง

ox:characterSlots > 1

ให้ทดสอบ

Character A
Character B

แล้วตรวจว่า

Data
Position
Accounts
Groups
Inventory

ไม่ปะปนกัน

นี่สำคัญมากก่อนเปิด Production

㊽ ทดสอบ Groups

สร้างหรือใช้ Group ที่ Framework มี

แล้วตรวจ

Character
↓
Group
↓
Grade
↓
Permission

ถ้ามี Jobs อย่าง

police
ambulance

ให้ทดสอบหลาย Grade

ไม่ใช่เฉพาะ Boss Account

㊾ ทดสอบ Accounts

หาก Server ใช้ Account System ของ Framework ให้ตรวจ

Personal Account
Group Account
Deposit
Withdraw
Transaction
Reconnect

และตรวจว่า Database บันทึกถูกต้อง

Economy Server ต้องทดสอบ Persistence ไม่ใช่แค่ยอดเปลี่ยนบน UI

㊿ ทดสอบ Vehicle Persistence

นี่เป็นส่วนสำคัญของ ox_core

ทดสอบ

Create/Own Vehicle
↓
Spawn
↓
เปลี่ยนข้อมูลรถ
↓
Store
↓
Restart Server
↓
เรียกรถกลับ

ตรวจ

VIN
Plate
Owner
Stored State
Vehicle Data

ว่าถูกต้อง

51. อย่าทดสอบ Vehicle แค่ Spawn ได้

รถ Spawn ได้ไม่ได้แปลว่า Persistence ทำงาน

ต้องทดสอบอย่างน้อย

Database Record
Owner
Plate
VIN
Store
Respawn
Restart

เพราะ ox_core มี Vehicle Persistence เป็นจุดเด่นของ Framework

52. ติดตั้ง ox_inventory หลัง Base ทำงาน

หากไม่ได้ใช้ Recipe เต็ม ให้ทำ ox_core Base ให้ผ่านก่อน แล้วค่อยเพิ่ม Inventory

Current ox_inventory Documentation แนะนำ Start Order ประมาณ

start oxmysql
start ox_lib
start ox_core
start ox_target
start ox_inventory

ตาม Dependency Stack

53. ox_inventory ต้องระวังอะไร

ox_inventory เป็นระบบใหญ่

เกี่ยวข้องกับ

Player Items
Weapons
Metadata
Stashes
Shops
Crafting
Trunks
Gloveboxes

จึงควรทดสอบ

Inventory เปิด
Item เพิ่ม
Item ลบ
Metadata
Reconnect

ก่อนติดตั้ง Jobs ที่ต้องพึ่ง Inventory

54. ติดตั้ง ox_target เมื่อไร

ox_target สามารถใช้เป็น Interaction Layer

ตัวอย่าง

NPC
Vehicle
Object
Zone

สำหรับ Stack แบบ OX มัก Start หลัง Framework และก่อน Inventory ตาม Documentation ของ ox_inventory

แต่ Target ไม่ใช่ Requirement ของ ox_core ทุก Feature

55. Phone ติดตั้งเมื่อไร

Documentation ยก

NPWD

เป็น Optional Dependency ที่แนะนำ

แต่อย่าเริ่มจาก Phone

Phone เชื่อมกับข้อมูลจำนวนมาก เช่น

Character
Phone Number
Accounts
Contacts
Vehicles
Jobs

ควรติดตั้งหลัง Character/Core Persistence ทำงานแล้ว

56. Appearance ติดตั้งเมื่อไร

Current Documentation ยก

illenium-appearance

เป็น Optional Resource ที่แนะนำ

Character Appearance ควรถูกทดสอบพร้อม

Create Character
Save Skin
Reconnect
Load Skin

เพื่อพิสูจน์ Persistence

57. txAdmin Recipe เหมาะกับใคร

เหมาะกับคนที่ต้องการ

Deploy Base เร็ว
ทดลอง Framework
เรียนรู้ Resource Stack
สร้าง Development Server

เพราะ Recipe จัด Dependencies และ SQL ให้จำนวนมาก

แต่ Official Recipe Repository เองระบุว่า Manual/Git Setup เหมาะกว่าเมื่อคุณต้องการ Version Control และ Merge Changes

58. Manual + Git เหมาะกับใคร

เหมาะกับ

Development Team
Production Server
Git Workflow
Custom Resource Development
Version Pinning
Automated Deployment

ข้อดีคือสามารถดู

อะไรเปลี่ยน
เมื่อไร
โดยใคร

และ Rollback ได้ง่ายกว่า Copy Folder ทับกัน

59. หลังติดตั้งควร Backup อะไร

เมื่อ Clean Base ทำงาน ให้ Backup

Database
resources/
server.cfg
Permissions
Custom Convars
txAdmin Profile

หรือทำ Git Commit เช่น

ox-core-clean-working-base

จากนั้นจึงเพิ่ม Scripts

60. Checklist ติดตั้ง ox_core

FXServer

  • Artifact ปัจจุบัน

  • txAdmin เปิดได้

  • Cfx Account ถูก

  • Server Registration Key ถูก

  • OneSync เปิด

Database

  • MariaDB 11.4+

  • Database ถูก

  • Database User ถูก

  • Password ถูก

  • oxmysql Connect สำเร็จ

  • install.sql ถูก Run

Dependencies

  • oxmysql

  • ox_lib

  • ox_core

Start สำเร็จ

Character

  • User ถูกสร้าง

  • Character สร้างได้

  • Spawn ได้

  • Reconnect ได้

  • Character เดิมยังอยู่

Core Systems

  • Groups ทำงาน

  • Accounts ทำงาน

  • Vehicle Persistence ทำงาน

Optional Systems

  • ox_target

  • ox_inventory

  • Phone

  • Appearance

  • Banking

  • Voice

ทดสอบหลัง Core ผ่านแล้ว

Production

  • Backup

  • Test Server

  • Git/Version Tracking

  • Rollback Plan

  • เพิ่ม Scripts ทีละตัว

วิธีติดตั้ง ox_core แบบสั้นที่สุด

ถ้าต้องการลำดับอย่างเดียว

① ติดตั้ง MariaDB 11.4+

② สร้าง Database และ User

③ ดาวน์โหลด FiveM Server Artifact ปัจจุบัน

④ เปิด FXServer / txAdmin

⑤ Link Cfx Account

⑥ สร้าง Server Profile

⑦ เลือกติดตั้งผ่าน Official Recipe
   หรือ Manual + Git

⑧ ติดตั้ง oxmysql

⑨ ติดตั้ง ox_lib

⑩ ติดตั้ง ox_core

⑪ Run ox_core install.sql

⑫ ตั้ง mysql_connection_string

⑬ ตั้ง ox_core Convars

⑭ ตั้ง ox_lib ACE Permissions

⑮ Start oxmysql

⑯ Start ox_lib

⑰ Start ox_core

⑱ ตรวจ Console

⑲ เข้า Server

⑳ สร้าง Character

㉑ Reconnect ตรวจ Persistence

㉒ ทดสอบ Groups / Accounts

㉓ ทดสอบ Vehicle Persistence

㉔ เพิ่ม ox_target / ox_inventory

㉕ เพิ่ม Phone / Appearance / Gameplay Scripts

㉖ Backup Clean Base

ข้อผิดพลาดที่พบบ่อยหลังติดตั้ง ox_core

Database Connection Error

ตรวจ

MariaDB
mysql_connection_string
DB User
Password

Table ไม่มี

ตรวจว่า install.sql ถูก Run แล้วหรือไม่

ox_lib Missing

ตรวจ Dependency และ Start Order

Character ไม่ Save

ตรวจ Database/Console และ Character Flow

รถหายหลัง Restart

ตรวจ Vehicle Persistence, Store และ Database Record

Inventory ไม่เปิด

แยก Debug ox_inventory ออกจาก Core

Target ไม่ขึ้น

ตรวจ ox_target และ Client F8

อย่าแก้ทุกปัญหาด้วย Clear Cache

อย่าติดตั้ง ESX/QBCore/Qbox Core ซ้อนด้วย

ถ้าตัดสินใจใช้

ox_core

เป็น Framework หลัก ไม่ควรเปิด

es_extended
qb-core
qbx_core

พร้อมกันโดยไม่มี Architecture เฉพาะที่ออกแบบไว้จริง

Player Framework หลายชุดสามารถสร้างความสับสนเรื่อง

Character
Money
Groups
Inventory
Database
Events

เลือก Source of Truth ให้ชัด

อย่า Rename OX Resources แบบสุ่ม

Resources อื่นอาจเรียก

ox_core
ox_lib
oxmysql
ox_inventory

ผ่าน Exports/Imports/Dependencies โดยใช้ชื่อ Resource ตรง ๆ

เช่น

shared_script '@ox_core/lib/init.lua'

หาก Rename เป็น

my_core

Resource ลูกจะหาไฟล์ไม่เจอ

ควรใช้ชื่อ Official

วิธีใช้ ox_core ใน Custom Script

Lua Resource สามารถ Import Definition ด้วย

shared_script '@ox_core/lib/init.lua'

จากนั้นใช้ Framework APIs เช่นแนวคิด

local player = Ox.GetPlayer(source)

ข้อดีคือ Custom Script เชื่อมกับ Framework ผ่าน Public API

แทนการอ่าน Database ตรง ๆ ทุกครั้ง

อย่า Query Core Tables โดยตรงโดยไม่จำเป็น

ถ้าต้องการ Player

ควรใช้

Ox.GetPlayer

หรือ API ที่เหมาะสม

มากกว่าทำ

SELECT * FROM characters ...

ในทุก Gameplay Action

เพราะ Core สามารถมี

Runtime State
Cache
Persistence Logic
Events

ที่ Database Query ตรง ๆ ไม่ได้อัปเดต

ติดตั้ง Script ใหม่ทีละตัว

หลัง Clean Base ผ่านแล้ว ให้ใช้

Install Resource A
↓
Test
↓
Commit / Backup
↓
Install Resource B
↓
Test

อย่า

ลง 100 Scripts
↓
Restart
↓
มี Error 400 บรรทัด

เพราะจะหาต้นเหตุยากมาก

Production ควรมี Test Server

ก่อน Update

ox_core
ox_lib
oxmysql
ox_inventory

ให้ทดสอบใน Environment แยก

Workflow ที่ดีคือ

Production Backup
↓
Clone Test
↓
Update
↓
Character Test
↓
Account Test
↓
Vehicle Test
↓
Inventory Test
↓
Custom Script Test
↓
Production

Framework Core ไม่ควรถูกทดลองครั้งแรกกับ Player จริง

สรุปวิธีติดตั้ง ox_core FiveM

การติดตั้ง ox_core ที่ถูกต้องควรเริ่มจาก Infrastructure ด้านล่างขึ้นบน

MariaDB
↓
oxmysql
↓
ox_lib
↓
ox_core
↓
Character / Groups / Accounts / Vehicles
↓
ox_target / ox_inventory
↓
Phone / Housing / Jobs / Custom Scripts

Current Documentation ระบุ oxmysql และ ox_lib เป็น Dependencies หลักของ Framework และแนะนำ MariaDB 11.4+ ขณะที่ ox_inventory, NPWD และ illenium-appearance เป็น Optional Dependencies ที่แนะนำ

สำหรับคนที่ต้องการทดลอง Framework อย่างรวดเร็ว มี Official txAdmin Recipe ที่สามารถ Download Resources, เชื่อม Database และ Import ox_core/sql/install.sql ให้อัตโนมัติ แต่ Recipe Repository ปัจจุบันระบุเองว่า Manual Installation ด้วย Git เหมาะกว่าสำหรับการควบคุม Version และ Merge Changes

หลังติดตั้งอย่าเพิ่งรีบเพิ่ม Scripts จำนวนมาก แต่ต้องพิสูจน์

Database Connected
↓
oxmysql
↓
ox_lib
↓
ox_core
↓
Create Character
↓
Reconnect
↓
Character Persistence
↓
Groups / Accounts
↓
Vehicle Persistence

ให้ผ่านก่อน

แนวทางของ comsiam คือเก็บ Clean Working Base ทันทีหลัง Core ผ่านทั้งหมด เพราะเมื่อเพิ่ม Inventory, Phone, Housing และ Custom Jobs ภายหลัง จะสามารถแยกได้ง่ายว่าปัญหาเกิดจาก Framework Base หรือ Resource ใหม่

สำหรับ Production comsiam แนะนำให้ใช้ Git หรือ Version Tracking กับ OX Resources สำคัญ และทดสอบ Updates บน Test Server ก่อนเสมอ โดยเฉพาะ ox_core, ox_lib, oxmysql และ ox_inventory เพราะ Resources เหล่านี้อยู่ลึกใน Dependency Stack และ Error เพียงตัวเดียวอาจทำให้ Scripts ชั้นบนมีปัญหาตามมาเป็นจำนวนมาก

Comments

Popular posts from this blog

FiveM ยังน่าเล่นไหม? Enhanced เปลี่ยน FiveM แค่ไหน

FiveM คืออะไร เล่นอย่างไร สำหรับมือใหม่ เริ่มต้นตั้งแต่ศูนย์

วิธีตั้ง Admin Permission ด้วย add_ace และ add_principal FiveM แบบละเอียด