[Release] [Bug Fix] Esx Scripts and some server suggestions

Hey there fellow ESX framework users. Let me keep it shorts, we all know esx has its bugs here and there. Recently more and more people approached me for solutions on some basic bugs with scripts running on the esx framework, so here I am releasing my fix for them. If you already found a fix for these issues or have a better solution or alternative fixes, please post them below. This is mean to help those who are newer to the framework or do not understand much about coding.

Trunks
Don’t even get me started there. I am aware people have got working trunks on their servers, however some people don’t, and some have but are very abusive. Let dive into some exploits and fixes.

  • Spamming items out and in the trunk for duping.
  • Putting a weapon in and taking it out with 1 bullet so the weapon stays in the trunk but you also get the weapon (duping).
  • Accessing trunks at the same time for dupes.

The fix is simple, add a weight to items such as dirty money and weapons so they cannot be placed in the trunk (in config.lua), as well as remove the delay when taking out items or placing them in the trunk (in client.lua). If you still do not know how to do it, I will include my trunk script in the script downloads bellow and you can have a look at it and configure it to your liking.

Reviving yourself when dead
This is a bug with the esx_identity script. Whilst the bug doesn’t revive you server wise (you are still dead on the database), it does revive you client wise, allowing you to walk around and be like a normal person (till you autorespawn ofc).

How the bug works is a user types /register, gets to the character creation and changes his gender once or twice, allowing him to get up from the ragdol state and have a health refil as gta detects a new model load.

How to fix: Go into your esx_identity server.lua file and make the register command admin only. Yes it has a down side to it but that’s the easiest fix. If you want a more advanced one, just add a health check on the command or a mysql search to make sure the user isn’t dead (this requires esx_ambulance tho but most servers have that anyways)

Glitching Esx_Jobs to make billions
Common thing to do amongst those with Cheat Engine or any other value editing softwares. How the bug works is the user exploits the return vehicle. Normally with esx jobs, you lose 2000$ when you take out a work car and then get it back if you return it undamaged. But you will lose some money if you damage it. Users abuse this as the return message is a client side script and can change the return value to billions.

How to fix: Simple, remove the return function for all jobs and make it so it takes 0$ when a user takes out a job vehicle. Once again my version of the job scripts will be in the download.

Realestate Agent job abuse
The script itself is abused as it doesn’t check how much money a user has, so agents can sell you a property for 2 billion let’s say and you will go to -2 bil and they will gain 2 bil. Also here is a suggestion, remove the renting option as it is sort of bugged, and remove the Customers option as it lags your server a lot.

Fix: Here is the correct selling function that you should add in your server lua file

RegisterServerEvent('esx_realestateagentjob:sell')
AddEventHandler('esx_realestateagentjob:sell', function(target, property, price)

  local xPlayer = ESX.GetPlayerFromId(target)

  if price == nil or price <= 0 or price > xPlayer.getMoney() then
    TriggerClientEvent('esx:showNotification', _source, _U('invalid_amount'))
  else
	xPlayer.removeMoney(price)

    TriggerEvent('esx_addonaccount:getSharedAccount', 'society_realestateagent', function(account)
      account.addMoney(price)
	end)
	TriggerEvent('esx_property:setPropertyOwned', property, price, false, xPlayer.identifier)
  end
end)

Once again the script with all my other changes will be available for download.

Banker Job interest fix/alternative and max account balance
This is done in order to stop your economy from inflation. This is just an example tho and can be altered. What my version of the script does is limit an account to 5 million max (so you cannot deposit more or gain interest), as well as revamps the interest function. Instead of using the cron function which for me is pretty broke, it uses ticks. Every server restart (after 10 minutes of the server being up so fast restarts don’t affect the interest), the bank interest script will run. After that it will remain idle for 12 hours and run again. Also I lowered the interest to 2% since it now runs 2 times a day.

Everything is done in the server lua file:

