FiveM Identifier คืออะไร? วิธีดู License, Steam, Discord และใช้กับ Permission

 FiveM Identifier คือข้อมูลตัวระบุผู้เล่นที่ FXServer สามารถใช้แยกผู้เล่นแต่ละคนออกจากกัน เช่น license, license2, fivem, steam, discord และ ip โดย Cfx.re มีฟังก์ชัน GetPlayerIdentifiers() สำหรับดึง Identifiers ที่มีอยู่ของ Player จากฝั่ง Server.

Identifier มีความสำคัญกับระบบ FiveM Server หลายส่วน เช่น Admin Permissions, Allowlist, Ban System, Player Database และการตรวจสอบผู้เล่นตอน playerConnecting แต่ไม่ควรคิดว่า Identifier ทุกประเภทจะมีอยู่กับผู้เล่นทุกคนเสมอไป เพราะ Server จะได้รับเฉพาะ Identifier ที่มีอยู่ใน Session/Environment นั้น.

Meta SEO

Meta Title: FiveM Identifier คืออะไร? วิธีดู License, Steam, Discord และใช้กับ Permission

Meta Description: อธิบาย FiveM Identifier แบบละเอียด license, license2, fivem, steam, discord, ip ต่างกันอย่างไร วิธีดู Identifier และใช้กับ Admin Permission, Allowlist และ Script

Focus Keyword: FiveM Identifier

Related Keywords: FiveM license identifier, FiveM Steam ID, FiveM Discord ID, FiveM fivem identifier, GetPlayerIdentifiers, FiveM admin identifier

สารบัญ

① FiveM Identifier คืออะไร

Identifier คือค่าที่ Server ใช้ระบุตัวตนของ Player จาก Provider ต่างๆ

ตัวอย่างรูปแบบ:

license:xxxxxxxxxxxxxxxx
fivem:12345678
steam:110000xxxxxxxxx
discord:123456789012345678
ip:192.0.2.1

ค่าด้านบนเป็นเพียงตัวอย่างรูปแบบเท่านั้น ไม่ควร Copy ไปใช้เป็น Identifier จริงของ Admin

Cfx.re ระบุว่า GetPlayerIdentifiers(player) จะคืนรายการ Identifiers ทั้งหมดที่มีอยู่สำหรับ Player นั้น.

② FiveM Identifier มีกี่ประเภท

Cfx.re Documentation ปัจจุบันระบุประเภทที่ GetPlayerIdentifiers สามารถพบได้ เช่น:

PrefixProvider
steamSteam
discordDiscord
licenseRockstar Online Services
license2Rockstar Online Services
fivemCfx
ipIP Address

ไม่ควรคาดหวังว่าผู้เล่นทุกคนจะมีครบทุกประเภท

③ Identifier กับ Server ID ต่างกันอย่างไร

Server ID เป็น ID ของ Player ใน Session ที่กำลังเชื่อมต่อ เช่น 1, 5 หรือ 42

ส่วน Identifier เป็นตัวระบุที่มาจาก Provider เช่น Rockstar Online Services หรือ Cfx

คำสั่ง status ของ FXServer สามารถแสดง Player พร้อม Primary Identifier, Server ID, Name, Endpoint และ Ping ได้เมื่อ Resource ที่ให้คำสั่งนี้พร้อมใช้งาน.

ดังนั้น Server ID ไม่ควรถูกใช้แทน Persistent Player Identifier ใน Database

④ Player ID เปลี่ยนหลังเข้าใหม่ได้ไหม

Server ID เป็น Identifier ของ Connected Player ใน Session ปัจจุบัน จึงไม่ควรถูกออกแบบเป็น Persistent Account Key

สำหรับข้อมูลที่ต้องคงอยู่ระหว่างการเข้า Server หลายครั้ง ควรใช้ Identifier ที่ระบบของ Server เลือกเป็นหลักแทน

⑤ license คืออะไร

license เป็น Identifier จาก Rockstar Online Services

Cfx.re ระบุ Data Type ของ Identifier นี้เป็น Hash และใช้ Prefix:

license:

นี่เป็นหนึ่งใน Identifier สำคัญที่พบใน FiveM Server Scripts

⑥ license ใช้ทำอะไรได้

ตัวอย่าง Documentation ของ Cfx.re สำหรับ playerConnecting ใช้ License Identifier เพื่อตรวจ Player กับ Ban List ก่อนอนุญาตให้เชื่อมต่อ Server.

