1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-07-12 20:30:08 +02:00
parent 08a306e1ff
commit fbf0b6b47f
23 changed files with 1547 additions and 10408 deletions

View file

@ -0,0 +1,74 @@
# Contributor Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race,
religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team in the discord at https://discord.com/invite/qbcore. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org

View file

@ -0,0 +1,71 @@
name: Bug report
description: Create a report to help us improve or fix something
title: "[BUG]"
labels: bug
body:
- type: markdown
attributes:
value: |
Thank you for taking the time to fill out a bug report!
Please use our Discord Server to ask questions and receive support: https://discord.gg/qbcore
- type: input
id: summary
attributes:
label: Summary
description: Write a short and concise description of your bug.
validations:
required: true
- type: textarea
id: repro
attributes:
label: Reproduction
description: What did you do to make this happen?
placeholder: |
1. Using ...
2. Do ...
3. Then use ...
4. See error
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: What did you expect to happen?
validations:
required: true
- type: textarea
id: actual
attributes:
label: Actual behavior
description: What actually happened?
validations:
required: true
- type: textarea
id: additional
attributes:
label: Additional context
description: If you have any other context about the problem such as screenshots or videos, add them here.
- type: input
id: updated
attributes:
label: Last Updated
description: When have you last updated?
placeholder: e.g. last week, today
validations:
required: true
- type: input
id: custom
attributes:
label: Custom Resources
description: Are you using custom resources? Which ones?
placeholder: e.g. zdiscord, qb-target
validations:
required: true
- type: input
id: renamed
attributes:
label: Resource Rename
description: Have you renamed this resource from `qb-` to something custom?
validations:
required: true

View file

@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: QBCore Discord Server
url: https://discord.gg/qbcore
about: Ask questions, receive support, and discuss with the community in our Discord server.

View file

@ -0,0 +1,37 @@
name: Feature request
description: Suggest an idea for QBCore
title: "[SUGGESTION]"
labels: enhancement
body:
- type: markdown
attributes:
value: |
Please use our Discord Server to ask questions and receive support: https://discord.gg/qbcore
- type: textarea
id: problem
attributes:
label: The problem
description: A clear and concise description of what the problem is, or what feature you want to be implemented.
placeholder: |
Some examples:
I'm frustrated that ...
It would be nice if ...
validations:
required: true
- type: textarea
id: solution
attributes:
label: Ideal solution
description: A clear and concise description of what you want to happen, with as much detail as possible.
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Alternative solutions
description: A clear and concise description of any alternative solutions or features you've considered.
- type: textarea
id: additional
attributes:
label: Additional context
description: If you have any other context about the problem such as screenshots or videos, add them here.

View file

@ -0,0 +1,17 @@
# Set to true to add reviewers to pull requests
addReviewers: true
# Set to true to add assignees to pull requests
addAssignees: author
# A list of reviewers to be added to pull requests (GitHub user name)
reviewers:
- qbcore-framework/maintenance
# A list of keywords to be skipped the process that add reviewers if pull requests include it
skipKeywords:
- wip
# A number of reviewers added to the pull request
# Set 0 to add all the reviewers (default: 0)
numberOfReviewers: 0

View file

