[Help] ESX_Society

Dear,

I need help because i can’t access to the menu boss from the job menu.
I have the line for access to menu boss in my job menu but there is no action when I click on it.

Original menu :

      if data.current.value == 'boss_actions' then
        TriggerEvent('esx_society:openBossMenu', 'mecano', function(data, menu)
		TriggerServerEvent('esx_society:withdrawMoney', society, amount)
		TriggerServerEvent('esx_society:depositMoney', society, amount)
		TriggerServerEvent('esx_society:washMoney', society, amount)
          menu.close()
        end)

If someone knows how can i fix the problem, i take help with pleasure !

Do you got esx_society?

1 Like

Yes, and society work because i have the account information in my HUD :confused:

I got an error on my consol maybe it’s for that :

Error running call reference function for resource esx_society: citizen:/scripting/lua/scheduler.lua:348: server/main.lua:91: attempt to index a nil value (upvalue 'xPlayer')
stack traceback:
        server/main.lua:91: in upvalue 'ref'
        citizen:/scripting/lua/scheduler.lua:334: in function <citizen:/scripting/lua/scheduler.lua:333>
        [C]: in function 'xpcall'
        citizen:/scripting/lua/scheduler.lua:333: in function <citizen:/scripting/lua/scheduler.lua:332>
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:348: in function <citizen:/scripting/lua/scheduler.lua:319>
        [C]: in function 'coroutine.resume'
        citizen:/scripting/lua/scheduler.lua:34: in field 'CreateThreadNow'
        citizen:/scripting/lua/scheduler.lua:173: in function <citizen:/scripting/lua/scheduler.lua:138>
Error running system event handling function for resource esx_addonaccount: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: 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:560: in local 'cb'
        server/main.lua:85: in upvalue 'handler'
        citizen:/scripting/lua/scheduler.lua:174: in function <citizen:/scripting/lua/scheduler.lua:173>
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
        citizen:/scripting/lua/scheduler.lua:173: in function <citizen:/scripting/lua/scheduler.lua:138>
Error running system event handling function for resource esx_society: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: server/main.lua:110: attempt to index a nil value (local 'xPlayer')
stack traceback:
        server/main.lua:110: in upvalue 'handler'
        citizen:/scripting/lua/scheduler.lua:174: in function <citizen:/scripting/lua/scheduler.lua:173>
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
        citizen:/scripting/lua/scheduler.lua:173: in function <citizen:/scripting/lua/scheduler.lua:138>
Error running system event handling function for resource esx_society: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: server/main.lua:130: attempt to index a nil value (local 'xPlayer')
stack traceback:
        server/main.lua:130: in upvalue 'handler'
        citizen:/scripting/lua/scheduler.lua:174: in function <citizen:/scripting/lua/scheduler.lua:173>
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
        citizen:/scripting/lua/scheduler.lua:173: in function <citizen:/scripting/lua/scheduler.lua:138>


RegisterServerEvent('esx_society:withdrawMoney')
AddEventHandler('esx_society:withdrawMoney', function(society, amount)

  local xPlayer = ESX.GetPlayerFromId(source)
  local society = GetSociety(society)

  TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account)

    if amount > 0 and account.money >= amount then

      account.removeMoney(amount)
      xPlayer.addMoney(amount)

      TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_withdrawn') .. amount)

    else
      TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_amount'))
    end

  end)

end)

RegisterServerEvent('esx_society:depositMoney')
AddEventHandler('esx_society:depositMoney', function(society, amount)

  local xPlayer = ESX.GetPlayerFromId(source)
  local society = GetSociety(society)

  if amount > 0 and xPlayer.get('money') >= amount then

    TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account)
      xPlayer.removeMoney(amount)
      account.addMoney(amount)
    end)

    TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_deposited') .. amount)

  else
    TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_amount'))
  end

end)

RegisterServerEvent('esx_society:washMoney')
AddEventHandler('esx_society:washMoney', function(society, amount)

  local xPlayer = ESX.GetPlayerFromId(source)
  local account = xPlayer.getAccount('black_money')

  if amount > 0 and account.money >= amount then

    xPlayer.removeAccountMoney('black_money', amount)

      MySQL.Async.execute(
        'INSERT INTO society_moneywash (identifier, society, amount) VALUES (@identifier, @society, @amount)',
        {
          ['@identifier'] = xPlayer.identifier,
          ['@society']    = society,
          ['@amount']     = amount
        },
        function(rowsChanged)
          TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have') .. amount .. '~s~ en attente de ~r~blanchiement~s~ (24h)')
        end
      )

  else
    TriggerClientEvent('esx:showNotification', xPlayer.source, _U('invalid_amount'))
  end

end)


The problem is xPlayer but i don’t know how can i resolved it…

Where you from? I could probaly help you with this.

I’m french, i send you my discord by message :wink:

1 Like

do you got esx_addonaccount then? :slight_smile:

Yes, it’s working now I reinstall society, add on account and cron :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.