จึงสามารถพบ License Identifier ในระบบประเภท:

  • Player Account Mapping

  • Allowlist

  • Ban List

  • Permissions

  • Database

ตามการออกแบบของแต่ละ Resource

⑦ license2 คืออะไร

Cfx.re ระบุว่า license2 เป็น Rockstar Online Services License Identifier อีกประเภทหนึ่ง และสำหรับผู้ใช้ Steam ค่า license2 อาจเหมือนกับ license.

รูปแบบ:

license2:xxxxxxxxxxxxxxxx

⑧ license กับ license2 ควรใช้อันไหน

Documentation สำหรับการ Migration ของ Cfx.re ระบุว่า FiveM ใช้ License Identifier ที่ตรวจสอบผ่าน Rockstar Online Services และ เมื่อมีทั้ง license และ license2 ควรให้ความสำคัญกับ license2.

Developer ที่กำลังออกแบบระบบ Account ใหม่จึงควรพิจารณาข้อนี้แทนการ Hard-code ว่าต้องใช้ license อย่างเดียวทุกกรณี

⑨ license2 มีทุกคนไหม

ไม่ควรสมมติว่ามี Identifier ทุกประเภทเสมอ

แนวทางที่ปลอดภัยกว่าคือดึงรายการ Identifiers ที่ Player มีอยู่จริงแล้วตรวจ Prefix ก่อนใช้งาน

GetPlayerIdentifiers() ถูกออกแบบมาเพื่อคืนรายการที่มีอยู่ของ Player โดยตรง.

⑩ fivem Identifier คืออะไร

fivem เป็น Identifier จาก Cfx และ Documentation ระบุประเภทข้อมูลเป็น User ID

ตัวอย่างรูปแบบ:

fivem:123456789

อย่าสับสนกับ Server ID ของ Player

⑪ FiveM Identifier กับ FiveM Server ID เหมือนกันไหม

ไม่เหมือนกัน

ตัวอย่าง:

Server ID: 17
FiveM Identifier: fivem:123456789

Server ID ใช้ระบุตัว Player ใน Connection ปัจจุบัน

ส่วน fivem: เป็น Identifier จาก Cfx

⑫ Steam Identifier คืออะไร

Steam Identifier ใช้ Prefix:

steam:

และ Cfx.re ระบุว่าเป็น Steam ID ในรูป Hexadecimal.

ตัวอย่างเชิงรูปแบบ:

steam:110000xxxxxxxxx

⑬ ทำไมบางคนไม่มี Steam Identifier

Steam Identifier ไม่ควรถูกถือว่าเป็น Identifier ที่ Server จะได้รับเสมอ

เอกสาร FXServer ปัจจุบันระบุว่า steam_webApiKey ใช้ตั้ง Steam Web API Key และ จำเป็นสำหรับให้ Server คืน Steam Identifiers.

ดังนั้น Resource ที่บังคับว่าผู้เล่นทุกคนต้องมี steam: โดยไม่รองรับ Identifier อื่นอาจมีข้อจำกัด

⑭ Steam Identifier เหมาะเป็น Account หลักไหม

สำหรับ Resource ใหม่ไม่ควรเลือกเพียงเพราะ Tutorial เก่าใช้ Steam

Cfx.re Documentation ปัจจุบันให้ความสำคัญกับ Rockstar Online Services License Identifier และระบุเรื่อง license2 โดยเฉพาะเมื่อมีทั้ง license และ license2.

จึงควรออกแบบระบบ Identifier จาก Requirement ปัจจุบันของ Resource

⑮ Discord Identifier คืออะไร

Cfx.re ระบุ Identifier Type:

discord

โดย Provider คือ Discord และข้อมูลเป็น Discord User ID.

ตัวอย่างเชิงรูปแบบ:

discord:123456789012345678

⑯ Discord Identifier มีทุกคนหรือไม่

ไม่ควรสมมติว่ามี

ให้ Resource ตรวจว่า Identifier Prefix discord: ถูกส่งมาในรายการจริงหรือไม่ ก่อนนำไปใช้งาน

ถ้า Resource ต้องใช้ Discord เป็น Requirement ควรมี Error Message ที่ชัดเจนเมื่อ Identifier ที่ต้องการไม่มี

⑰ Discord ID กับ Username เหมือนกันไหม

ไม่เหมือนกัน

