[DISCONTINUED] esx-kr-advanced-shops

That right, that is huge bug i hope.

Also i getting some problems when i open and close the shop, sometimes all items duplicated (?).
https://streamable.com/y3vwi

https://streamable.com/y3vwi

I may have found a fix :

server/main.lua line 155 change

RegisterServerEvent('esx_kr_shops:Buy')
AddEventHandler('esx_kr_shops:Buy', function(id, Item, ItemCount)
  local src = source
  local identifier = ESX.GetPlayerFromId(src).identifier
  local xPlayer = ESX.GetPlayerFromId(src)

        local ItemCount = tonumber(ItemCount)

        MySQL.Async.fetchAll(
        'SELECT * FROM shops WHERE ShopNumber = @Number AND item = @item',
        {
            ['@Number'] = id,
            ['@item'] = Item,
        }, function(result)

    
        MySQL.Async.fetchAll(
        'SELECT * FROM owned_shops WHERE ShopNumber = @Number',
        {
            ['@Number'] = id,
        }, function(result2)

            if xPlayer.getMoney() < ItemCount * result[1].price then
                TriggerClientEvent('esx:showNotification', src, '~r~You don\'t have enough money.')
            else
                xPlayer.removeMoney(ItemCount * result[1].price)
                TriggerClientEvent('esx:showNotification', xPlayer.source, '~g~You bought ' .. ItemCount .. 'x ' .. Item .. ' for $' .. ItemCount * result[1].price)
                xPlayer.addInventoryItem(result[1].item, ItemCount)

                MySQL.Async.execute("UPDATE owned_shops SET money = @money WHERE ShopNumber = @Number",
                {
                    ['@money']      = result2[1].money + (result[1].price * ItemCount),
                    ['@Number']     = id,
                })
    

                if result[1].count ~= ItemCount then
                    MySQL.Async.execute("UPDATE shops SET count = @count WHERE item = @name AND ShopNumber = @Number",
                    {
                        ['@name'] = Item,
                        ['@Number'] = id,
                        ['@count'] = result[1].count - ItemCount
                    })
                elseif result[1].count == ItemCount then
                    MySQL.Async.fetchAll("DELETE FROM shops WHERE item = @name AND ShopNumber = @Number",
                    {
                        ['@Number'] = id,
                        ['@name'] = result[1].item
                    })
                end
            end
        end)
    end)
end)

to

RegisterServerEvent('esx_kr_shops:Buy')
AddEventHandler('esx_kr_shops:Buy', function(id, Item, ItemCount)
  local src = source
  local identifier = ESX.GetPlayerFromId(src).identifier
  local xPlayer = ESX.GetPlayerFromId(src)

        local ItemCount = tonumber(ItemCount)

        MySQL.Async.fetchAll(
        'SELECT * FROM shops WHERE ShopNumber = @Number AND item = @item',
        {
            ['@Number'] = id,
            ['@item'] = Item,
        }, function(result)

    
        MySQL.Async.fetchAll(
        'SELECT * FROM owned_shops WHERE ShopNumber = @Number',
        {
            ['@Number'] = id,
        }, function(result2)

            if xPlayer.getMoney() < ItemCount * result[1].price then
                TriggerClientEvent('esx:showNotification', src, '~r~You don\'t have enough money.')
            elseif ItemCount <= 0 then
                TriggerClientEvent('esx:showNotification', src, '~r~invalid quantity.')
            else
                xPlayer.removeMoney(ItemCount * result[1].price)
                TriggerClientEvent('esx:showNotification', xPlayer.source, '~g~You bought ' .. ItemCount .. 'x ' .. Item .. ' for $' .. ItemCount * result[1].price)
                xPlayer.addInventoryItem(result[1].item, ItemCount)

                MySQL.Async.execute("UPDATE owned_shops SET money = @money WHERE ShopNumber = @Number",
                {
                    ['@money']      = result2[1].money + (result[1].price * ItemCount),
                    ['@Number']     = id,
                })
    

                if result[1].count ~= ItemCount then
                    MySQL.Async.execute("UPDATE shops SET count = @count WHERE item = @name AND ShopNumber = @Number",
                    {
                        ['@name'] = Item,
                        ['@Number'] = id,
                        ['@count'] = result[1].count - ItemCount
                    })
                elseif result[1].count == ItemCount then
                    MySQL.Async.fetchAll("DELETE FROM shops WHERE item = @name AND ShopNumber = @Number",
                    {
                        ['@Number'] = id,
                        ['@name'] = result[1].item
                    })
                end
            end
        end)
    end)
end)
2 Likes

