Skip to content

Commit 4911dec

Browse files
authored
Merge branch 'qbcore-framework:main' into main
2 parents cf33903 + 5cf9f4b commit 4911dec

File tree

4 files changed

+231
-18
lines changed

4 files changed

+231
-18
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Semantic Version Bump (Conventional Commits)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
semver-bump:
10+
runs-on: ubuntu-latest
11+
if: github.event.head_commit.author.name != 'github-actions[bot]'
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Determine bump type from commit message
18+
id: bump
19+
run: |
20+
COMMIT_MSG="${{ github.event.head_commit.message }}"
21+
echo "🔍 Commit message: $COMMIT_MSG"
22+
23+
if echo "$COMMIT_MSG" | grep -qE 'BREAKING CHANGE|!:'; then
24+
echo "bump=major" >> $GITHUB_OUTPUT
25+
elif echo "$COMMIT_MSG" | grep -qE '^feat(\(.+\))?:'; then
26+
echo "bump=minor" >> $GITHUB_OUTPUT
27+
elif echo "$COMMIT_MSG" | grep -qE '^fix(\(.+\))?:'; then
28+
echo "bump=patch" >> $GITHUB_OUTPUT
29+
else
30+
echo "bump=none" >> $GITHUB_OUTPUT
31+
fi
32+
33+
- name: Bump version in fxmanifest.lua
34+
if: steps.bump.outputs.bump != 'none'
35+
run: |
36+
FILE="fxmanifest.lua"
37+
VERSION_LINE=$(grep -E "version ['\"]?[0-9]+\.[0-9]+\.[0-9]+['\"]?" "$FILE")
38+
VERSION=$(echo "$VERSION_LINE" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+")
39+
40+
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
41+
42+
case "${{ steps.bump.outputs.bump }}" in
43+
major)
44+
MAJOR=$((MAJOR + 1))
45+
MINOR=0
46+
PATCH=0
47+
;;
48+
minor)
49+
MINOR=$((MINOR + 1))
50+
PATCH=0
51+
;;
52+
patch)
53+
PATCH=$((PATCH + 1))
54+
;;
55+
esac
56+
57+
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
58+
sed -i "s/version ['\"]$VERSION['\"]/version '$NEW_VERSION'/" "$FILE"
59+
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
60+
61+
- name: Commit and push version bump
62+
if: steps.bump.outputs.bump != 'none'
63+
run: |
64+
git config user.name "github-actions[bot]"
65+
git config user.email "github-actions[bot]@users.noreply.github.com"
66+
git add fxmanifest.lua
67+
68+
if git diff --cached --quiet; then
69+
echo "⚠️ No version changes to commit."
70+
exit 0
71+
fi
72+
73+
COMMIT_MSG="${{ github.event.head_commit.message }}"
74+
git commit -m "ci: bump fxmanifest version to ${{ env.new_version }} – $COMMIT_MSG"
75+
git push

locale/cn.lua renamed to locale/zh-cn.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ local Translations = {
120120
},
121121
}
122122

123-
if GetConvar('qb_locale', 'en') == 'cn' then
123+
if GetConvar('qb_locale', 'en') == 'zh-cn' then
124124
Lang = Locale:new({
125125
phrases = Translations,
126126
warnOnMissing = true,
127127
fallbackLang = Lang,
128128
})
129-
end
129+
end