Identifier ที่ Cfx.re ระบุเป็น Discord User ID ไม่ใช่ Display Name หรือ Username.

ดังนั้น Database ไม่ควรใช้ชื่อที่ผู้เล่นเปลี่ยนได้แทน ID หากระบบต้องผูกกับ Discord Account

⑱ IP Identifier คืออะไร

Cfx.re ระบุ ip เป็น Identifier ประเภท IP Address และ Data Type เป็น IPv4 String.

ตัวอย่าง:

ip:192.0.2.1

IP ควรถือเป็นข้อมูล Network ที่ต้องจัดการอย่างระมัดระวัง ไม่ควรโพสต์ Identifier ของผู้เล่นลงสาธารณะโดยไม่จำเป็น

⑲ IP เหมาะใช้เป็น Account หลักไหม

ไม่ควรใช้ IP เป็น Persistent Identity เพียงตัวเดียว เพราะ Network Address สามารถเปลี่ยนหรือถูกใช้ร่วมกันได้ตาม Network Environment

สำหรับ Identity หลัก FiveM มี Identifiers จาก Provider อื่นที่ออกแบบมาเพื่อระบุ Account มากกว่า IP Address.

⑳ ซ่อน IP จาก Public Server Reports ได้ไหม

FXServer มีตัวแปร:

sv_endpointPrivacy true

Cfx.re ระบุว่าหากเปิดค่า sv_endpointPrivacy Server จะซ่อน IP Address ของผู้เล่นจาก Public Reports ที่ Server ส่งออก.

นี่เป็น Server Privacy Setting ที่ควรพิจารณาสำหรับ Public Server

㉑ วิธีดู FiveM Identifier จาก Script

Cfx.re มีฟังก์ชัน:

GetPlayerIdentifiers(source)

ซึ่งคืน Table ของ Identifiers ของ Player.

ตัวอย่างแบบพื้นฐาน:

local identifiers = GetPlayerIdentifiers(source)

for _, identifier in ipairs(identifiers) do
    print(identifier)
end

ควรใช้สำหรับ Development/Administration และหลีกเลี่ยงการพิมพ์ข้อมูลผู้เล่นลง Public Logs โดยไม่จำเป็น

㉒ วิธีแยก Identifier ตามประเภท

รูปแบบจาก Documentation สามารถแยก Prefix ก่อน : แล้วเก็บเป็น Table ตามประเภทได้.

ตัวอย่าง:

local ids = {}

for _, identifier in ipairs(GetPlayerIdentifiers(source)) do
    local identifierType = identifier:match("^([^:]+):")
    if identifierType then
        ids[identifierType] = identifier
    end
end

จากนั้นสามารถอ่าน:

print(ids.license)
print(ids.license2)
print(ids.fivem)

โดยควรตรวจว่าค่ามีอยู่ก่อนใช้งาน

㉓ ถ้าต้องการ Identifier ประเภทเดียวต้อง Loop ทุกตัวไหม

Cfx.re ระบุว่า หากต้องการ Identifier เพียงประเภทเดียว สามารถใช้ Native สำหรับดึง Identifier ตาม Type ได้ ส่วน GetPlayerIdentifiers เหมาะเมื่อจำเป็นต้องดึงหลายประเภท.

Developer จึงควรเลือก API ให้เหมาะกับงาน

㉔ ดู Identifier จาก Server Console ได้ไหม

คำสั่ง:

status

สามารถแสดง Player พร้อม Primary Identifier, Server ID, Name, Endpoint และ Ping หาก rconlog Resource ที่ให้ Command นี้ทำงานอยู่.

เหมาะสำหรับตรวจสอบเบื้องต้น แต่ Resource ที่ต้องการ Identifier หลายประเภทควรใช้ API โดยตรง

㉕ status ไม่ได้แสดง Identifier ทุกประเภท

status แสดง Primary Identifier ตาม Server Command Documentation ไม่ได้หมายความว่าจะพิมพ์รายการ license, license2, discord, fivem และอื่นๆ ทั้งหมด.

หากต้องการหลาย Identifier ให้ใช้ GetPlayerIdentifiers

㉖ Identifier ดูตอน Player Connecting ได้ไหม

ได้

Cfx.re ยกตัวอย่างการเรียก GetPlayerIdentifiers(player) ภายใน playerConnecting และอีกตัวอย่างใช้ License Identifier ตรวจ Ban List ก่อนให้ Player เข้า Server.