IS there anybody here that could spare 5 minutes to help me implement this, I’ve done everything it instructed but hasn’t worked.

@Barack what exactly u have add?

It’s for fix the fact that you order a negative value in the item number for the buyer.

This is amazing man, this has to be made into other scripts

Oh, I found solution for that - thanks.

I have not experienced that have you renamed the script or edited it?

Nothing at all.

I added the script as it is and followed all the steps. :confused:

@KRILLE Very cool script. I love it. Thanks for releasing this. I made it so that in config file that each shop can have their own shop blip color and size. @KRILLE. Now i just need to duplicate this resource and make a weapon shop out of this.

1 Like

ill would like to see that. XxFri3ndlyxX…
good idea

got this when taking out shipments has worked before

Error running call reference function for resource esx-kr-advanced-shops: citizen:/scripting/lua/scheduler.lua:403: citizen:/scripting/lua/MessagePack.lua:830: missing bytes
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/MessagePack.lua:830: in method ‘underflow’
citizen:/scripting/lua/MessagePack.lua:465: in field ‘any’
citizen:/scripting/lua/MessagePack.lua:860: in field ‘unpack’
citizen:/scripting/lua/scheduler.lua:626: in field ‘addInventoryItem’
@esx-kr-advanced-shops/server/main.lua:276: in upvalue ‘ref’
citizen:/scripting/lua/scheduler.lua:389: in function citizen:/scripting/lua/scheduler.lua:388
[C]: in function ‘xpcall’
citizen:/scripting/lua/scheduler.lua:388: in function citizen:/scripting/lua/scheduler.lua:387
stack traceback:
[C]: in function ‘error’
citizen:/scripting/lua/scheduler.lua:403: in function citizen:/scripting/lua/scheduler.lua:372
Error: Unhandled error in timer: Error: BUFFER_SHORTAGE
Error: BUFFER_SHORTAGE
at n.e [as reserve] (citizen:/scripting/v8/msgpack.js:29:12766)
at h (citizen:/scripting/v8/msgpack.js:29:15761)
at n.r [as decode] (citizen:/scripting/v8/msgpack.js:29:13908)
at n.fetch (citizen:/scripting/v8/msgpack.js:29:6972)
at n.u [as read] (citizen:/scripting/v8/msgpack.js:29:12076)
at Object.n [as decode] (citizen:/scripting/v8/msgpack.js:29:7097)
at unpack (citizen:/scripting/v8/main.js:20:33)
at citizen:/scripting/v8/main.js:51:20
at setImmediate (mysql-async.js:4962:9)
at Object.callback (citizen:/scripting/v8/timer.js:96:21)

[ERROR] [MySQL] An error happens on MySQL for query “SELECT * FROM shops WHERE ShopNumber = @ShopNumber {@ShopNumber=8}”: Unknown column ‘ShopNumber’ in ‘where clause’
I HAVE THIS ERROR CAN ANYONE SOLVE THIS?

Show screenshot of table shops please

Good day I have a problem when I click on Boss action does not come a window but only a mouse pointer please help me!

Video: https://www.youtube.com/watch?v=KfcgAPJ3Tmw

Server.cfg

You probably don’t want to change these!

Only change them if you’re using a server with multiple network interfaces.