@ -0,0 +1,201 @@
# Contributing to QBCore
First of all, thank you for taking the time to contribute!
These guidelines will help you help us in the best way possible regardless of your skill level. We ask that you try to read everything related to the way you'd like to contribute and try and use your best judgement for anything not covered.
### Table of Contents
[Code of Conduct](#code-of-conduct)
[I don't want to read this whole thing, I just have a question!!!](#i-dont-want-to-read-this-whole-thing-i-just-have-a-question)
[How Can I Contribute?](#how-can-i-contribute)
* [Reporting Bugs](#reporting-bugs)
* [Suggesting Features / Enhancements](#suggesting-features--enhancements)
* [Your First Code Contribution](#your-first-code-contribution)
* [Pull Requests](#pull-requests)
[Styleguides](#styleguides)
* [Git Commit Messages](#git-commit-messages)
* [Lua Styleguide](#lua-styleguide)
* [JavaScript Styleguide](#javascript-styleguide)
## Code of Conduct
- Refrain from using languages other than English.
- Refrain from discussing any politically charged or inflammatory topics.
- Uphold mature conversations and respect each other; excessive profanity, hate speech or any kind of harassment will not be tolerated.
- No advertising of any kind.
- Follow these guidelines.
- Do not mention members of github unless a question is directed at them and can't be answered by anyone else.
- Do not mention any of the development team for any reason. We will read things as we get to them.
## I don't want to read this whole thing I just have a question!!!
> **Note:** Please don't file an issue to ask a question. You'll get faster results by using the resources below.
* [QBCore Website](https://qbcore.org)
* [QBCore Discord](https://discord.gg/qbcore)
* [FiveM Discord - #qbcore channel](https://discord.gg/fivem)
## How Can I Contribute?
### Reporting Bugs
The easiest way to contribute for most people is just to report bugs you find cause if nobody reports it there's a chance we'll never know it exists and then we'll never fix it.
Before creating bug reports, please check [this list](#before-submitting-a-bug-report) as you might find out that you don't need to create one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). Fill out the bug-report template with the information it asks for helps us resolve issues faster.
> **Note:** If you find a **Closed** issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one.
#### Before Submitting A Bug Report
* **Check the docs** There's a chance what you see as a bug might just work differently than you expect and if you think it could work better consider a feature enhancement report instead.
* **Search the [discord](https://discord.gg/qbcore)** to see if anyone else has run into the issue and see if it was solved through user error or code changes. (if the code change isn't pending a PR and you know what you're doing consider submitting one following [Pull Requests](#pull-requests) )
* **Determine which resource the problem should be reported in**. If the bug is related to the inventory for example report this bug under qb-inventory rather than under qb-core or some other resource.
* **Perform a [cursory search](https://github.com/search?q=+is%3Aissue+user%3Aqbcore-framework)** to see if the problem has already been reported. If it has **and the issue is still open**, add a comment to the existing issue instead of opening a new one.
#### How Do I Submit A (Good) Bug Report?
Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you've determined which resource your bug is related to, create an issue on that repository and provide the following information by filling in bug-report template.
Explain the problem and include additional details to help maintainers reproduce the problem:
* **Use a clear and descriptive title** for the issue to identify the problem.
* **Describe the exact steps which reproduce the problem** in as many details as possible.
* **Provide specific examples to demonstrate the steps**. If something happened with only a specific group or single item but not others, specify that.
* **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior.
* **Explain which behavior you expected to see instead and why.**
* **Include screenshots** which show the specific bug in action or before and after.
* **If the problem wasn't triggered by a specific action**, describe what you were doing before the problem happened and share more information using the guidelines below.
Provide more context by answering these questions if possible:
* **Did the problem start happening recently** (e.g. after updating to a new version of QBCore?) or was this always a problem?
* If the problem started happening recently, **can you reproduce the problem in an older version of QBCore?** What's the most recent commit in which the problem doesn't happen?
* **Can you reliably reproduce the issue?** If not, provide details about how often the problem happens and under which conditions it normally happens.
Include details about your setup:
* **When was your QBCore last updated?**
* **What OS is the server running on**?
* **Which *extra* resources do you have installed?**
---
### Suggesting Features / Enhancements
This section guides you through submitting an enhancement suggestion for QBCore, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion.
Before creating enhancement suggestions, please check [this list](#before-submitting-an-enhancement-suggestion) as you might find out that you don't need to create one. When you are creating an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-a-good-enhancement-suggestion). Fill in feature request template, including the steps that you imagine you would take if the feature you're requesting existed.
#### Before Submitting An Enhancement Suggestion
* **Make sure it doesn't already exist.** Sounds silly, but there's a lot of features built in to qbcore that people don't realize so take a look through the docs and stuff to make sure it's not already there.
* **Check if there's already PR which provides that enhancement.**
* **Determine which resource the enhancement should be suggested in.** if it fits with another resource suggest it in that resource. if it would be it's own resource suggest it in the main qb-core repository.
* **Perform a [cursory search](https://github.com/search?q=+is%3Aissue+user%3Aqbcore-framework)** to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
#### How Do I Submit A (Good) Enhancement Suggestion?
Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you've determined which resource your enhancement suggestion is related to, create an issue on that repository and provide the following information:
* **Use a clear and descriptive title** for the issue to identify the suggestion.
* **Provide a step-by-step description of the suggested enhancement** in as many details as possible.
* **Provide specific examples to demonstrate the steps**. Include copy/pasteable snippets which you use in those examples, as [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines).
* **Describe the current behavior** and **explain which behavior you expected to see instead** and why.
* **Include screenshots and animated GIFs** which help you demonstrate the steps or point out the part of QBCore which the suggestion is related to.
* **Explain why this enhancement would be useful.**
* **Be creative and unique.** Stealing ideas from popular servers 1:1 detail isn't going to get accepted.
---
### Your First Code Contribution
Unsure where to begin contributing to QBCore? You can start by looking through these `beginner` and `help-wanted` issues.
---
### Pull Requests
The process described here has several goals:
- Maintain QBCore's quality.
- Fix problems that are important to users.
- Engage the community in working toward the best possible QBCore.
- Enable a sustainable system for QBCore's maintainers to review contributions.
Please follow these steps to have your contribution considered by the maintainers:
1. Follow all instructions in The Pull Request template.
2. Follow the [styleguides](#styleguides).
3. Await review by the reviewer(s).
While the prerequisites above must be satisfied prior to having your pull request reviewed, the reviewer(s) may ask you to complete additional design work, tests, or other changes before your pull request can be ultimately accepted.
---
## Styleguides
### Git Commit Messages
* Limit the first line to 72 characters or less.
* Reference issues and pull requests liberally after the first line.
* Consider starting the commit message with an applicable emoji:
* :art: `:art:` when improving the format/structure of the code
* :racehorse: `:racehorse:` when improving performance
* :memo: `:memo:` when writing docs
* :bug: `:bug:` when fixing a bug
* :fire: `:fire:` when removing code or files
* :white_check_mark: `:white_check_mark:` when adding tests
* :lock: `:lock:` when dealing with security
* :arrow_up: `:arrow_up:` when upgrading dependencies
* :arrow_down: `:arrow_down:` when downgrading dependencies
* :shirt: `:shirt:` when removing linter warnings
### Lua Styleguide
All lua code should be done using all the best practices of proper lua using the easiest to read yet fastest/most optimized methods of execution.
- Use 4 Space indentation
- Aim for lua 5.4 (include `lua54 'yes'` in the fxmanifest.lua)
- Use `PlayerPedId()` instead of `GetPlayerPed(-1)`
- Use `#(vector3 - vector3)` instead of `GetDistanceBetweenCoords()`
- Don't create unnecessary threads. always try to find a better method of triggering events
- Don't repeat yourself.. if you're using the same operations in many different places convert them into a function with flexible variables
- For distance checking loops set longer waits if you're outside of a range
- Job specific loops should only run for players with that job, don't waste cycles
- When possible don't trust the client, esspecially with transactions
- Balance security and optimizations
- [Consider this Lua Performance guide](https://springrts.com/wiki/Lua_Performance)
- Use local varriables everywhere possible
- Make use of config options where it makes sense making features optional or customizable
- Instead of `table.insert(myTable, "Value")` use `myTable[#myTable + 1] = "Value"`
- Instead of `table.insert(ages, "bob", 30)` use `ages["bob"] = 30`
### JavaScript Styleguide
- Use 4 Space indentation
- Don't repeat yourself.. if you're using the same operations in many different places convert them into a function with flexible variables.

View file

@ -0,0 +1,11 @@
## Description
<!-- What does your pull request change? Why should it be merged? Does it fix an issue? -->
## Checklist
<!-- Put an x inside the [ ] to check an item, like so: [x] -->
- [ ] I have personally loaded this code into an updated qbcore project and checked all of its functionality.
- [ ] My code fits the style guidelines.
- [ ] My PR fits the contribution guidelines.

View file

@ -0,0 +1,23 @@
name: Lint
on: [push, pull_request_target]
jobs:
lint:
name: Lint Resource
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Lint
uses: iLLeniumStudios/fivem-lua-lint-action@v2
with:
capture: "junit.xml"
args: "-t --formatter JUnit"
extra_libs: mysql
- name: Generate Lint Report
if: always()
uses: mikepenz/action-junit-report@v3
with:
report_paths: "**/junit.xml"
check_name: Linting Report
fail_on_failure: false

View file

@ -0,0 +1,75 @@
name: Semantic Version Bump (Conventional Commits)
on:
push:
branches:
- main
jobs:
semver-bump:
runs-on: ubuntu-latest
if: github.event.head_commit.author.name != 'github-actions[bot]'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Determine bump type from commit message
id: bump
run: |
COMMIT_MSG="${{ github.event.head_commit.message }}"
echo "🔍 Commit message: $COMMIT_MSG"
if echo "$COMMIT_MSG" | grep -qE 'BREAKING CHANGE|!:'; then
echo "bump=major" >> $GITHUB_OUTPUT
elif echo "$COMMIT_MSG" | grep -qE '^feat(\(.+\))?:'; then
echo "bump=minor" >> $GITHUB_OUTPUT
elif echo "$COMMIT_MSG" | grep -qE '^fix(\(.+\))?:'; then
echo "bump=patch" >> $GITHUB_OUTPUT
else
echo "bump=none" >> $GITHUB_OUTPUT
fi
- name: Bump version in fxmanifest.lua
if: steps.bump.outputs.bump != 'none'
run: |
FILE="fxmanifest.lua"
VERSION_LINE=$(grep -E "version ['\"]?[0-9]+\.[0-9]+\.[0-9]+['\"]?" "$FILE")
VERSION=$(echo "$VERSION_LINE" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+")
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
case "${{ steps.bump.outputs.bump }}" in
major)
MAJOR=$((MAJOR + 1))
MINOR=0
PATCH=0
;;
minor)
MINOR=$((MINOR + 1))
PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
sed -i "s/version ['\"]$VERSION['\"]/version '$NEW_VERSION'/" "$FILE"
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
- name: Commit and push version bump
if: steps.bump.outputs.bump != 'none'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add fxmanifest.lua
if git diff --cached --quiet; then
echo "⚠️ No version changes to commit."
exit 0
fi
COMMIT_MSG="${{ github.event.head_commit.message }}"
git commit -m "ci: bump fxmanifest version to ${{ env.new_version }} $COMMIT_MSG"
git push

View file

@ -0,0 +1,29 @@
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues and pull requests
on:
schedule:
- cron: '41 15 * * *'
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue has had 60 days of inactivity & will close within 7 days'
stale-pr-message: 'This PR has had 60 days of inactivity & will close within 7 days'
close-issue-label: 'Stale Closed'
close-pr-label: 'Stale Closed'
exempt-issue-labels: 'Suggestion'
exempt-pr-labels: 'Suggestion'

View file

@ -45,7 +45,7 @@ function QBCore.Functions.GetCoords(entity)
end
function QBCore.Functions.HasItem(items, amount)
return exports['qs-inventory']:HasItem(items, amount)
return exports['qb-inventory']:HasItem(items, amount)
end
---Returns the full character name

View file

@ -48,10 +48,3 @@ local function GetSharedGangs()
return QBShared.Gangs
end
exports('GetSharedGangs', GetSharedGangs)
-- Jobs Creator integration (jobs_creator)
RegisterNetEvent("jobs_creator:injectJobs", function(jobs)
QBCore.Shared.Jobs = jobs
end)

View file

@ -0,0 +1,129 @@
local Translations = {
error = {
not_online = '玩家不在线',
wrong_format = '格式错误',
missing_args = '请输入必须参数 (x, y, z)',
missing_args2 = '请输入所有参数!',
no_access = '你没有权限',
company_too_poor = '你所在的公司账户目前发不起工资',
item_not_exist = '该物品不存在',
too_heavy = '背包已满',
location_not_exist = '位置不存在',
duplicate_license = '发现重复的 Rockstar 许可证',
no_valid_license = '未找到有效的 Rockstar 许可证',
not_whitelisted = '您没有被列入此服务器的白名单',
server_already_open = '服务器已打开',
server_already_closed = '服务器已关闭',
no_permission = '您没有此权限..',
no_waypoint = '无GPS点位设置.',
tp_error = '传送时出错.',
connecting_database_error = '连接到服务器时发生数据库错误。(SQL server是否已打开?)',
connecting_database_timeout = '与数据库的连接超时。(SQL server是否已打开?)',
},
success = {
server_opened = '服务器已打开',
server_closed = '服务器已关闭',
teleported_waypoint = '传送至航路点.',
},
info = {
received_paycheck = '你收到的薪水是 $%{value}',
job_info = '工作: %{value} | 级别: %{value2} | 上班状态: %{value3}',
gang_info = '帮派: %{value} | 级别: %{value2}',
on_duty = '你现在开始上班了!',
off_duty = '从现在开始你下班了!',
checking_ban = '你好 %s. 我们正在检查您是否被禁止.',
join_server = '欢迎 %s 加入 {Server Name}.',
checking_whitelisted = '你好 %s. 我们正在检查您是否在白名单内.',
exploit_banned = '你因作弊而被禁止。查看Discord了解更多信息:%{discord}',
exploit_dropped = '你因为被而被踢出',
},
command = {
tp = {
help = 'TP至玩家或坐标(仅限管理员)',
params = {
x = { name = 'id/x', help = '玩家ID或X位置'},
y = { name = 'y', help = 'Y位置'},
z = { name = 'z', help = 'Z位置'},
},
},
tpm = { help = 'TP到标记(仅限管理员)' },
togglepvp = { help = '切换服务器上的PVP(仅限管理员)' },
addpermission = {
help = '授予玩家权限(仅限God)',
params = {
id = { name = 'id', help = '玩家ID' },
permission = { name = 'permission', help = '权限级别' },
},
},
removepermission = {
help = '删除玩家权限(仅限上帝)',
params = {
id = { name = 'id', help = '玩家ID' },
permission = { name = 'permission', help = '权限级别' },
},
},
openserver = { help = '为每个人打开服务器(仅限管理员)' },
closeserver = {
help = '为没有权限的人关闭服务器(仅限管理员)',
params = {
reason = { name = 'reason', help = '关闭原因(可选)' },
},
},
car = {
help = '刷出车辆(仅限管理员)',
params = {
model = { name = 'model', help = '车辆型号名称' },
},
},
dv = { help = '删除车辆(仅限管理员)' },
givemoney = {
help = '给玩家钱(仅限管理员)',
params = {
id = { name = 'id', help = '玩家ID' },
moneytype = { name = 'moneytype', help = '货币类型(cash, bank, crypto)' },
amount = { name = 'amount', help = '数量' },
},
},
setmoney = {
help = '设置玩家金额(仅限管理员)',
params = {
id = { name = 'id', help = '玩家ID' },
moneytype = { name = 'moneytype', help = '货币类型(cash, bank, crypto)' },
amount = { name = 'amount', help = '数量' },
},
},
job = { help = '检查您的工作' },
setjob = {
help = '设置玩家工作(仅限管理员)',
params = {
id = { name = 'id', help = '玩家ID' },
job = { name = 'job', help = '工作名称' },
grade = { name = 'grade', help = '工作级别' },
},
},
gang = { help = '检查你的帮派' },
setgang = {
help = '设置玩家作业(仅限管理员)',
params = {
id = { name = 'id', help = '玩家ID' },
gang = { name = 'gang', help = '帮派名称' },
grade = { name = 'grade', help = '帮派级别' },
},
},
ooc = { help = 'OOC聊天消息' },
me = {
help = '显示本地消息',
params = {
message = { name = 'message', help = '要发送的消息' }
},
},
},
}
if GetConvar('qb_locale', 'en') == 'zh-cn' then
Lang = Locale:new({
phrases = Translations,
warnOnMissing = true,
fallbackLang = Lang,
})
end

View file

@ -0,0 +1,133 @@
local Translations = {
error = {
not_online = '玩家不在線上',
wrong_format = '格式不正確',
missing_args = '尚未輸入所有參數 (x, y, z)',
missing_args2 = '必須填寫所有參數!',
no_access = '無法使用此指令',
company_too_poor = '您的雇主已破產',
item_not_exist = '物品不存在',
too_heavy = '背包已滿',
location_not_exist = '位置不存在',
duplicate_license = '[QBCORE] - 發現重複的 Rockstar 授權',
no_valid_license = '[QBCORE] - 找不到有效的 Rockstar 授權',
not_whitelisted = '[QBCORE] - 您不在此伺服器的白名單中',
server_already_open = '伺服器已經開啟',
server_already_closed = '伺服器已經關閉',
no_permission = '您沒有此權限..',
no_waypoint = '尚未設置導航點',
tp_error = '傳送時發生錯誤',
ban_table_not_found = '[QBCORE] - 無法在資料庫中找到封禁清單。請確認您已正確匯入 SQL 檔案。',
connecting_database_error = '[QBCORE] - 連接資料庫時發生錯誤。請確保 SQL 伺服器正在運行,且 server.cfg 檔案中的設定正確。',
connecting_database_timeout = '[QBCORE] - 資料庫連接超時。請確保 SQL 伺服器正在運行,且 server.cfg 檔案中的設定正確。',
},
success = {
server_opened = '伺服器已經開啟',
server_closed = '伺服器已經關閉',
teleported_waypoint = '傳送至導航點。',
},
info = {
received_paycheck = '您收到了 $%{value} 的薪水',
job_info = '工作: %{value} | 等級: %{value2} | 上班狀態: %{value3}',
gang_info = '幫派: %{value} | 等級: %{value2}',
on_duty = '您現在已經上班了!',
off_duty = '您現在已經下班了!',
checking_ban = '你好 %s,我們正在檢查您是否被封禁',
join_server = '歡迎 %s 加入 {Server Name}',
checking_whitelisted = '你好 %s,我們正在檢查您的白名單權限',
exploit_banned = '您因作弊行為而被封禁。請查看我們的 Discord 以獲取更多資訊: %{discord}',
exploit_dropped = '您因使用外掛程式而被踢出伺服器',
},
command = {
tp = {
help = '傳送至玩家或座標 (僅限管理員)',
params = {
x = { name = 'id/x', help = '玩家 ID 或 X 座標' },
y = { name = 'y', help = 'Y 座標' },
z = { name = 'z', help = 'Z 座標' },
},
},
tpm = { help = '傳送至標記點 (僅限管理員)' },
togglepvp = { help = '切換伺服器 PVP 狀態 (僅限管理員)' },
addpermission = {
help = '給予玩家權限 (僅限最高權限)',
params = {
id = { name = 'id', help = '玩家 ID' },
permission = { name = 'permission', help = '權限等級' },
},
},
removepermission = {
help = '移除玩家權限 (僅限最高權限)',
params = {
id = { name = 'id', help = '玩家 ID' },
permission = { name = 'permission', help = '權限等級' },
},
},
openserver = { help = '開放伺服器給所有人 (僅限管理員)' },
closeserver = {
help = '關閉伺服器給無權限者 (僅限管理員)',
params = {
reason = { name = 'reason', help = '關閉原因 (選填)' },
},
},
car = {
help = '生成載具 (僅限管理員)',
params = {
model = { name = 'model', help = '載具型號名稱' },
},
},
dv = { help = '刪除載具 (僅限管理員)' },
dvall = { help = '刪除所有載具 (僅限管理員)' },
dvp = { help = '刪除所有 NPC (僅限管理員)' },
dvo = { help = '刪除所有物件 (僅限管理員)' },
givemoney = {
help = '給予玩家金錢 (僅限管理員)',
params = {
id = { name = 'id', help = '玩家 ID' },
moneytype = { name = 'moneytype', help = '金錢類型 (現金, 銀行, 加密貨幣)' },
amount = { name = 'amount', help = '金額' },
},
},
setmoney = {
help = '設定玩家金錢數量 (僅限管理員)',
params = {
id = { name = 'id', help = '玩家 ID' },
moneytype = { name = 'moneytype', help = '金錢類型 (現金, 銀行, 加密貨幣)' },
amount = { name = 'amount', help = '金額' },
},
},
job = { help = '查看你的工作' },
setjob = {
help = '設定玩家工作 (僅限管理員)',
params = {
id = { name = 'id', help = '玩家 ID' },
job = { name = 'job', help = '工作名稱' },
grade = { name = 'grade', help = '工作等級' },
},
},
gang = { help = '查看你所在的幫派' },
setgang = {
help = '設定玩家幫派 (僅限管理員)',
params = {
id = { name = 'id', help = '玩家 ID' },
gang = { name = 'gang', help = '幫派名稱' },
grade = { name = 'grade', help = '幫派等級' },
},
},
ooc = { help = 'OOC 聊天訊息' },
me = {
help = '顯示本地訊息',
params = {
message = { name = 'message', help = '要發送的訊息' }
},
},
},
}
if GetConvar('qb_locale', 'en') == 'zh-tw' then
Lang = Locale:new({
phrases = Translations,
warnOnMissing = true,
fallbackLang = Lang,
})
end

View file

@ -18,6 +18,14 @@ AddEventHandler('playerDropped', function(reason)
QBCore.Players[src] = nil
end)
AddEventHandler("onResourceStop", function(resName)
for i,v in pairs(QBCore.UsableItems) do
if v.resource == resName then
QBCore.UsableItems[i] = nil
end
end
end)
-- Player Connecting
local readyFunction = MySQL.ready
local databaseConnected, bansTableExists = readyFunction == nil, readyFunction == nil

View file

@ -7,7 +7,6 @@ QBCore.UsableItems = {}
-- Get your player first and then trigger a function on them
-- ex: local player = QBCore.Functions.GetPlayer(source)
-- ex: local example = player.Functions.functionname(parameter)
---Gets the coordinates of an entity
---@param entity number
---@return vector4
@ -133,15 +132,21 @@ function QBCore.Functions.GetQBPlayers()
return QBCore.Players
end
---Gets a list of all on duty players of a specified job and the number
---@param job string
---@return table, number
function QBCore.Functions.GetPlayersOnDuty(job)
--- Gets a list of all online players of a specified job or job type and the number
--- @param job string
--- @param checkOnDuty boolean If true, only players on duty will be returned
function QBCore.Functions.GetPlayersByJob(job, checkOnDuty)
local players = {}
local count = 0
for src, Player in pairs(QBCore.Players) do
if Player.PlayerData.job.name == job then
if Player.PlayerData.job.onduty then
local playerData = Player.PlayerData
if playerData.job.name == job or playerData.job.type == job then
if checkOnDuty then
if playerData.job.onduty then
players[#players + 1] = src
count += 1
end
else
players[#players + 1] = src
count += 1
end
@ -150,18 +155,19 @@ function QBCore.Functions.GetPlayersOnDuty(job)
return players, count
end
---Gets a list of all on duty players of a specified job and the number
---@param job string
---@return table, number
function QBCore.Functions.GetPlayersOnDuty(job)
local players, count = QBCore.Functions.GetPlayersByJob(job, true)
return players, count
end
---Returns only the amount of players on duty for the specified job
---@param job string
---@return number
function QBCore.Functions.GetDutyCount(job)
local count = 0
for _, Player in pairs(QBCore.Players) do
if Player.PlayerData.job.name == job then
if Player.PlayerData.job.onduty then
count += 1
end
end
end
local _, count = QBCore.Functions.GetPlayersByJob(job, true)
return count
end
@ -395,33 +401,32 @@ function QBCore.Functions.CreateVehicle(source, model, vehtype, coords, warp)
end
function PaycheckInterval()
if next(QBCore.Players) then
for _, Player in pairs(QBCore.Players) do
if Player then
local payment = Player.PlayerData.job.payment
if Player.PlayerData.job and payment > 0 and (QBShared.Jobs[Player.PlayerData.job.name].offDutyPay or Player.PlayerData.job.onduty) then
if QBCore.Config.Money.PayCheckSociety then
local account = exports['qb-management']:GetAccount(Player.PlayerData.job.name)
if account ~= 0 then -- Checks if player is employed by a society
if account < payment then -- Checks if company has enough money to pay society
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('error.company_too_poor'), 'error')
else
Player.Functions.AddMoney('bank', payment)
exports['qb-management']:RemoveMoney(Player.PlayerData.job.name, payment)
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
TriggerEvent('okokBanking:AddTransferTransactionFromSocietyToP', payment, "salary", "Salary", Player.PlayerData.citizenid, Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname)
end
else
Player.Functions.AddMoney('bank', payment)
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
TriggerEvent('okokBanking:AddTransferTransactionFromSocietyToP', payment, "salary", "Salary", Player.PlayerData.citizenid, Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname)
end
if not next(QBCore.Players) then
SetTimeout(QBCore.Config.Money.PayCheckTimeOut * (60 * 1000), PaycheckInterval) -- Prevent paychecks from stopping forever once 0 players
return
end
for _, Player in pairs(QBCore.Players) do
if not Player then return end
local payment = QBShared.Jobs[Player.PlayerData.job.name]['grades'][tostring(Player.PlayerData.job.grade.level)].payment
if not payment then payment = Player.PlayerData.job.payment end
if Player.PlayerData.job and payment > 0 and (QBShared.Jobs[Player.PlayerData.job.name].offDutyPay or Player.PlayerData.job.onduty) then
if QBCore.Config.Money.PayCheckSociety then
local account = exports['qb-banking']:GetAccountBalance(Player.PlayerData.job.name)
if account ~= 0 then
if account < payment then
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('error.company_too_poor'), 'error')
else
Player.Functions.AddMoney('bank', payment)
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
TriggerEvent('okokBanking:AddTransferTransactionFromSocietyToP', payment, "salary", "Salary", Player.PlayerData.citizenid, Player.PlayerData.charinfo.firstname..' '..Player.PlayerData.charinfo.lastname)
Player.Functions.AddMoney('bank', payment, 'paycheck')
exports['qb-banking']:RemoveMoney(Player.PlayerData.job.name, payment, 'Employee Paycheck')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', { value = payment }))
end
else
Player.Functions.AddMoney('bank', payment, 'paycheck')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', { value = payment }))
end
else
Player.Functions.AddMoney('bank', payment, 'paycheck')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', { value = payment }))
end
end
end
@ -470,7 +475,26 @@ end
---@param item string
---@param data function
function QBCore.Functions.CreateUseableItem(item, data)
QBCore.UsableItems[item] = data
local rawFunc = nil
if type(data) == 'table' then
if rawget(data, '__cfx_functionReference') then
rawFunc = data
elseif data.cb and rawget(data.cb, '__cfx_functionReference') then
rawFunc = data.cb
elseif data.callback and rawget(data.callback, '__cfx_functionReference') then
rawFunc = data.callback
end
elseif type(data) == 'function' then
rawFunc = data
end
if rawFunc then
QBCore.UsableItems[item] = {
func = rawFunc,
resource = GetInvokingResource()
}
end
end
---Checks if the given item is usable
@ -484,8 +508,8 @@ end
---@param source any
---@param item string
function QBCore.Functions.UseItem(source, item)
if GetResourceState('qs-inventory') == 'missing' then return end
exports['qs-inventory']:UseItem(source, item)
if GetResourceState('qb-inventory') == 'missing' then return end
exports['qb-inventory']:UseItem(source, item)
end
---Kick Player
@ -681,8 +705,8 @@ end
---@param amount number
---@return boolean
function QBCore.Functions.HasItem(source, items, amount)
if GetResourceState('qs-inventory') == 'missing' then return end
return exports['qs-inventory']:HasItem(source, items, amount)
if GetResourceState('qb-inventory') == 'missing' then return end
return exports['qb-inventory']:HasItem(source, items, amount)
end
---Notify
@ -716,6 +740,5 @@ for functionName, func in pairs(QBCore.Functions) do
exports(functionName, func)
end
end
-- Access a specific function directly:
-- exports['qb-core']:Notify(source, 'Hello Player!')

View file

@ -47,11 +47,3 @@ local function GetSharedGangs()
return QBShared.Gangs
end
exports('GetSharedGangs', GetSharedGangs)
-- Jobs Creator integration (jobs_creator)
RegisterNetEvent("jobs_creator:injectJobs", function(jobs)
if type(source) == "number" and source > 0 then return end
QBCore.Shared.Jobs = jobs
end)

View file

@ -146,8 +146,8 @@ function QBCore.Player.CheckPlayerData(source, PlayerData)
applyDefaults(PlayerData, QBCore.Config.Player.PlayerDefaults)
if GetResourceState('qs-inventory') ~= 'missing' then
PlayerData.items = exports['qs-inventory']:LoadInventory(PlayerData.source, PlayerData.citizenid)
if GetResourceState('qb-inventory') ~= 'missing' then
PlayerData.items = exports['qb-inventory']:LoadInventory(PlayerData.source, PlayerData.citizenid)
end
return QBCore.Player.CreatePlayer(PlayerData, Offline)
@ -310,98 +310,83 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
return self.PlayerData.metadata['rep'][rep] or 0
end
function self.Functions.AddMoney(moneytype, amount, reason)
reason = reason or 'unknown'
moneytype = moneytype:lower()
amount = tonumber(amount)
if amount < 0 then return end
if not self.PlayerData.money[moneytype] then return false end
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] + amount
function self.Functions.AddMoney(moneytype, amount, reason)
reason = reason or 'unknown'
moneytype = moneytype:lower()
amount = tonumber(amount)
if amount < 0 then return end
if not self.PlayerData.money[moneytype] then return false end
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] + amount
local isMoneyItem, moneyItemName = exports["tgiann-inventory"]:IsMoneyItem(moneytype)
if isMoneyItem then
exports["tgiann-inventory"]:SetItem(self.PlayerData.source, moneyItemName, self.PlayerData.money[moneytype])
end
if not self.Offline then
self.Functions.UpdatePlayerData()
if amount > 100000 then
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney', 'lightgreen', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') added, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason, true)
else
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney', 'lightgreen', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') added, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)
if not self.Offline then
self.Functions.UpdatePlayerData()
if amount > 100000 then
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney', 'lightgreen', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') added, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason, true)
else
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney', 'lightgreen', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') added, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)
end
TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, amount, false)
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'add', reason)
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'add', reason)
end
TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, amount, false)
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'add', reason)
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'add', reason)
return true
end
return true
end
function self.Functions.RemoveMoney(moneytype, amount, reason)
reason = reason or 'unknown'
moneytype = moneytype:lower()
amount = tonumber(amount)
if amount < 0 then return end
if not self.PlayerData.money[moneytype] then return false end
for _, mtype in pairs(QBCore.Config.Money.DontAllowMinus) do
if mtype == moneytype then
if (self.PlayerData.money[moneytype] - amount) < 0 then
return false
function self.Functions.RemoveMoney(moneytype, amount, reason)
reason = reason or 'unknown'
moneytype = moneytype:lower()
amount = tonumber(amount)
if amount < 0 then return end
if not self.PlayerData.money[moneytype] then return false end
for _, mtype in pairs(QBCore.Config.Money.DontAllowMinus) do
if mtype == moneytype then
if (self.PlayerData.money[moneytype] - amount) < 0 then
return false
end
end
end
end
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] - amount
local isMoneyItem, moneyItemName = exports["tgiann-inventory"]:IsMoneyItem(moneytype)
if isMoneyItem then
exports["tgiann-inventory"]:SetItem(self.PlayerData.source, moneyItemName, self.PlayerData.money[moneytype])
end
if self.PlayerData.money[moneytype] - amount < QBCore.Config.Money.MinusLimit then return false end
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] - amount
if not self.Offline then
self.Functions.UpdatePlayerData()
if amount > 100000 then
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') removed, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason, true)
else
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') removed, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)
if not self.Offline then
self.Functions.UpdatePlayerData()
if amount > 100000 then
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') removed, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason, true)
else
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') removed, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)
end
TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, amount, true)
if moneytype == 'bank' then
TriggerClientEvent('qb-phone:client:RemoveBankMoney', self.PlayerData.source, amount)
end
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'remove', reason)
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'remove', reason)
end
TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, amount, true)
if moneytype == 'bank' then
TriggerClientEvent('qb-phone:client:RemoveBankMoney', self.PlayerData.source, amount)
return true
end
function self.Functions.SetMoney(moneytype, amount, reason)
reason = reason or 'unknown'
moneytype = moneytype:lower()
amount = tonumber(amount)
if amount < 0 then return false end
if not self.PlayerData.money[moneytype] then return false end
local difference = amount - self.PlayerData.money[moneytype]
self.PlayerData.money[moneytype] = amount
if not self.Offline then
self.Functions.UpdatePlayerData()
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'SetMoney', 'green', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') set, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)
TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, math.abs(difference), difference < 0)
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'set', reason)
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'set', reason)
end
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'remove', reason)
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'remove', reason)
return true
end
return true
end
function self.Functions.SetMoney(moneytype, amount, reason, forInventory)
reason = reason or 'unknown'
moneytype = moneytype:lower()
amount = tonumber(amount)
if amount < 0 then return false end
if not self.PlayerData.money[moneytype] then return false end
local difference = amount - self.PlayerData.money[moneytype]
self.PlayerData.money[moneytype] = amount
if not forInventory then
local isMoneyItem, moneyItemName = exports["tgiann-inventory"]:IsMoneyItem(moneytype)
if isMoneyItem then
exports["tgiann-inventory"]:SetItem(self.PlayerData.source, moneyItemName, amount)
end
end
if not self.Offline then
self.Functions.UpdatePlayerData()
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'SetMoney', 'green', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') set, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)
TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, math.abs(difference), difference < 0)
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'set', reason)
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'set', reason)
end
return true
end
function self.Functions.GetMoney(moneytype)
if not moneytype then return false end
moneytype = moneytype:lower()
@ -514,22 +499,13 @@ function QBCore.Player.Save(source)
position = json.encode(pcoords),
metadata = json.encode(PlayerData.metadata)
})
if GetResourceState('qs-inventory') ~= 'missing' then exports['qs-inventory']:SaveInventory(source) end
if GetResourceState('qb-inventory') ~= 'missing' then exports['qb-inventory']:SaveInventory(source) end
QBCore.ShowSuccess(resourceName, PlayerData.name .. ' PLAYER SAVED!')
else
QBCore.ShowError(resourceName, 'ERROR QBCORE.PLAYER.SAVE - PLAYERDATA IS EMPTY!')
end
end
AddEventHandler('onResourceStop', function(resourceName)
if (resourceName == 'qs-inventory') then
local players = QBCore.Functions.GetPlayers()
for _, player in ipairs(players) do
QBCore.Player.Save(player)
end
end
end)
function QBCore.Player.SaveOffline(PlayerData)
if PlayerData then
MySQL.insert('INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (:citizenid, :cid, :license, :name, :money, :charinfo, :job, :gang, :position, :metadata) ON DUPLICATE KEY UPDATE cid = :cid, name = :name, money = :money, charinfo = :charinfo, job = :job, gang = :gang, position = :position, metadata = :metadata', {
@ -544,7 +520,7 @@ function QBCore.Player.SaveOffline(PlayerData)
position = json.encode(PlayerData.position),
metadata = json.encode(PlayerData.metadata)
})
if GetResourceState('qs-inventory') ~= 'missing' then exports['qs-inventory']:SaveInventory(PlayerData, true) end
if GetResourceState('qb-inventory') ~= 'missing' then exports['qb-inventory']:SaveInventory(PlayerData, true) end
QBCore.ShowSuccess(resourceName, PlayerData.name .. ' OFFLINE PLAYER SAVED!')
else
QBCore.ShowError(resourceName, 'ERROR QBCORE.PLAYER.SAVEOFFLINE - PLAYERDATA IS EMPTY!')
@ -619,28 +595,28 @@ end
-- Inventory Backwards Compatibility
function QBCore.Player.SaveInventory(source)
if GetResourceState('qs-inventory') == 'missing' then return end
exports['qs-inventory']:SaveInventory(source, false)
if GetResourceState('qb-inventory') == 'missing' then return end
exports['qb-inventory']:SaveInventory(source, false)
end
function QBCore.Player.SaveOfflineInventory(PlayerData)
if GetResourceState('qs-inventory') == 'missing' then return end
exports['qs-inventory']:SaveInventory(PlayerData, true)
if GetResourceState('qb-inventory') == 'missing' then return end
exports['qb-inventory']:SaveInventory(PlayerData, true)
end
function QBCore.Player.GetTotalWeight(items)
if GetResourceState('qs-inventory') == 'missing' then return end
return exports['qs-inventory']:GetTotalWeight(items)
if GetResourceState('qb-inventory') == 'missing' then return end
return exports['qb-inventory']:GetTotalWeight(items)
end
function QBCore.Player.GetSlotsByItem(items, itemName)
if GetResourceState('qs-inventory') == 'missing' then return end
return exports['qs-inventory']:GetSlotsByItem(items, itemName)
if GetResourceState('qb-inventory') == 'missing' then return end
return exports['qb-inventory']:GetSlotsByItem(items, itemName)
end
function QBCore.Player.GetFirstSlotByItem(items, itemName)
if GetResourceState('qs-inventory') == 'missing' then return end
return exports['qs-inventory']:GetFirstSlotByItem(items, itemName)
if GetResourceState('qb-inventory') == 'missing' then return end
return exports['qb-inventory']:GetFirstSlotByItem(items, itemName)
end
-- Util Functions