นี่จึงเป็นจุดที่พบการใช้ Identifier มากในระบบ Authentication และ Allowlist

㉗ playerConnecting คืออะไร

playerConnecting เป็น Server Event ที่เกิดขึ้นขณะ Player กำลังเชื่อม Server

ระบบสามารถใช้ Deferrals เพื่อรอการตรวจสอบ และสามารถปฏิเสธ Connection พร้อม Failure Reason ได้ตาม API ที่ Cfx.re ระบุ.

Resource ประเภท Ban/Allowlist จึงมักทำงานในช่วงนี้

㉘ Identifier ใช้กับ ACE Permission ได้อย่างไร

ACE Permission สามารถผูก Principal กับ Group ได้

รูปแบบเชิงโครงสร้าง:

add_principal identifier.TYPE:VALUE group.admin

สิ่งสำคัญคือใช้ Identifier จริงของ Admin และใช้ประเภท Identifier ที่ Server/Resource ออกแบบให้รองรับ

ไม่ควร Copy Identifier จาก Tutorial

㉙ ตัวอย่างโครงสร้าง Admin Permission

ตัวอย่างเพื่ออธิบาย:

add_ace group.admin command.example allow
add_principal identifier.example:ADMIN_IDENTIFIER group.admin

แนวคิดคือ:

Identifier ของ Admin → group.admin → ACE Permissions

หลังตั้งค่าแล้วควรตรวจ Principal และ Permission ตาม Workflow ACE แทนการแจกสิทธิ์กว้างโดยไม่ตรวจ

㉚ ควรใช้ Identifier ไหนกับ Admin

ไม่ควรมีคำตอบแบบตายตัวว่า “Steam เท่านั้น” หรือ “Discord เท่านั้น”

ควรพิจารณา:

  • Server Framework

  • Resource ที่ใช้

  • Identifier ที่มีเสถียรภาพสำหรับ Use Case

  • Documentation ของ Permission System

  • Identifier ที่ Server ได้รับจริง

สำหรับระบบใหม่ Cfx.re ระบุว่า License Identifier มาจาก Rockstar Online Services และเมื่อมีทั้ง license กับ license2 ควร prefer license2.

㉛ อย่าใช้ Server ID ใน add_principal

ตัวอย่างที่ไม่ควรออกแบบ:

add_principal 17 group.admin

เพราะ Server ID เช่น 17 เป็น ID ของ Player Connection ปัจจุบัน ไม่ใช่ Persistent Identifier

ควรใช้ Principal Identifier รูปแบบที่ระบบ ACE/Server ของคุณรองรับ

㉜ Admin เปลี่ยนชื่อแล้ว Permission หายไหม

หาก Permission ผูกกับ Identifier ที่เหมาะสม ไม่ควรขึ้นกับ Display Name ของ Player

นี่เป็นข้อได้เปรียบของ Identifier เมื่อเทียบกับการผูก Permission จากชื่อที่ผู้ใช้สามารถเปลี่ยนได้

㉝ Identifier ใช้ทำ Allowlist ได้ไหม

ได้ตามการออกแบบของ Resource

ตัวอย่าง Official playerConnecting ของ Cfx.re แสดงการดึง License Identifier ก่อนตัดสินใจว่าจะอนุญาตหรือปฏิเสธ Player Connection.

แนวคิดเดียวกันสามารถถูกใช้กับ Allowlist System ที่ตรวจ Identifier กับ Database

㉞ Identifier ใช้ทำ Ban ได้ไหม

ตัวอย่าง Cfx.re ใช้ License Identifier ตรวจ Ban List โดยตรงใน playerConnecting.

Server Owner ควรใช้ระบบ Ban ที่จัดเก็บข้อมูลอย่างเป็นระบบและมีเหตุผล Moderation ชัดเจน แทนการเก็บข้อมูลผู้เล่นมากเกินความจำเป็น

㉟ txAdmin จัดการ Player ได้ไหม

txAdmin มี Player Management Permissions เช่น:

  • players.whitelist

  • players.warn

  • players.kick

  • players.ban

และสามารถจำกัดว่า Admin คนใดทำ Action ใดได้.

ดังนั้น Server ที่ใช้ txAdmin ไม่จำเป็นต้องสร้างระบบ Staff Permissions ทุกอย่างจาก ACE เอง

㊱ ACE กับ txAdmin Player Permissions คนละระบบ