RegisterServerEvent('esx_bankerjob:customerDeposit')
AddEventHandler('esx_bankerjob:customerDeposit', function (target, amount)
  local xPlayer = ESX.GetPlayerFromId(target)

  TriggerEvent('esx_addonaccount:getSharedAccount', 'society_banker', function (account)
    if amount > 0 and account.money >= amount then
      TriggerEvent('esx_addonaccount:getAccount', 'bank_savings', xPlayer.identifier, function (account)
		if account.money + amount <= 5000000 then
			account.addMoney(amount)
			TriggerEvent('esx_addonaccount:getSharedAccount', 'society_banker', function (account)
				account.removeMoney(amount)
			end)
		else
			TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_amount'))
		end
      end)
    else
      TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_amount'))
    end
  end)
end)
Citizen.CreateThread( function()
while true do
  Wait(60000)

  local asyncTasks = {}

  MySQL.Async.fetchAll(
    'SELECT * FROM addon_account_data WHERE account_name = @account_name',
    { ['@account_name'] = 'bank_savings' },
    function (result)
      local bankInterests = 0

      for i=1, #result, 1 do
        local foundPlayer = false
        local xPlayer     = ESX.GetPlayerFromIdentifier(result[i].owner)

        if xPlayer ~= nil then
          TriggerEvent('esx_addonaccount:getAccount', 'bank_savings', xPlayer.identifier, function (account)
            local interests = math.floor(account.money / 100 * 2)
			local remaining = math.floor(5000000 - account.money)
            bankInterests   = bankInterests + interests

            table.insert(asyncTasks, function(cb)
              if account.money + interests <= 5000000 then
                account.addMoney(interests)
              else
                if account.money + interests >= 5100000 then
                  account.addMoney(0)
                else
                  account.addMoney(remaining)
                end
              end
            end)
          end)
        else
          local interests = math.floor(result[i].money / 100 * 2)
          local newMoney  = result[i].money + interests;
          bankInterests   = bankInterests + interests

          local scope = function (newMoney, owner)
            table.insert(asyncTasks, function (cb)

              MySQL.Async.execute(
                'UPDATE addon_account_data SET money = @money WHERE owner = @owner AND account_name = @account_name',
                {
                  ['@money']        = newMoney,
                  ['@owner']        = owner,
                  ['@account_name'] = 'bank_savings',
                },
                function (rowsChanged)
                  cb()
                end
              )
            end)
          end

          scope(newMoney, result[i].owner)
        end
      end

      TriggerEvent('esx_addonaccount:getSharedAccount', 'society_banker', function (account)
        account.addMoney(50000)
      end)

      Async.parallelLimit(asyncTasks, 5, function (results)
        print('[BANK] Calculated interests')
      end)

    end
  )
  Wait(43140000)
 end
end)

Make sure to change up the values if you want to limit the max account balance or interest gain. This script version will also be available to download.

Animation clipping though walls
Gta has some animations that allow users to clip though walls. This can be abused. Normally all the animations of an esx server would be located in the esx_animations resource. Some of the default glitched anims would be the mechanic repair under car and the sit on ground anim.

How to remove an animation:
Go in the config.lua file and remove them manually (make sure to double check before deleting something)
Here are the two default bugged anims:

{label = "Mechanic: Repair under car", type = "scenario", data = {anim = "world_human_vehicle_mechanic"}},
{label = "Sit on floor", type = "scenario", data = {anim = "WORLD_HUMAN_PICNIC"}},

Cops confiscating weapons and items and getting them in their inventory
No one likes corrupt cops and the temptation is too big when someone is getting everything they confiscate. No more! If you are using esx_policejob then this is for you.

Here is the full confiscate function on the server lua, but what interests you more is the bottom part where the actual items get removed.