endpoint_add_tcp “0.0.0.0:30120”
endpoint_add_udp “0.0.0.0:30120”

set es_enableCustomData 1
set mysql_connection_string “server=localhost;database=essentialmode;userid=essentialmode;password=ANONYM”

FIVEM

start mapmanager
start chat
start spawnmanager
start sessionmanager
start fivem
start hardcap
start ■■■■■■■
start scoreboard

essentials

start essentialmode
start esplugin_mysql
start mysql-async
start es_extended
start es_admin2
start async
start cron
start es_ui

Phone

start gcphone
start esx_addons_gcphone

ESX

start esx_accessories
start esx_addonaccount
start esx_addoninventory
start esx_ambulancejob
start esx_animations
start esx_basicneeds
start esx_barbershop
start esx_billing
start esx_boilerplate
start esx_clotheshop
start esx_datastore
start esx_holdup
start esx_identity
start esx_joblisting
start esx_jobs
start esx_lscustom
start esx_license
start esx_mecanojob
start esx_mechanicjob
start esx_menu_default
start esx_menu_dialog
start esx_menu_list
start esx_optionalneeds
start esx_policejob
start esx_realestateagentjob
start esx_property
start esx_service
#start esx_shops
start esx_skin
start esx_society
start esx_status
start esx_taxijob
start esx_weaponshop
start instance
start skinchanger

CUSTOM

start new_banking
start eden_garage
start ft_libs
start esx_kr_shop

VehicleShops

start esx_vehicleshop
start esx_vansshop
start esx_suvshop
start esx_supershop
start esx_sportshop
start esx_sedanshop
start esx_offroad
start esx_muscleshop
start esx_lkwshop
start esx_fahrradshop
start esx_coupesshop
start esx_compactsshop
start esx_bikeshop

DEVHILFE

start showcoords

This allows players to use scripthook based plugins such as lambda menu.

Set this to 0 to disallow scripthook.

sv_scriptHookAllowed 0

Uncomment this to enable RCON. Make sure to change the password.

#rcon_password changeme

A comma-separated list of tags for your server.

For example:

- sets tags “drifting, cars, racing”

Or:

- sets tags “roleplay, military, tanks”

sets tags “default”

Set an optional server info and connecting banner image url.

Size doesn’t matter, any banner sized image will be fine.

#sets banner_detail “http://url.to/image.png
#sets banner_connecting “http://url.to/image.png

Set your server’s hostname

sv_hostname “[GERMAN|NEU] ^5Rebalze HarcoreRP^7|^3Ab 16^7|^2Durchdachtes Wirtschaftssystem^7|^6RolePlay Fahrschule^7|etc…|^6Discord:^5discord.gg/ekNnuP^7|^1In Wartungsarbeiten!!^7|^1DESIGNER GESUCHT!!^7|”

Nested configs!

#exec server_internal.cfg

Loading a server icon (96x96 PNG file)

#load_server_icon myLogo.png

convars which can be used in scripts

set temp_convar “hey world!”

Uncomment this line if you do not want your server to be listed in the server browser.

#sv_master1 “”

Want to only allow players authenticated with a third-party provider like Steam?

Don’t forget Social Club is a third party provider too!

#sv_authMaxVariance 1
#sv_authMinTrust 5

Add system admins

add_ace group.admin command allow # allow all commands
add_ace group.admin command.quit deny # but don’t allow quit
add_principal identifier.steam:110000112345678 group.admin # add the admin to the group

Hide player endpoints in external log output.

sv_endpointprivacy true

Server player slot limit (must be between 1 and 32)

sv_maxclients 32

License key for your server (https://keymaster.fivem.net)

sv_licenseKey ANONYM

rename it to esx_kr_shop

It must be named esx-kr-advanced-shops.

1 Like

thank you i have a question:
when you spawn on the server you are always random how to do that spawning where you are disconnected

Sry my english is not god

renaming the script will not help

It must be named esx-kr-advanced-shops.