ACE เป็น Access Control ระดับ FXServer

ส่วน txAdmin มี Permission System แยก เช่น:

players.whitelist
players.kick
players.ban

รวมถึง Console และ Server Control Permissions.

จึงควรแยกให้ชัดว่า Permission ที่กำลังแก้อยู่มาจากระบบใด

㊲ Identifier ควรเก็บใน Database อย่างไร

หลักสำคัญคือเก็บเฉพาะข้อมูลที่ Resource ต้องใช้จริง และไม่เปิดเผย Identifier ต่อสาธารณะโดยไม่จำเป็น

ก่อนออกแบบ Schema ให้กำหนดก่อนว่า:

  • Identifier ไหนเป็น Primary

  • รองรับ Identifier สำรองหรือไม่

  • จะทำอย่างไรเมื่อ Identifier บางประเภทไม่มี

  • Resource เดิมใช้ Type ไหน

  • Migration จะทำอย่างไร

อย่า Hard-code Database โดยสมมติว่าทุก Player ต้องมี Steam หรือ Discord Identifier

㊳ อย่าใช้ Display Name เป็น Primary Account Key

ชื่อ Player สามารถเปลี่ยนได้และอาจซ้ำกันได้

ระบบ Account จึงควรใช้ Identifier ที่เหมาะสมกับ Server Architecture แทน

Display Name เหมาะสำหรับแสดงผล ไม่ใช่ตัวระบุ Persistent Identity หลัก

㊴ Identifier หลายตัวควรเก็บทั้งหมดไหม

ไม่จำเป็นต้องเก็บทุกอย่างเพียงเพราะ Server สามารถอ่านได้

ให้เก็บเฉพาะข้อมูลที่จำเป็นต่อ:

  • Permission

  • Account

  • Moderation

  • Resource Functionality

โดยเฉพาะ IP Address ควรหลีกเลี่ยงการเก็บหรือเผยแพร่เกินความจำเป็น

㊵ FiveM Identifier ไม่ขึ้น แก้อย่างไร

ตรวจตามลำดับ:

  1. Player เชื่อม Server แล้วหรือไม่

  2. ใช้ GetPlayerIdentifiers ฝั่ง Server หรือไม่

  3. ตรวจรายการ Identifier ที่ได้รับจริง

  4. อย่าคาดหวังทุก Prefix

  5. ตรวจ Resource Error

  6. ตรวจ Server Artifact/Configuration

  7. ถ้าต้องการ Steam Identifier ให้ตรวจ Steam API Configuration

Cfx.re ระบุประเภท Identifier ที่สามารถคืนได้ และ Server Commands ระบุ steam_webApiKey เป็น Requirement สำหรับการคืน Steam Identifiers.

㊶ Steam Identifier ไม่ขึ้น

ตรวจ steam_webApiKey ก่อน

Cfx.re ระบุว่า Server Variable นี้ต้องมีเพื่อให้ Steam Identifiers ถูกคืนโดย Server.

แต่ Resource ใหม่ไม่ควรถูกออกแบบให้ Steam เป็น Identity เพียงประเภทเดียวหากไม่มีเหตุผลเฉพาะ

㊷ Discord Identifier ไม่ขึ้น

อย่าแก้ด้วยการสร้าง Discord ID เอง

ให้ตรวจรายการจริงจาก:

GetPlayerIdentifiers(source)

ก่อน

หากไม่มี discord: Resource ต้องรองรับกรณี Identifier ประเภทนั้นไม่พร้อม แทนการ Assume ว่าทุก Session ต้องมี.

㊸ license กับ license2 ค่าเหมือนกันได้ไหม

ได้

Cfx.re ระบุว่า license2 สำหรับผู้ใช้ Steam สามารถมีค่าเดียวกับ license.

ดังนั้น Database Logic ไม่ควรสมมติว่าทั้งสองค่าจะต่างกันเสมอ

㊹ Resource ใช้ license แต่ Server มี license2 ด้วยทำอย่างไร

ถ้า Resource เดิมออกแบบมาสำหรับ license อย่าเปลี่ยน Database Key แบบทันทีโดยไม่มี Migration Plan

แต่สำหรับระบบใหม่ Cfx.re ระบุว่าเมื่อทั้ง license และ license2 พร้อม ควร prefer license2.

Resource เก่าควรตรวจ Documentation และ Compatibility ก่อนเปลี่ยน