locale/zh-tw.lua

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
local Translations = {
2+
error = {
3+
not_online = '玩家不在線上',
4+
wrong_format = '格式不正確',
5+
missing_args = '尚未輸入所有參數 (x, y, z)',
6+
missing_args2 = '必須填寫所有參數!',
7+
no_access = '無法使用此指令',
8+
company_too_poor = '您的雇主已破產',
9+
item_not_exist = '物品不存在',
10+
too_heavy = '背包已滿',
11+
location_not_exist = '位置不存在',
12+
duplicate_license = '[QBCORE] - 發現重複的 Rockstar 授權',
13+
no_valid_license = '[QBCORE] - 找不到有效的 Rockstar 授權',
14+
not_whitelisted = '[QBCORE] - 您不在此伺服器的白名單中',
15+
server_already_open = '伺服器已經開啟',
16+
server_already_closed = '伺服器已經關閉',
17+
no_permission = '您沒有此權限..',
18+
no_waypoint = '尚未設置導航點',
19+
tp_error = '傳送時發生錯誤',
20+
ban_table_not_found = '[QBCORE] - 無法在資料庫中找到封禁清單。請確認您已正確匯入 SQL 檔案。',
21+
connecting_database_error = '[QBCORE] - 連接資料庫時發生錯誤。請確保 SQL 伺服器正在運行,且 server.cfg 檔案中的設定正確。',
22+
connecting_database_timeout = '[QBCORE] - 資料庫連接超時。請確保 SQL 伺服器正在運行,且 server.cfg 檔案中的設定正確。',
23+
},
24+
success = {
25+
server_opened = '伺服器已經開啟',
26+
server_closed = '伺服器已經關閉',
27+
teleported_waypoint = '傳送至導航點。',
28+
},
29+
info = {
30+
received_paycheck = '您收到了 $%{value} 的薪水',
31+
job_info = '工作: %{value} | 等級: %{value2} | 上班狀態: %{value3}',
32+
gang_info = '幫派: %{value} | 等級: %{value2}',
33+
on_duty = '您現在已經上班了!',
34+
off_duty = '您現在已經下班了!',
35+
checking_ban = '你好 %s,我們正在檢查您是否被封禁',
36+
join_server = '歡迎 %s 加入 {Server Name}',
37+
checking_whitelisted = '你好 %s,我們正在檢查您的白名單權限',
38+
exploit_banned = '您因作弊行為而被封禁。請查看我們的 Discord 以獲取更多資訊: %{discord}',
39+
exploit_dropped = '您因使用外掛程式而被踢出伺服器',
40+
},
41+
command = {
42+
tp = {
43+
help = '傳送至玩家或座標 (僅限管理員)',
44+
params = {
45+
x = { name = 'id/x', help = '玩家 ID 或 X 座標' },
46+
y = { name = 'y', help = 'Y 座標' },
47+
z = { name = 'z', help = 'Z 座標' },
48+
},
49+
},
50+
tpm = { help = '傳送至標記點 (僅限管理員)' },
51+
togglepvp = { help = '切換伺服器 PVP 狀態 (僅限管理員)' },
52+
addpermission = {
53+
help = '給予玩家權限 (僅限最高權限)',
54+
params = {
55+
id = { name = 'id', help = '玩家 ID' },
56+
permission = { name = 'permission', help = '權限等級' },
57+
},
58+
},
59+
removepermission = {
60+
help = '移除玩家權限 (僅限最高權限)',
61+
params = {
62+
id = { name = 'id', help = '玩家 ID' },
63+
permission = { name = 'permission', help = '權限等級' },
64+
},
65+
},
66+
openserver = { help = '開放伺服器給所有人 (僅限管理員)' },
67+
closeserver = {
68+
help = '關閉伺服器給無權限者 (僅限管理員)',
69+
params = {
70+
reason = { name = 'reason', help = '關閉原因 (選填)' },
71+
},
72+
},
73+
car = {
74+
help = '生成載具 (僅限管理員)',
75+
params = {
76+
model = { name = 'model', help = '載具型號名稱' },
77+
},
78+
},
79+
dv = { help = '刪除載具 (僅限管理員)' },
80+
dvall = { help = '刪除所有載具 (僅限管理員)' },
81+
dvp = { help = '刪除所有 NPC (僅限管理員)' },
82+
dvo = { help = '刪除所有物件 (僅限管理員)' },
83+
givemoney = {
84+
help = '給予玩家金錢 (僅限管理員)',
85+
params = {
86+
id = { name = 'id', help = '玩家 ID' },
87+
moneytype = { name = 'moneytype', help = '金錢類型 (現金, 銀行, 加密貨幣)' },
88+
amount = { name = 'amount', help = '金額' },
89+
},
90+
},
91+
setmoney = {
92+
help = '設定玩家金錢數量 (僅限管理員)',
93+
params = {
94+
id = { name = 'id', help = '玩家 ID' },
95+
moneytype = { name = 'moneytype', help = '金錢類型 (現金, 銀行, 加密貨幣)' },
96+
amount = { name = 'amount', help = '金額' },
97+
},
98+
},
99+
job = { help = '查看你的工作' },
100+
setjob = {
101+
help = '設定玩家工作 (僅限管理員)',
102+
params = {
103+
id = { name = 'id', help = '玩家 ID' },
104+
job = { name = 'job', help = '工作名稱' },
105+
grade = { name = 'grade', help = '工作等級' },
106+
},
107+
},
108+
gang = { help = '查看你所在的幫派' },
109+
setgang = {
110+
help = '設定玩家幫派 (僅限管理員)',
111+
params = {
112+
id = { name = 'id', help = '玩家 ID' },
113+
gang = { name = 'gang', help = '幫派名稱' },
114+
grade = { name = 'grade', help = '幫派等級' },
115+
},
116+
},
117+
ooc = { help = 'OOC 聊天訊息' },
118+
me = {
119+
help = '顯示本地訊息',
120+
params = {
121+
message = { name = 'message', help = '要發送的訊息' }
122+
},
123+
},
124+
},
125+
}
126+
127+
if GetConvar('qb_locale', 'en') == 'zh-tw' then
128+
Lang = Locale:new({
129+
phrases = Translations,
130+
warnOnMissing = true,
131+
fallbackLang = Lang,
132+
})
133+
end