RegisterServerEvent('esx_policejob:confiscatePlayerItem')
AddEventHandler('esx_policejob:confiscatePlayerItem', function(target, itemType, itemName, amount)
    local _source = source
    local sourceXPlayer = ESX.GetPlayerFromId(_source)
    local targetXPlayer = ESX.GetPlayerFromId(target)
 
    if sourceXPlayer.job.name ~= 'police' then
        print(('esx_policejob: %s attempted to confiscate!'):format(xPlayer.identifier))
        return
    end
 
    if itemType == 'item_standard' then
        local targetItem = targetXPlayer.getInventoryItem(itemName)
        local sourceItem = sourceXPlayer.getInventoryItem(itemName)
 
        -- does the target player have enough in their inventory?
        if targetItem.count > 0 and targetItem.count <= amount then
        
            -- can the player carry the said amount of x item?
            if sourceItem.limit ~= -1 and (sourceItem.count + amount) > sourceItem.limit then
                TriggerClientEvent('esx:showNotification', _source, _U('quantity_invalid'))
            else
                targetXPlayer.removeInventoryItem(itemName, amount)
                --sourceXPlayer.addInventoryItem   (itemName, amount)
                --TriggerClientEvent('esx:showNotification', _source, _U('you_confiscated', amount, sourceItem.label, targetXPlayer.name))
                TriggerClientEvent('esx:showNotification', target,  _U('got_confiscated', amount, sourceItem.label, sourceXPlayer.name))
            end
        else
            TriggerClientEvent('esx:showNotification', _source, _U('quantity_invalid'))
        end
 
    elseif itemType == 'item_account' then
        targetXPlayer.removeAccountMoney(itemName, amount)
        --sourceXPlayer.addAccountMoney   (itemName, amount)
 
        --TriggerClientEvent('esx:showNotification', _source, _U('you_confiscated_account', amount, itemName, targetXPlayer.name))
        TriggerClientEvent('esx:showNotification', target,  _U('got_confiscated_account', amount, itemName, sourceXPlayer.name))
 
    elseif itemType == 'item_weapon' then
        if amount == nil then amount = 0 end
        targetXPlayer.removeWeapon(itemName, amount)
        --sourceXPlayer.addWeapon   (itemName, amount)
 
        --TriggerClientEvent('esx:showNotification', _source, _U('you_confiscated_weapon', ESX.GetWeaponLabel(itemName), targetXPlayer.name, amount))
        TriggerClientEvent('esx:showNotification', target,  _U('got_confiscated_weapon', ESX.GetWeaponLabel(itemName), amount, sourceXPlayer.name))
    end
end)

Gangs using their storage to dupe items and weapons
Since you need to change a lot of areas in the script to fix this, I added my version of esx mafia in the scripts below, however you can do this with any gang script. What I basically did for the storage items is I made it so every time an item is removed, the menu is refreshed so you cannot dupe it. As for the guns, there is no longer an inventory, as that was client side and people could dupe all the way. Instead, now when a player buys a gun, it will go directly in their inventory.

Duping any throwable item like grenades, sticky bombs, etc
How this works is a player gets one of those throwing weapons, put them in their apartment, takes them out, rince and repeat till you get 25 ammo. Why? Because the apartment storage script duplicates the weapon ammo when you put a gun in. Now that isn’t too harmful for something that actually uses bullets, but for throwing items, well, they are the bullets themselves.

The only fix I came up with so far was just removing those items from player markets. Just a suggestion.

EMS Spamming revives in order to get cash
Pretty self explanatory. Spam the revive button of the player over the 10 second revive period. The player will get revived like 40 times and the EMS will make a lot and a lot of money. This is with the esx_ambulancejob script and my only fix was putting the revive reward to 0 and just increasing ems salary. After all it is about rp and not how many revives you can get. This is a lazy fix tho so feel free to add stuff to the script if you want.

People using an alternative steam account to evade bans as well as combat loggers
This is legit the most annoying thing to experience. As if you log in with another steam account but have the same rockstar ID, you game license will be the same therefore a tow cannot be created in the users databse as it would interfere with the other account. So now you got this invisible man running around and RDMing people, and you cannot do much about it other than clientkick him from the console. But then he could join again and get away with all the stuff he does on this alt account as you do not know his main.

Fix:
Use this script. It registers the steam, license, ip, online time, last log, etc of any user on a new table called account_info in your database. And I mean ANY USER. So if someone joins with another steam and he is invisible, you can search his name in account_info, then copy his license and see what user has that exact same license. Then you can ban his original account though es_admin2 or whatever other script you’re using by putting his identifiers there. It will also stop combat loggers as now you got their IP and all other identifiers.
ID Logs

How to offline ban people in es_admin2
Just a quick tutorial for those who don’t know. You can ban and unban people on es_admin2 without having to restart your server once! Wow right? Ok lol. So here is how you offline ban someone. Get their identifier, license, and IP (if you want) for the database. Then navigate over to es_admin2\data\bans.txt and open that up. Then just paste the identifiers but make sure that the starting format for each identifier is correct. (look one row bellow)

steam:
license:
ip:

After you are done banning or unbanning someone. Save the file and close it, then open your server console and type restart es_admin2 and poof, all done.

How to catch instanced players
We all hate instanced people, especially when they are robbing store. Being instanced means being in a server all alone (kind of like a solo session), whilst the rest of the players are on the normal server. Instanced people can only view chat and interact with other players only though there. Now when someone notices they’re instanced, they go on a robbing spree, as no one can catch and arrest them.