㊺ Identifier เปลี่ยนแล้วข้อมูล Player หาย

หาก Resource ใช้ Identifier ประเภทที่ไม่เหมาะสมเป็น Primary Key อาจเกิด Account Mapping Problem

จึงควรตรวจ Identifier Strategy ก่อนเปิด Production Server

โดยเฉพาะ Migration Server เก่าควร Backup Database ก่อนเปลี่ยน Primary Identifier

㊻ FiveM Identifier กับ Hardware Token เหมือนกันไหม

ไม่เหมือนกัน

Cfx.re แยก Player Identifiers ออกจาก Hardware-related Player Tokens และระบุว่า Hardware-related Identifiers สามารถเข้าถึงผ่าน GetNumPlayerTokens และ GetPlayerToken.

ดังนั้นอย่าเรียกทุกค่าเกี่ยวกับ Player ว่า License Identifier

㊼ Identifier กับ Network ID เหมือนกันไหม

ไม่เหมือนกัน

FiveM ยังมี Entity/Network Identifiers เช่น Handles, PlayerIds และ NetIDs ซึ่งใช้สำหรับ Entity Networking ไม่ใช่ Account Identity แบบ license: หรือ fivem:.

นี่เป็นสองระบบที่ทำหน้าที่ต่างกัน

㊽ Player Name, Server ID และ Identifier ต่างกันอย่างไร

ค่าใช้ทำอะไร
Player Nameชื่อแสดงผล
Server IDอ้าง Player ใน Session
license:Rockstar Online Services Identifier
license2:ROS License Identifier อีกประเภท
fivem:Cfx User Identifier
steam:Steam Identifier
discord:Discord User Identifier
ip:Network Address

ประเภท Identifier อ้างอิงจาก Cfx.re GetPlayerIdentifiers Documentation.

㊾ Checklist เลือก Identifier สำหรับ Resource

ก่อนเขียนระบบ Player Account ให้ตรวจ:

  1. Resource ต้องการ Persistent Identity หรือไม่

  2. ใช้ Identifier ประเภทใดเป็น Primary

  3. รองรับ license2 หรือไม่

  4. Identifier นั้นมีทุก Session ที่ต้องรองรับหรือไม่

  5. มี Fallback หรือไม่

  6. Database เดิมใช้ Type อะไร

  7. ACE Permission ใช้ Type ไหน

  8. Allowlist/Ban ใช้ Type ไหน

  9. หลีกเลี่ยงใช้ IP เป็น Identity หลัก

  10. ไม่เปิดเผย Identifier ต่อ Public Logs โดยไม่จำเป็น

㊿ Checklist สำหรับ Server Owner

เวลาตั้ง Admin หรือ Resource ใหม่:

ดู Identifier จริง
↓
เลือกประเภทที่ Resource รองรับ
↓
เพิ่ม Permission/Database
↓
Reconnect ทดสอบ
↓
ตรวจว่า Permission ยังทำงาน

อย่า Copy Identifier จากบทความหรือ Video เพราะแต่ละ Player มีค่าของตัวเอง

ตัวอย่าง Lua ดู Identifiers แบบอ่านง่าย

RegisterCommand("myids", function(source)
    if source == 0 then
        print("Run this command as a player.")
        return
    end

    local identifiers = GetPlayerIdentifiers(source)

    for _, identifier in ipairs(identifiers) do
        print(identifier)
    end
end, false)

ตัวอย่างนี้แสดงแนวคิดการเรียก GetPlayerIdentifiers ตาม API ของ Cfx.re.

สำหรับ Production Server ไม่ควรเปิด Command ที่แสดงข้อมูล Identifier ให้ผู้เล่นทุกคนโดยไม่มีเหตุผล ควรจำกัดการใช้งานสำหรับ Development/Admin ตามความจำเป็น

ตัวอย่างแยก license, license2 และ fivem

local identifiers = {}

for _, identifier in ipairs(GetPlayerIdentifiers(source)) do
    local identifierType = identifier:match("^([^:]+):")

    if identifierType then
        identifiers[identifierType] = identifier
    end
end

local license = identifiers.license
local license2 = identifiers.license2
local fivem = identifiers.fivem

แนวคิดนี้สอดคล้องกับตัวอย่าง Cfx.re ที่แยก Identifier จาก Prefix แล้วเก็บเป็น Table ตาม Type.

ตัวอย่างเลือก license2 ก่อน license

