From 469f7353b15ead290b9676f9a73c7e4433165178 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 7 May 2018 23:02:02 +0200 Subject: [PATCH] Improved cron code and readme --- README.md | 45 +++++++++++++++++++++++++++++++++------------ client/main.lua | 3 ++- server/main.lua | 13 ++----------- 3 files changed, 37 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 4cc0ae94..84248ade 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,43 @@ -# fxserver-esx_bankerjob -FXServer ESX BankerJob +# esx_bankerjob -[REQUIREMENTS] +## Requirements -- cron => https://github.com/FXServer-ESX/fxserver-cron -- esx_addonaccount => https://github.com/FXServer-ESX/fxserver-esx_addonaccount -- esx_society => https://github.com/FXServer-ESX/fxserver-esx_society +- [cron](https://github.com/ESX-Org/cron) +- [esx_addonaccount](https://github.com/ESX-Org/esx_addonaccount) +- [esx_society](https://github.com/ESX-Org/esx_society) -[INSTALLATION] +## Download & Installation -1) CD in your resources/[esx] folder -2) Clone the repository +### Using [fvm](https://github.com/qlaffont/fvm-installer) ``` -git clone https://github.com/FXServer-ESX/fxserver-esx_bankerjob esx_bankerjob +fvm install --save --folder=esx esx-org/esx_bankerjob ``` -3) Import esx_bankerjob.sql in your database -4) Add this in your server.cfg : + +### Using Git +``` +cd resources +git clone https://github.com/ESX-Org/esx_bankerjob [esx]/esx_bankerjob +``` + +### Manually +- Download https://github.com/ESX-Org/esx_bankerjob/archive/master.zip +- Put it in the `[esx]` directory + +- Import `esx_bankerjob.sql` in your database +- Add this in your `server.cfg`: ``` start esx_bankerjob ``` + +# Legal +### License +esx_bankerjob - bank script + +Copyright (C) 2015-2018 Jérémie N'gadi + +This program Is free software: you can redistribute it And/Or modify it under the terms Of the GNU General Public License As published by the Free Software Foundation, either version 3 Of the License, Or (at your option) any later version. + +This program Is distributed In the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty Of MERCHANTABILITY Or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License For more details. + +You should have received a copy Of the GNU General Public License along with this program. If Not, see http://www.gnu.org/licenses/. \ No newline at end of file diff --git a/client/main.lua b/client/main.lua index 95f3f35b..460d99a8 100644 --- a/client/main.lua +++ b/client/main.lua @@ -54,6 +54,7 @@ function OpenBankActionsMenu () 'default', GetCurrentResourceName(), 'bank_actions', { title = _U('bank'), + align = 'top-left', elements = elements, }, function (data, menu) @@ -291,7 +292,7 @@ end) -- Key Controls Citizen.CreateThread(function () while true do - Citizen.Wait(0) + Citizen.Wait(10) if CurrentAction ~= nil then SetTextComponentFormat('STRING') diff --git a/server/main.lua b/server/main.lua index 6fde1afd..78fc6386 100644 --- a/server/main.lua +++ b/server/main.lua @@ -68,21 +68,12 @@ function CalculateBankSavings (d, h, m) { ['@account_name'] = 'bank_savings' }, function (result) local bankInterests = 0 - local xPlayers = ESX.GetPlayers() for i=1, #result, 1 do local foundPlayer = false - local xPlayer = nil + local xPlayer = ESX.GetPlayerFromIdentifier(result[i].owner) - for i=1, #xPlayers, 1 do - local xPlayer2 = ESX.GetPlayerFromId(xPlayers[i]) - if xPlayer2.identifier == result[i].owner then - foundPlayer = true - xPlayer = xPlayer2 - end - end - - if foundPlayer then + if xPlayer ~= nil then TriggerEvent('esx_addonaccount:getAccount', 'bank_savings', xPlayer.identifier, function (account) local interests = math.floor(account.money / 100 * Config.BankSavingPercentage) bankInterests = bankInterests + interests