Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(types): everything else #531

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions client/character.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,7 @@ local function previewPed(citizenId)
end
end

---@class CharacterRegistration
---@field firstname string
---@field lastname string
---@field nationality string
---@field gender number
---@field birthdate string
---@field cid integer

---@return string[]?
---@return CharacterRegistration?
local function characterDialog()
local nationalityOption = config.characters.limitNationalities and {
type = 'select',
Expand Down
5 changes: 3 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
fx_version 'cerulean'
game 'gta5'

description 'QBX_Core'
name 'qbx_core'
description 'The core resource for the Qbox Framework'
repository 'https://github.com/Qbox-project/qbx_core'
version '1.17.2'

Expand Down Expand Up @@ -66,4 +67,4 @@ dependencies {

provide 'qb-core'
lua54 'yes'
use_experimental_fxv2_oal 'yes'
use_experimental_fxv2_oal 'yes'
6 changes: 0 additions & 6 deletions server/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ AddEventHandler('playerDropped', function(reason)
QBX.Players[src] = nil
end)

---@class Deferrals https://docs.fivem.net/docs/scripting-reference/events/list/playerConnecting/#deferring-connections
---@field defer fun() initialize deferrals for the current resource. Required to wait at least 1 tick before calling other deferrals methods.
---@field update fun(message: string) sends a progress message to the connecting client
---@field presentCard fun(card: unknown|string, cb?: fun(data: unknown, rawData: string)) send an adaptive card to the client https://learn.microsoft.com/en-us/adaptive-cards/authoring-cards/getting-started and capture user input via callback.
---@field done fun(failureReason?: string) finalizes deferrals. If failureReason is present, user will be refused connection and shown reason. Need to wait 1 tick after calling other deferral methods before calling done.

-- Player Connecting
---@param name string
---@param _ any
Expand Down
26 changes: 0 additions & 26 deletions server/groups.lua
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
---@class GroupData
---@field label string

---@class JobData : GroupData
---@field type? string
---@field defaultDuty boolean
---@field offDutyPay boolean

---@class GangData : GroupData

---@class GradeData
---@field name string
---@field isboss? boolean
---@field bankAuth? boolean

---@class JobGradeData : GradeData
---@field payment number

---@class GangGradeData : GradeData

---@class Job : JobData
---@field grades table<integer, JobGradeData>

---@class Gang : GangData
---@field grades table<integer, GangGradeData>

---@enum GroupType
GroupType = {
JOB = 'job',
Expand Down
28 changes: 0 additions & 28 deletions server/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ local maxGangsPerPlayer = GetConvarInt('qbx:max_gangs_per_player', 1)
local setJobReplaces = GetConvar('qbx:setjob_replaces', 'true') == 'true'
local setGangReplaces = GetConvar('qbx:setgang_replaces', 'true') == 'true'

---@class PlayerData : PlayerEntity
---@field jobs table<string, integer>
---@field gangs table<string, integer>
---@field source? Source present if player is online
---@field optin? boolean present if player is online

---@param source Source
---@param citizenid? string
---@param newData? PlayerEntity
Expand Down Expand Up @@ -567,28 +561,6 @@ end

exports('Logout', Logout)

---@class Player
---@field Functions PlayerFunctions
---@field PlayerData PlayerData
---@field Offline boolean

---@class PlayerFunctions
---@field UpdatePlayerData fun()
---@field SetJob fun(job: string, grade: integer): boolean
---@field SetGang fun(gang: string, grade: integer): boolean
---@field SetJobDuty fun(onDuty: boolean)
---@field SetPlayerData fun(key: string, val: any)
---@field SetMetaData fun(meta: string, val: any)
---@field GetMetaData fun(meta: string): any
---@field AddJobReputation fun(amount: number)
---@field AddMoney fun(moneytype: MoneyType, amount: number, reason?: string): boolean
---@field RemoveMoney fun(moneytype: MoneyType, amount: number, reason?: string): boolean
---@field SetMoney fun(moneytype: MoneyType, amount: number, reason?: string): boolean
---@field GetMoney fun(moneytype: MoneyType): boolean | number
---@field SetCreditCard fun(cardNumber: number)
---@field Save fun()
---@field Logout fun()

---Create a new character
---Don't touch any of this unless you know what you are doing
---Will cause major issues!
Expand Down
9 changes: 0 additions & 9 deletions server/queue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ local waitingEmojiCount = #waitingEmojis
local useAdaptiveCard = config.useAdaptiveCard
local generateCard = config.generateCard

---@class SubQueue : SubQueueConfig
---@field positions table<string, number> Player license to sub-queue position map.
---@field size number

---@type SubQueue[]
local subQueues = {}
for i = 1, #config.subQueues do
Expand All @@ -42,11 +38,6 @@ for i = 1, #config.subQueues do
}
end

---@class PlayerQueueData
---@field waitingSeconds number
---@field subQueueIndex number
---@field globalPos number

---Player license to queue data map.
---@type table<string, PlayerQueueData>
local playerDatas = {}
Expand Down
16 changes: 0 additions & 16 deletions server/storage/main.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
local players = require 'server.storage.players'

---@class StorageFunctions
---@field insertBan fun(request: InsertBanRequest)
---@field fetchBan fun(request: GetBanRequest): BanEntity?
---@field deleteBan fun(request: GetBanRequest)
---@field upsertPlayerEntity fun(request: UpsertPlayerRequest)
---@field fetchPlayerSkin fun(citizenId: string): PlayerSkin?
---@field fetchPlayerEntity fun(citizenId: string): PlayerEntity?
---@field fetchAllPlayerEntities fun(license2: string, license?: string): PlayerEntity[]
---@field deletePlayer fun(citizenId: string): boolean success
---@field fetchIsUnique fun(type: UniqueIdType, value: string|number): boolean
---@field addPlayerToJob fun(citizenid: string, group: string, grade: integer)
---@field addPlayerToGang fun(citizenid: string, group: string, grade: integer)
---@field fetchPlayerGroups fun(citizenid: string): table<string, integer>, table<string, integer> jobs, gangs
---@field removePlayerFromJob fun(citizenid: string, group: string)
---@field removePlayerFromGang fun(citizenid: string, group: string)

---@type StorageFunctions
return players
106 changes: 0 additions & 106 deletions server/storage/players.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
local defaultSpawn = require 'config.shared'.defaultSpawn
local characterDataTables = require 'config.server'.characterDataTables

---@class InsertBanRequest
---@field name string
---@field license? string
---@field discordId? string
---@field ip? string
---@field reason string
---@field bannedBy string
---@field expiration integer epoch second that the ban will expire

---@param request InsertBanRequest
---@return boolean success
---@return ErrorResult? errorResult
Expand Down Expand Up @@ -48,15 +39,6 @@ local function getBanId(request)
end
end

---@class GetBanRequest
---@field license? string
---@field discordId? string
---@field ip? string

---@class BanEntity
---@field expire integer epoch second that the ban will expire
---@field reason string

---@param request GetBanRequest
---@return BanEntity?
local function fetchBan(request)
Expand All @@ -74,10 +56,6 @@ local function deleteBan(request)
MySQL.query.await('DELETE FROM bans WHERE ' ..column.. ' = ?', { value })
end

---@class UpsertPlayerRequest
---@field playerEntity PlayerEntity
---@field position vector3

---@param request UpsertPlayerRequest
local function upsertPlayerEntity(request)
MySQL.insert.await('INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata, last_logged_out) VALUES (:citizenid, :cid, :license, :name, :money, :charinfo, :job, :gang, :position, :metadata, :last_logged_out) ON DUPLICATE KEY UPDATE name = :name, money = :money, charinfo = :charinfo, job = :job, gang = :gang, position = :position, metadata = :metadata, last_logged_out = :last_logged_out', {
Expand All @@ -95,90 +73,6 @@ local function upsertPlayerEntity(request)
})
end

---@class PlayerEntity
---@field citizenid string
---@field license string
---@field name string
---@field money Money
---@field charinfo PlayerCharInfo
---@field job? PlayerJob
---@field gang? PlayerGang
---@field position vector4
---@field metadata PlayerMetadata
---@field cid integer
---@field lastLoggedOut integer
---@field items table deprecated

---@class PlayerEntityDatabase : PlayerEntity
---@field charinfo string
---@field money string
---@field job? string
---@field gang? string
---@field position string
---@field metadata string
---@field lastLoggedOutUnix integer

---@class PlayerCharInfo
---@field firstname string
---@field lastname string
---@field birthdate string
---@field nationality string
---@field cid integer
---@field gender integer
---@field backstory string
---@field phone string
---@field account string
---@field card number

---@class PlayerMetadata
---@field health number
---@field armor number
---@field hunger number
---@field thirst number
---@field stress number
---@field isdead boolean
---@field inlaststand boolean
---@field ishandcuffed boolean
---@field tracker boolean
---@field injail number time in minutes
---@field jailitems table TODO: expand
---@field status table TODO: expand
---@field phone {background: any, profilepicture: any} TODO: figure out more specific types
---@field bloodtype BloodType
---@field dealerrep number
---@field craftingrep number
---@field attachmentcraftingrep number
---@field currentapartment? integer apartmentId
---@field jobrep {tow: number, trucker: number, taxi: number, hotdog: number}
---@field callsign string
---@field fingerprint string
---@field walletid string
---@field criminalrecord {hasRecord: boolean, date?: table} TODO: date is os.date(), create better type than table
---@field licences {id: boolean, driver: boolean, weapon: boolean}
---@field inside {house?: any, apartment: {apartmentType?: any, apartmentId?: integer}} TODO: expand
---@field phonedata {SerialNumber: string, InstalledApps: table} TODO: expand

---@class PlayerJob
---@field name string
---@field label string
---@field payment number
---@field type? string
---@field onduty boolean
---@field isboss boolean
---@field grade {name: string, level: number}

---@class PlayerGang
---@field name string
---@field label string
---@field isboss boolean
---@field grade {name: string, level: number}

---@class PlayerSkin
---@field citizenid string
---@field model string
---@field skin string
---@field active integer

---@param citizenId string
---@return PlayerSkin?
local function fetchPlayerSkin(citizenId)
Expand Down
13 changes: 0 additions & 13 deletions shared/items.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
---@class Item
---@field name string
---@field label string
---@field weight number
---@field type string
---@field ammotype? string
---@field image string
---@field unique boolean
---@field useable boolean
---@field shouldClose? boolean
---@field combineable? false|table
---@field description string

---@deprecated This file is deprecated and will be removed in the future. If you are utilizing QB-Core bridge functionality you will need to populate items here for them to be available in QBCore.Shared.Items. If not please add your items directly in ox_inventory/data/items.lua file. Currently items placed in here will be converted at next server restart.
---@type table<string, Item>
return {
Expand Down
13 changes: 0 additions & 13 deletions shared/locale.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
---@class Locale
---@field fallback? Locale
---@field warnOnMissing boolean
---@field phrases table
---@field currentLocale string
---@field new fun(_: Locale, opts: table<string, any>): Locale
---@field extend fun(self: Locale, phrases: table<string, string>, prefix: string?)
---@field clear fun(self: Locale)
---@field replace fun(self: Locale, phrases: table<string, any>)
---@field locale fun(self: Locale, newLocale: string): string
---@field t fun(self: Locale, key: string, subs: table<string, any>?): string
---@field has fun(self: Locale, key: string): boolean
---@field delete fun(self: Locale, phraseTarget: string | table, prefix: string)
Locale = {}
Locale.__index = Locale

Expand Down
8 changes: 0 additions & 8 deletions shared/vehicles.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
---@class Vehicle
---@field name string
---@field brand string
---@field model string
---@field price number
---@field category string
---@field hash string | integer actually just an integer but string is required for types to align when using `asbo` for example

---@type table<string, Vehicle>
return {
adder = {
Expand Down
7 changes: 0 additions & 7 deletions shared/weapons.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
---@class Weapon
---@field name string
---@field label string
---@field weapontype string
---@field ammotype? string
---@field damagereason string

---@deprecated This file is deprecated and will be removed in the future. If you are utilizing QB-Core bridge functionality you will need to populate weapons here for them to be available in QBCore.Shared.Weapons. If not please add your weapons in ox_inventory/data/weapons.lua file. Currently weapons in this file will be converted on next server start.
---@type table<number, Weapon>
return {
Expand Down
Loading