สำหรับระบบใหม่ที่ต้องการทำตามคำแนะนำการ Migration ปัจจุบัน:

local identifiers = {}

for _, identifier in ipairs(GetPlayerIdentifiers(source)) do
    local identifierType = identifier:match("^([^:]+):")
    if identifierType then
        identifiers[identifierType] = identifier
    end
end

local primaryLicense = identifiers.license2 or identifiers.license

Cfx.re ระบุว่าเมื่อมีทั้งสองประเภทควร prefer license2.

อย่างไรก็ตาม หาก Server มี Database เดิมที่ใช้ license อยู่แล้ว ต้องออกแบบ Migration ก่อนเปลี่ยน Key จริง

FAQ FiveM Identifier

FiveM Identifier คืออะไร

เป็นตัวระบุ Player จาก Provider ต่างๆ เช่น Rockstar Online Services, Cfx, Steam, Discord และ IP ซึ่ง Server สามารถดึงผ่าน GetPlayerIdentifiers.

FiveM license กับ license2 ต่างกันอย่างไร

ทั้งสองมาจาก Rockstar Online Services โดย Cfx.re ระบุว่า license2 อาจมีค่าเดียวกับ license สำหรับผู้ใช้ Steam และเมื่อทั้งสองมีอยู่ควร prefer license2.

Steam Identifier มีทุกคนไหม

ไม่ควรสมมติว่ามี และ Cfx.re ระบุว่า Server ต้องมี steam_webApiKey เพื่อให้ Steam Identifiers ถูกคืน.

Discord Identifier มีทุกคนไหม

ไม่ควรสมมติว่ามี ให้ตรวจรายการที่ GetPlayerIdentifiers() คืนมาจริงก่อนใช้งาน.

FiveM Identifier ดูจาก Console ได้ไหม

คำสั่ง status สามารถแสดง Primary Identifier ของ Player ได้ แต่หากต้องการ Identifiers หลายประเภทควรใช้ GetPlayerIdentifiers.

Identifier ใช้ทำ Ban ได้ไหม

ได้ตามการออกแบบของ Resource โดย Cfx.re มีตัวอย่าง playerConnecting ที่ตรวจ License Identifier กับ Ban List ก่อนอนุญาตให้ Player เชื่อมต่อ.

Identifier ใช้กับ Admin Permission ได้ไหม

ได้เมื่อ Permission System ใช้ Identifier Principal แต่ต้องใช้ Identifier จริงของ Admin และประเภทที่ระบบนั้นรองรับ ไม่ควรใช้ Player Name หรือ Server ID แทน Persistent Identifier

สรุปสำคัญ

FiveM Identifier คือข้อมูลที่ใช้ระบุ Player โดยประเภทหลักที่ Cfx.re ระบุประกอบด้วย steam, discord, license, license2, fivem และ ip และสามารถอ่านรายการเหล่านี้จากฝั่ง Server ด้วย GetPlayerIdentifiers().

สำหรับ Rockstar Online Services Identifier จุดสำคัญคือ license2 สามารถมีค่าเหมือน license และ Cfx.re ระบุว่าเมื่อทั้งคู่มีอยู่ควร prefer license2 สำหรับระบบที่กำลังออกแบบใหม่.

Steam Identifier ไม่ควรถูกถือว่ามีเสมอ และ Cfx.re ระบุว่า Server ต้องตั้ง steam_webApiKey เพื่อให้ Steam Identifiers ถูกคืน ส่วน status จะแสดงเพียง Primary Identifier จึงควรใช้ API หากต้องการรายการ Identifier หลายประเภท.

ในการทำ Allowlist หรือ Ban Cfx.re มีตัวอย่างอย่างเป็นทางการที่ตรวจ License Identifier ภายใน playerConnecting ก่อนตัดสินใจว่าจะอนุญาตให้ผู้เล่นเข้า Server หรือไม่.

สำหรับผู้อ่าน comsiam ให้จำว่า “Server ID ใช้ใน Session แต่ Identifier ใช้ระบุตัว Player ตาม Provider” และ comsiam แนะนำให้ Server Owner เลือก Identifier Strategy ตั้งแต่ก่อนสร้าง Database พร้อมหลีกเลี่ยงการเปิดเผย IP หรือ Identifier ของผู้เล่นต่อสาธารณะโดยไม่จำเป็น

Comments

Popular posts from this blog

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

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

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