LordDangerous / duckymdt

Police MDT for FiveM using ESX framework in PDA format for simple and minimal display
https://forum.cfx.re/t/4768208
GNU General Public License v3.0
9 stars 3 forks source link

ESX - LEGACY FIX #2

Open noctisthecat opened 2 years ago

noctisthecat commented 2 years ago

Change this event on line 179 of server.lua

AddEventHandler('duckymdt:addFinetoPlayer', function(identifier, name, fine)
    local _source = source

    local amount = fine.amount
    local finded = false

    for _, playerId in ipairs(GetPlayers()) do
        local possibleName = GetRealPlayerName(playerId)
        if possibleName then
            finded = true
            MySQL.Async.execute("INSERT INTO `mdt_fines` (identifier, charge, amount) VALUES (@identifier, @charge, @amount)", {
                ['@identifier'] = identifier,
                ['@charge'] = fine.label,
                ['@amount'] = fine.amount
            })
            TriggerClientEvent('duckymdt:addBilltoPlayer', _source, playerId, fine.label, amount)
            TriggerClientEvent('esx:showNotification', _source, _U('added_fine'))
        end
    end
    if not finded then
        TriggerClientEvent('esx:showNotification', _source, _U('error_adding_fine'))
    end
end)

And add this function on the same file

    local xPlayer = ESX.GetPlayerFromId(playerId)

    if xPlayer then
        if Config.EnableESXIdentity then
            if Config.OnlyFirstname then
                return xPlayer.get('firstName')
            else
                return xPlayer.getName()
            end
        else
            return xPlayer.getName()
        end
    else
        return GetPlayerName(playerId)
    end
end

Finaly add on the config.lua this lines

Config.OnlyFirstname = false
Config.EnableESXIdentity = true -- only turn this on if you are using esx_identity and want to use RP names
mikalgoma commented 2 years ago

And where we add this function in the server side ?

noctisthecat commented 2 years ago

And where we add this function in the server side ?

Where u want

Gill0 commented 2 years ago

Ähm. What is the Name of the Function? In your Second Codesnipped is the first line missing. xD

redde05 commented 2 years ago

Looks like ur missing the top part of the second code snippet. Mind fixing it?