T1GER Library

Documentation, troubleshooting and support for T1GER Library

Note

This resource will be used in all T1GER resources as a dependency. The main purpose of the library is to add configurable support between frameworks, inventories, target systems and etc. for the gameplay resources. All options must be set in config.lua.

Do not edit/customize functions if you have no knowledge of LUA and FiveM Coding!

Framework

The library resource handles framework settings throughout T1GER's gameplay resources, so you only need to configure framework in this library resource.

Inventory

The library supports one custom inventory; ox-inventory, however, more inventories will be added in the future. Default ESX and QB-Inventory are supported.

Stash only works for ox-inventory and qb-inventory. If you are using another inventory, you can easily functions for it.

ESX default inventory is not supported with the stash functions.

Target-System / 3. Eye

The library supports three target systems; ox-target, q-target and qb-target. More target systems will be added in the future.

Get Player/Owned Vehicles

This is a function to retrieve all owned vehicles for a player. This function will be used throughout T1GER resources. According to what columns you have in your owned_vehicles or player_vehicles table, you might need to update something inside the function.

  1. Navigate to t1ger_lib/server/framework.lua.

  2. Find the function named: GetAllVehicles.

  3. You should see a table.insert() function containing the keys and values below:

table.insert(vehicles, {
    plate = results[i].plate,
    props = results[i].vehicle or results[i].mods,
    type = results[i].type or nil,
    job = results[i].job or nil,
    stored = results[i].stored or results[i].state or nil,
    garage = results[i].garage or results[i].parking or nil,
    impound = results[i].impound or results[i].pound or nil,
    seized = results[i].seized or nil,
    model = results[i].model or nil,
    name = results[i].name or nil,
    category = results[i].category or nil,
    fuel = results[i].fuel or nil,
    engine = results[i].engine or nil,
    body = results[i].body or nil,
})

Do not alter the key name, as these key names are used throughout the resources and may break them!

  1. You can alter the values starting with results[i] if your table columns are named something else. Look below for examples.

Example #1: garage column is named t1ger_garage.

garage = results[i].t1ger_garage

Example #2: stored column is named parked.

stored = results[i].parked

Update Owned Vehicle

This is a function to update owned vehicle, when the respective vehicle is either spawned or stored from/in a garage. According to what columns you have in your owned_vehicles or player_vehicles table, you might need to update something inside the function.

  1. Navigate to t1ger_lib/server/framework.lua.

  2. Find the function named: UpdateOwnedVehicle.

    UpdateOwnedVehicle = function(src, stored, garage, props)
    -- stored (boolean) true/false
    -- garage (string)
    -- props (table)
  3. Do not edit the '@' but only the value before the "=", as it's the exact column-name from your database table.

  4. Please read the end-line comments for brief information on the edits you are about to do.

  5. Start with updating the SQL string to your server's preferences:

    • is it the correct table?

    • is your stored state called: 'stored', 'state', 'parked' or something else?

    • do you even have a 'garage' or 'parked' column, if not delete it from the SQL string. If you have it, then make sure to name it the same as your table column.

    • are you using 'vehicle', 'mods' or something else for vehicle properties? If so, update it!

  6. After updating the SQL, make sure to update the keys & values inside the MySQL call. Only do this if you've added/removed keys from the SQL string.

  7. That's it - you are now all set.

    • Please note; if your database column for stored uses other value than boolean, then you need to re-code the true/false to return INT or whatever it may be.

Notifications

  • You should see a table.insert() function containing the keys and values below:

Set the config option UseFrameworkNotification to either true or false. If true, the system will use default ESX or QB notifications. If false, by default it will use ox notifications. Inside utils, you can easily customize/change to your own notification system.

Throughout the gameplay resources, all notification messages will be sent as a table with title, message and type. Integration of your own notifcation system won't get any easier.

If you want to parse more data through the notification, then you'd have to find the specific notification in the gameplay resource and add your extra values.

Create Vehicle Meta

You can use this server sided export to create vehicle meta on spawned vehicles in run-time.

The vehicle must be added to the database as an owned vehicle, when using this.

exports['t1ger_lib']:CreateVehicleMeta(plate, src)

Parameters:

  • plate(string): the plate string of the vehicle to create metadata for.

  • src(int): the player handle (player server id)

EXAMPLE #1

This example will make sure that when /admincar command is used in qb-core, the vehicle in question will have metadata created and synced.

RegisterNetEvent('qb-admin:server:SaveCar', function(mods, vehicle, _, plate)
    local src = source
    if QBCore.Functions.HasPermission(src, 'admin') or IsPlayerAceAllowed(src, 'command') then
        local Player = QBCore.Functions.GetPlayer(src)
        local result = MySQL.query.await('SELECT plate FROM player_vehicles WHERE plate = ?', { plate })
        if result[1] == nil then
            MySQL.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, state) VALUES (?, ?, ?, ?, ?, ?, ?)', {
                Player.PlayerData.license,
                Player.PlayerData.citizenid,
                vehicle.model,
                vehicle.hash,
                json.encode(mods),
                plate,
                0
            })
            exports['t1ger_lib']:CreateVehicleMeta(plate, src)
            TriggerClientEvent('QBCore:Notify', src, Lang:t("success.success_vehicle_owner"), 'success', 5000)
        else
            TriggerClientEvent('QBCore:Notify', src, Lang:t("error.failed_vehicle_owner"), 'error', 3000)
        end
    else
        BanPlayer(src)
    end
end)

Utils

Inside the utils.lua you'll find various functions. Feel free to use these in your resources as you please.

Last updated