server/functions.lua

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ QBCore.UsableItems = {}
77
-- Get your player first and then trigger a function on them
88
-- ex: local player = QBCore.Functions.GetPlayer(source)
99
-- ex: local example = player.Functions.functionname(parameter)
10-
1110
---Gets the coordinates of an entity
1211
---@param entity number
1312
---@return vector4
@@ -133,15 +132,21 @@ function QBCore.Functions.GetQBPlayers()
133132
return QBCore.Players
134133
end
135134

136-
---Gets a list of all on duty players of a specified job and the number
137-
---@param job string
138-
---@return table, number
139-
function QBCore.Functions.GetPlayersOnDuty(job)
135+
--- Gets a list of all online players of a specified job or job type and the number
136+
--- @param job string
137+
--- @param checkOnDuty boolean If true, only players on duty will be returned
138+
function QBCore.Functions.GetPlayersByJob(job, checkOnDuty)
140139
local players = {}
141140
local count = 0
142141
for src, Player in pairs(QBCore.Players) do
143-
if Player.PlayerData.job.name == job then
144-
if Player.PlayerData.job.onduty then
142+
local playerData = Player.PlayerData
143+
if playerData.job.name == job or playerData.job.type == job then
144+
if checkOnDuty then
145+
if playerData.job.onduty then
146+
players[#players + 1] = src
147+
count += 1
148+
end
149+
else
145150
players[#players + 1] = src
146151
count += 1
147152
end
@@ -150,18 +155,19 @@ function QBCore.Functions.GetPlayersOnDuty(job)
150155
return players, count
151156
end
152157

158+
---Gets a list of all on duty players of a specified job and the number
159+
---@param job string
160+
---@return table, number
161+
function QBCore.Functions.GetPlayersOnDuty(job)
162+
local players, count = QBCore.Functions.GetPlayersByJob(job, true)
163+
return players, count
164+
end
165+
153166
---Returns only the amount of players on duty for the specified job
154167
---@param job string
155168
---@return number
156169
function QBCore.Functions.GetDutyCount(job)
157-
local count = 0
158-
for _, Player in pairs(QBCore.Players) do
159-
if Player.PlayerData.job.name == job then
160-
if Player.PlayerData.job.onduty then
161-
count += 1
162-
end
163-
end
164-
end
170+
local _, count = QBCore.Functions.GetPlayersByJob(job, true)
165171
return count
166172
end
167173

@@ -734,6 +740,5 @@ for functionName, func in pairs(QBCore.Functions) do
734740
exports(functionName, func)
735741
end
736742
end
737-
738743
-- Access a specific function directly:
739744
-- exports['qb-core']:Notify(source, 'Hello Player!')

0 commit comments

Comments
 (0)