View file

@ -1,3 +1,58 @@
QBShared = QBShared or {}
QBShared.Gangs = {}
QBShared.Gangs = {
none = { label = 'No Gang', grades = { ['0'] = { name = 'Unaffiliated' } } },
lostmc = {
label = 'The Lost MC',
grades = {
['0'] = { name = 'Recruit' },
['1'] = { name = 'Enforcer' },
['2'] = { name = 'Shot Caller' },
['3'] = { name = 'Boss', isboss = true },
},
},
ballas = {
label = 'Ballas',
grades = {
['0'] = { name = 'Recruit' },
['1'] = { name = 'Enforcer' },
['2'] = { name = 'Shot Caller' },
['3'] = { name = 'Boss', isboss = true },
},
},
vagos = {
label = 'Vagos',
grades = {
['0'] = { name = 'Recruit' },
['1'] = { name = 'Enforcer' },
['2'] = { name = 'Shot Caller' },
['3'] = { name = 'Boss', isboss = true },
},
},
cartel = {
label = 'Cartel',
grades = {
['0'] = { name = 'Recruit' },
['1'] = { name = 'Enforcer' },
['2'] = { name = 'Shot Caller' },
['3'] = { name = 'Boss', isboss = true },
},
},
families = {
label = 'Families',
grades = {
['0'] = { name = 'Recruit' },
['1'] = { name = 'Enforcer' },
['2'] = { name = 'Shot Caller' },
['3'] = { name = 'Boss', isboss = true },
},
},
triads = {
label = 'Triads',
grades = {
['0'] = { name = 'Recruit' },
['1'] = { name = 'Enforcer' },
['2'] = { name = 'Shot Caller' },
['3'] = { name = 'Boss', isboss = true },
},
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,142 @@
QBShared = QBShared or {}
QBShared.ForceJobDefaultDutyAtLogin = true -- true: Force duty state to jobdefaultDuty | false: set duty state from database last saved
QBShared.Jobs = {
unemployed = { label = 'Civilian', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Freelancer', payment = 10 } } },
bus = { label = 'Bus', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Driver', payment = 50 } } },
judge = { label = 'Honorary', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Judge', payment = 100 } } },
lawyer = { label = 'Law Firm', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Associate', payment = 50 } } },
reporter = { label = 'Reporter', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Journalist', payment = 50 } } },
trucker = { label = 'Trucker', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Driver', payment = 50 } } },
tow = { label = 'Towing', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Driver', payment = 50 } } },
garbage = { label = 'Garbage', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Collector', payment = 50 } } },
vineyard = { label = 'Vineyard', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Picker', payment = 50 } } },
hotdog = { label = 'Hotdog', defaultDuty = true, offDutyPay = false, grades = { ['0'] = { name = 'Sales', payment = 50 } } },
QBShared.Jobs = {}
-- Jobs Creator integration (jobs_creator)
RegisterNetEvent("jobs_creator:injectJobs", function(jobs)
if IsDuplicityVersion() and type(source) == "number" and source > 0 then return end
QBShared.Jobs = jobs
end)
police = {
label = 'Law Enforcement',
type = 'leo',
defaultDuty = true,
offDutyPay = false,
grades = {
['0'] = { name = 'Recruit', payment = 50 },
['1'] = { name = 'Officer', payment = 75 },
['2'] = { name = 'Sergeant', payment = 100 },
['3'] = { name = 'Lieutenant', payment = 125 },
['4'] = { name = 'Chief', isboss = true, payment = 150 },
},
},
ambulance = {
label = 'EMS',
type = 'ems',
defaultDuty = true,
offDutyPay = false,
grades = {
['0'] = { name = 'Recruit', payment = 50 },
['1'] = { name = 'Paramedic', payment = 75 },
['2'] = { name = 'Doctor', payment = 100 },
['3'] = { name = 'Surgeon', payment = 125 },
['4'] = { name = 'Chief', isboss = true, payment = 150 },
},
},
realestate = {
label = 'Real Estate',
defaultDuty = true,
offDutyPay = false,
grades = {
['0'] = { name = 'Recruit', payment = 50 },
['1'] = { name = 'House Sales', payment = 75 },
['2'] = { name = 'Business Sales', payment = 100 },
['3'] = { name = 'Broker', payment = 125 },
['4'] = { name = 'Manager', isboss = true, payment = 150 },
},
},
taxi = {
label = 'Taxi',
defaultDuty = true,
offDutyPay = false,
grades = {
['0'] = { name = 'Recruit', payment = 50 },
['1'] = { name = 'Driver', payment = 75 },
['2'] = { name = 'Event Driver', payment = 100 },
['3'] = { name = 'Sales', payment = 125 },
['4'] = { name = 'Manager', isboss = true, payment = 150 },
},
},
cardealer = {
label = 'Vehicle Dealer',
defaultDuty = true,
offDutyPay = false,
grades = {
['0'] = { name = 'Recruit', payment = 50 },
['1'] = { name = 'Showroom Sales', payment = 75 },
['2'] = { name = 'Business Sales', payment = 100 },
['3'] = { name = 'Finance', payment = 125 },
['4'] = { name = 'Manager', isboss = true, payment = 150 },
},
},
mechanic = {
label = 'LS Customs',
type = 'mechanic',
defaultDuty = true,
offDutyPay = false,
grades = {
['0'] = { name = 'Recruit', payment = 50 },
['1'] = { name = 'Novice', payment = 75 },
['2'] = { name = 'Experienced', payment = 100 },
['3'] = { name = 'Advanced', payment = 125 },
['4'] = { name = 'Manager', isboss = true, payment = 150 },
},
},
mechanic2 = {
label = 'LS Customs',
type = 'mechanic',
defaultDuty = true,
offDutyPay = false,
grades = {
['0'] = { name = 'Recruit', payment = 50 },
['1'] = { name = 'Novice', payment = 75 },
['2'] = { name = 'Experienced', payment = 100 },
['3'] = { name = 'Advanced', payment = 125 },
['4'] = { name = 'Manager', isboss = true, payment = 150 },
},
},
mechanic3 = {
label = 'LS Customs',
type = 'mechanic',
defaultDuty = true,
offDutyPay = false,
grades = {
['0'] = { name = 'Recruit', payment = 50 },
['1'] = { name = 'Novice', payment = 75 },
['2'] = { name = 'Experienced', payment = 100 },
['3'] = { name = 'Advanced', payment = 125 },
['4'] = { name = 'Manager', isboss = true, payment = 150 },
},
},
beeker = {
label = 'Beeker\'s Garage',
type = 'mechanic',
defaultDuty = true,
offDutyPay = false,
grades = {
['0'] = { name = 'Recruit', payment = 50 },
['1'] = { name = 'Novice', payment = 75 },
['2'] = { name = 'Experienced', payment = 100 },
['3'] = { name = 'Advanced', payment = 125 },
['4'] = { name = 'Manager', isboss = true, payment = 150 },
},
},
bennys = {
label = 'Benny\'s Original Motor Works',
type = 'mechanic',
defaultDuty = true,
offDutyPay = false,
grades = {
['0'] = { name = 'Recruit', payment = 50 },
['1'] = { name = 'Novice', payment = 75 },
['2'] = { name = 'Experienced', payment = 100 },
['3'] = { name = 'Advanced', payment = 125 },
['4'] = { name = 'Manager', isboss = true, payment = 150 },
},
},
}

View file

@ -741,14 +741,14 @@ local Vehicles = {
{ model = 'barracks3', name = 'Barracks', brand = 'HVY', price = 100000, category = 'military', type = 'automobile', shop = 'none' },
--- Commercial (20)
{ model = 'cerberus', name = 'Apocalypse Cerberus', brand = 'MTL', price = 100000, category = 'commercial', type = 'automobile', shop = 'none' },
{ model = 'pounder2', name = 'Pounder Custom', brand = 'Jobuilt', price = 55000, category = 'commercial', type = 'automobile', shop = 'truck' },
{ model = 'pounder2', name = 'Pounder Custom', brand = 'MTL', price = 55000, category = 'commercial', type = 'automobile', shop = 'truck' },
{ model = 'mule4', name = 'Mule Custom', brand = 'Maibatsu', price = 40000, category = 'commercial', type = 'automobile', shop = 'truck' },
{ model = 'phantom3', name = 'Phantom Custom', brand = 'Jobuilt', price = 110000, category = 'commercial', type = 'automobile', shop = 'truck' },
{ model = 'hauler2', name = 'Hauler Custom', brand = 'Jobuilt', price = 100000, category = 'commercial', type = 'automobile', shop = 'truck' },
{ model = 'phantom2', name = 'Phantom Wedge', brand = 'Jobuilt', price = 100000, category = 'commercial', type = 'automobile', shop = 'none' },
{ model = 'mule5', name = 'Mule (Heist)', brand = 'Maibatsu', price = 40000, category = 'commercial', type = 'automobile', shop = 'truck' },
{ model = 'stockade', name = 'Stockade', brand = 'Brute', price = 100000, category = 'commercial', type = 'automobile', shop = 'truck' },
{ model = 'pounder', name = 'Pounder', brand = 'Jobuilt', price = 55000, category = 'commercial', type = 'automobile', shop = 'truck' },
{ model = 'pounder', name = 'Pounder', brand = 'MTL', price = 55000, category = 'commercial', type = 'automobile', shop = 'truck' },
{ model = 'phantom', name = 'Phantom', brand = 'Jobuilt', price = 100000, category = 'commercial', type = 'automobile', shop = 'truck' },
{ model = 'packer', name = 'Packer', brand = 'MTL', price = 100000, category = 'commercial', type = 'automobile', shop = 'truck' },
{ model = 'mule', name = 'Mule', brand = 'Maibatsu', price = 40000, category = 'commercial', type = 'automobile', shop = 'truck' },

View file

@ -26,9 +26,6 @@ QBShared.Weapons = {
[`weapon_bread`] = { name = 'weapon_bread', label = 'Baquette', weapontype = 'Melee', ammotype = nil, damagereason = 'Melee killed / Whacked / Executed / Beat down / Murdered / Battered' },
[`weapon_stone_hatchet`] = { name = 'weapon_stone_hatchet', label = 'Stone Hatchet', weapontype = 'Melee', ammotype = nil, damagereason = 'Knifed / Stabbed / Eviscerated' },
[`weapon_candycane`] = { name = 'weapon_candycane', label = 'Candy Cane', weapontype = 'Melee', ammotype = nil, damagereason = 'Melee Killed / Whacked / Executed / Beat down / Musrdered / Battered / Candy Caned' },
[`weapon_colbaton`] = { name = 'weapon_colbaton', label = 'Teleskopschlagstock', weapontype = 'Melee', ammotype = nil, damagereason = 'Melee killed / Whacked / Executed / Beat down / Murdered / Battered' },
[`weapon_pocketlight`] = { name = 'weapon_pocketlight', label = 'kleine Taschenlampe', weapontype = 'Melee', ammotype = nil, damagereason = 'Melee killed / Whacked / Executed / Beat down / Murdered / Battered' },
-- Handguns
[`weapon_pistol`] = { name = 'weapon_pistol', label = 'Pistol', weapontype = 'Pistol', ammotype = 'AMMO_PISTOL', damagereason = 'Pistoled / Blasted / Plugged / Bust a cap in' },
@ -102,8 +99,6 @@ QBShared.Weapons = {
[`weapon_marksmanrifle`] = { name = 'weapon_marksmanrifle', label = 'Marksman Rifle', weapontype = 'Sniper Rifle', ammotype = 'AMMO_SNIPER', damagereason = 'Sniped / Picked off / Scoped' },
[`weapon_marksmanrifle_mk2`] = { name = 'weapon_marksmanrifle_mk2', label = 'Marksman Rifle MK2', weapontype = 'Sniper Rifle', ammotype = 'AMMO_SNIPER', damagereason = 'Sniped / Picked off / Scoped' },
[`weapon_remotesniper`] = { name = 'weapon_remotesniper', label = 'Remote Sniper', weapontype = 'Sniper Rifle', ammotype = 'AMMO_SNIPER_REMOTE', damagereason = 'Sniped / Picked off / Scoped' },
[`weapon_huntingrifle`] = { name = 'weapon_huntingrifle', label = 'Hunting Rifle', weapontype = 'Sniper Rifle', ammotype = 'AMMO_SNIPER', damagereason = 'Sniped / Picked off / Scoped' }, -- GG Hunting
[`weapon_crossbow`] = { name = 'weapon_crossbow', label = 'Hunting Crossbow', weapontype = 'Sniper Rifle', ammotype = 'AMMO_SNIPER', damagereason = 'Sniped / Picked off / Scoped' }, -- GG Hunting
-- Heavy Weapons
[`weapon_rpg`] = { name = 'weapon_rpg', label = 'RPG', weapontype = 'Heavy Weapons', ammotype = 'AMMO_RPG', damagereason = 'Killed / Exploded / Obliterated / Destroyed / Erased / Annihilated' },
@ -129,7 +124,6 @@ QBShared.Weapons = {
[`weapon_ball`] = { name = 'weapon_ball', label = 'Ball', weapontype = 'Throwable', ammotype = 'AMMO_BALL', damagereason = 'Died' },
[`weapon_smokegrenade`] = { name = 'weapon_smokegrenade', label = 'Smoke Grenade', weapontype = 'Throwable', ammotype = nil, damagereason = 'Died' },
[`weapon_flare`] = { name = 'weapon_flare', label = 'Flare pistol', weapontype = 'Throwable', ammotype = 'AMMO_FLARE', damagereason = 'Died' },
[`weapon_throwingshoered`] = { name = 'weapon_throwingshoered', label = 'Schuh rot', weapontype = 'Throwable', ammotype = 'AMMO_BALL', damagereason = 'Died' },
-- Miscellaneous
[`weapon_petrolcan`] = { name = 'weapon_petrolcan', label = 'Petrol Can', weapontype = 'Miscellaneous', ammotype = 'AMMO_PETROLCAN', damagereason = 'Died' },