How to find them:
Use third part software like the FiveM app on the phone or a discord bot to list all the IDs of players connected to your server. Then check one by one the IDs and see if you can spot them in game or on the leaderboard. If you can’t then just kick that specific ID with the standard /kick ID command or though the console clientkick ID

A new and more advanced ban system
This is only a suggestion, but here is a more advanced admin system that uses the database as a way to ban or unban people. This also works perfectly with the discord bot addition for esx. Here are the links.
Ban SQL
ESX Discord Bot

Players dropping money bags from inventory to dupe them
I don’t have a public fix as a lot of servers use different inventory scripts, however how the bug works is two players get into a car or a bike, one drops money from his inventory, and when they get out they both pick it up. As I said there are different fixes for this as everyone uses their own inventory system. It’s just something to watch out for.

Scripts download
As mentioned before, here is the download for some of the scripts I patched. There are a lot more bugs and patches in esx scripts that can be done. Just thought I would help some newer people by posting this. Enjoy :wink:

Esx Scripts.zip (180.6 KB)

43 Likes

Are you sure you are allowed to “Release” all of this? :smiley: (just asking. correct if i’m wrong)

1 Like

why not? it’s actually a pretty good job right here tbh :smile:

2 Likes

See this part “(just asking. correct if i’m wrong)”. I didn’t know you can re-release scripts like that. Now i know tho!

1 Like

Some of these are not even fixes but just deletes the purpose of the script. Why not just do pull requests on each script github site? I think this is pointless to make all these things to let everyone know since you just could do pull request or report the issue.

1 Like

afaik the esx devs won’t accept pull requests, i’ve seen many try to make some and they all got rejected or not even checked out, they were good quality PRs as well, :man_shrugging:

2 Likes

Lot of stuff have changed since Gizz stopped working on ESX. IMO this is not the way these issues should be handled.

1 Like

Very helpful and thank you!

1 Like

Thanks For Realising This

1 Like

Thanks for your job :smiley:

1 Like

I was afraid of people abusing and breaking the economy, thank you for the releases.

1 Like

cool good job

Update

  • Fixed the police job server.lua as one row was missing
1 Like

I wouldn’t release any of the full scripts without permission and shame on FiveM mods allowing this. You should set them up as script “snippets” with instructions on how to put them in.

Just skimming a couple of these scripts shows that the official ESX releases are newer than what is being offered here. In other words, possibly already fixed. I mean, if you are going to offer “fixed” scripts, at least make sure they are the most recent versions.

2 Likes

I legit said that this is an alternative and what I found as a fix. I even quote from the start If you already found a fix for these issues or have a better solution or alternative fixes, please post them below.

Also, ye releasing code snippets is an option, but some of the scripts have changes all over the place so releasing the full script is much easier. Did I ever claim I built the scripts? No. I even left the original notes and creator credit in the scripts. Don’t see what the problem is to take 5 scripts I modified and put a download to it. Again not claiming it is my work lmao. You got to understand that not everyone is as familiar as you are with taking script snippets and adding them in, so a simple download is easier to understand.

3 Likes

Seeing as how they’re open source and licensed as such… I disagree… that’s the entire premise behind open source.

1 Like

mistyped

1 Like

I do actually agree with you here @Chip_W_Gaming in many points!

Why not just make a fork on github with all the “fixes”? Because even though the code may have some fixes, when ESX admins updates their scripts, the users will have to put this code in again and again. Also if people download all these scripts here, they will not get the new updates coming from ESX.

Also, in my opinion, to not let the owners of the scripts know before posting it is just painful to watch. You haven’t even put credits in your post. So to release scripts that you haven’t been written and not putting credits and links to the original code is just disrespectful in my opinion. Sure it’s open source but use your brain if you still want people to release their stuff.

2 Likes

Why not just make a fork on github with all the “fixes”

Cause most of them aren’t fixes, but more of alternative ways to run the script. Also take fixes to the realestate let’s say. The dude didn’t really update the script once since he released it. I doubt putting it on github will do anything. As mentioned before, all the script downloads still contain the name of the people who did it in the script read me file. It’s open source for a reason, so that anyone can make changes. Think of this as a script addon. It is easier to put it all in one place on the forum where people browse.

1 Like

The esx_jobs code for deposits has been re written already, you cant cheat it like that now

I’ll take look at the things you mentioned, btw instanced players can really easily be fixed. Count players on both client side and server side. If the list doesnt match then kick the client.

1 Like