Deltarix Scripts
TebexDiscord
  • Information
    • About Me - Deltarix
  • Keymaster
    • FiveM Asset Escrow
    • Authentication
    • Transfers
  • Paid Assets
    • MDT V3
      • Setup Guide
      • Configurations
        • Settings
        • Graphics
        • Locales
        • Themes
      • Exports
        • Server
          • OpenMDT
          • CloseMDT
          • CreateLog
          • GetBoloByLinkedId
          • GetIdentifierByStateId
          • GetOfficerByBadgenumber
          • GetOfficerByStateId
          • GetOfficerExists
          • GetOfficerFiredByStateId
          • GetOfficerSuspendedByStateId
          • GetPlayerFullNameByStateId
          • GetStateIdBySource
          • GetWantedByLinkedId
      • Public
        • Bridges
          • Server
            • Framework
              • qbx_core
              • qb-core
              • es_extended
            • Garage
              • qbx_garages
              • qb-garages
              • jg-advancedgarages
            • Inventory
              • ox_inventory
            • Licence
              • qbx_core
              • qb-core
            • Media
              • fivemanage
            • Property
              • qbx_properties
              • qb-apartments
              • qb-houses
              • qb-apartments & qb-housing
              • nolag_properties
              • qbx_properties & nolag_properties
        • Functions
          • Server
            • Create Card
            • Log
            • Prints
          • Client
            • Waypoint
            • Anim
      • Dependencies
    • MDT V2
      • Setup
      • Locales
      • Configurations
        • Server
        • Client
        • Settings
        • 10 Codes
        • Commands
      • Exports
        • Server
          • OpenMDT
          • OpenVehicleDetailsInMDT
          • GetStateId
          • GetOfficer
          • GetPlayerWanted
          • GetPlateFlagged
          • GetOfficerSuspended
          • GetWeaponRegistered
          • GetOfficerClockedIn
          • GetClosestCamera
          • CreateWeapon
          • CreateOfficer
          • DeleteOfficer
          • UpdateCitizenData
          • UpdateCitizenPoints
          • ToggleCamera
          • ToggleCameraTimeout
          • ToggleClock
        • Client
          • OpenMDT
          • InsertPhotoToGallery
      • Bridges
        • Server
          • Framework
            • es_extended
            • qb-core
            • qbx_core
          • Garage
            • esx_garage
            • qb-garages
            • qbx_garages
          • Inventory
            • ox_inventory
            • qb-inventory
          • Licence
            • es_extended
            • qb-core
            • qbx_core
          • Property
            • esx_property
            • qb-apartments
            • qbx_apartments
          • Utilities
            • Logger
        • Client
          • Garage
            • esx_garage
            • qb-garages
            • qbx_garages
          • Utilities
            • Camera
      • Dependencies
      • Known Bugs
      • Common Issues and Troubleshooting
    • Dispatch
      • Exports
        • Server
          • Notifications
          • IsDispatcher
          • GetDispatchersByGroup
          • GetGroups
          • GetStateId
        • Client
          • defaultNotification
          • officerNotification
          • dispatchNotification
          • Copy of dispatchNotification
      • Dependencies
Powered by GitBook
On this page

Was this helpful?

  1. Paid Assets
  2. MDT V3
  3. Public
  4. Bridges
  5. Server
  6. Framework

es_extended

if not GetResourceState('es_extended') == 'started' then return end

Framework = {

  ---@param source number
  ---@return string|nil
  getIdentifierBySource = function(source)
    if not source or type(source) ~= 'number' or not GetPlayerName(source) then
      prints.error('Invalid source provided')
      return nil
    end

    local xPlayer = ESX.GetPlayerFromId(source)
    if not xPlayer then
      prints.error('Player not found for source: %s', source)
      return nil
    end

    local identifier = xPlayer.getIdentifier()
    if not identifier then
      prints.error('Identifier not found for player: %s', source)
      return nil
    end

    return identifier
  end,

  ---@param stateid string
  ---@return string
  getPlayerGender = function(stateid)
    local result = MySQL.single.await(
      [[
        SELECT
          sex
        FROM
          users
        WHERE
          identifier = ?
      ]], { stateid }
    )

    if not result or not result.sex then
      prints.error('Gender not found for stateid: %s', stateid)
      return 'Unknown'
    end

    local gender = result.sex
    if gender == 'm' or gender == 'M' then
      return 'Male'
    elseif gender == 'f' or gender == 'F' then
      return 'Female'
    else
      prints.error('Invalid gender value for stateid: %s', stateid)
      return 'Unknown'
    end
  end,

  ---@param stateid string
  ---@return table A list of jobs with keys: label, value, coords<optional>
  getPlayerEmployment = function(stateid)
    local result = MySQL.single.await(
      [[
        SELECT
          job,
          job_grade
        FROM
          users
        WHERE
          identifier = ?
      ]], { stateid }
    )

    if not result or not result.job then
      prints.error('Employment not found for stateid: %s', stateid)
      return {}
    end

    local jobLabel = result.job
    local jobGrade = result.job_grade

    return {
      {
        label = jobLabel,
        value = tostring(jobGrade)
      }
    }
  end,

  ---@param author_stateid string
  ---@param stateid string
  ---@param amount number
  ---@return boolean
  penalizePlayer = function(author_stateid, stateid, amount)
    local xTarget = ESX.GetPlayerFromIdentifier(stateid)
    if not xTarget then
      prints.error("Player not found for identifier: %s", stateid)
      return false
    end

    -- Example penalization logic
    -- local fineAmount = math.floor(amount)
    -- MySQL.insert('INSERT INTO billing (identifier, sender, target_type, target, label, amount) VALUES (?, ?, ?, ?, ?, ?)',
    --   { xTarget.getIdentifier(), 'MDT', 'society', 'society_police', 'Issued fine', fineAmount }, function(insertId)
    --     xTarget.triggerEvent('esx:showNotification', 'You have just ~r~received a fine')
    --   end)

    return true
  end,

  ---@param author_stateid string
  ---@param stateid string
  ---@param jailTime number
  ---@return boolean
  detainPlayer = function(author_stateid, stateid, jailTime)
    if GetResourceState('esx_jail') ~= 'started' then
      prints.error("esx_jail resource is not started")
      return false
    end

    local xTarget = ESX.GetPlayerFromIdentifier(stateid)
    if not xTarget then
      prints.error("Player not found for identifier: %s", stateid)
      return false
    end

    -- exports.esx_jail:sendToJail(xTarget.source, jailTime) -- Example detainment logic
    return true
  end
}

Last updated 5 days ago

Was this helpful?