From fce1da377e335d5a6bac0d6fb987c3de44c7bb25 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 7 May 2018 22:14:59 +0200 Subject: [PATCH] Improved washing money code, README cleanup --- README.md | 53 ++++++++++++++++++++++++++++-------------- __resource.lua | 2 +- esx_society.sql | 13 +++++------ server/main.lua | 61 +++++++++++++++++-------------------------------- 4 files changed, 64 insertions(+), 65 deletions(-) diff --git a/README.md b/README.md index 46c786af..b7e0f68f 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,38 @@ -# fxserver-esx_society -FXServer ESX Society +# esx_society -[REQUIREMENTS] +## Requirements +- [cron](https://github.com/ESX-Org/cron) +- [esx_addonaccount](https://github.com/ESX-Org/esx_addonaccount) -- cron => https://github.com/FXServer-ESX/fxserver-cron -- esx_addonaccount => https://github.com/FXServer-ESX/fxserver-esx_addonaccount +## Download & Installation -[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_society esx_society +fvm install --save --folder=esx esx-org/esx_society ``` -3) Import esx_society.sql in your database -4) Add this in your server.cfg : + +### Using Git +``` +cd resources +git clone https://github.com/ESX-Org/esx_society [esx]/esx_society +``` + +### Manually +- Download https://github.com/ESX-Org/esx_society/archive/master.zip +- Put it in the `[esx]` directory + +- Import `esx_society.sql` in your database +- Add this in your `server.cfg`: ``` start esx_society ``` -[EXPLANATION] -ESX Society works with addon accounts named 'society_xxx' like 'society_taxi' or 'society_realestateagent'. -If you job grade is 'boss', you will see the society_xxx money of your job showed in the HUD. +## Explanation +ESX Society works with addon accounts named 'society_xxx', for example 'society_taxi' or 'society_realestateagent'. If you job grade is 'boss' the society money will be displayed in your hud. -[USAGE] -``` +## Usage +```lua local society = 'taxi' local amount = 100 @@ -33,3 +40,15 @@ TriggerServerEvent('esx_society:withdrawMoney', society, amount) TriggerServerEvent('esx_society:depositMoney', society, amount) TriggerServerEvent('esx_society:washMoney', society, amount) ``` + +# Legal +### License +esx_society - societies for ESX + +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/__resource.lua b/__resource.lua index c89ac6cc..e1569c35 100644 --- a/__resource.lua +++ b/__resource.lua @@ -2,7 +2,7 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' description 'ESX Society' -version '1.0.3' +version '1.0.4' server_scripts { '@mysql-async/lib/MySQL.lua', diff --git a/esx_society.sql b/esx_society.sql index 6f2594d9..0e34e3ec 100644 --- a/esx_society.sql +++ b/esx_society.sql @@ -1,11 +1,10 @@ USE `essentialmode`; CREATE TABLE `society_moneywash` ( - - `id` int(11) NOT NULL AUTO_INCREMENT, - `identifier` varchar(60) NOT NULL, - `society` varchar(60) NOT NULL, - `amount` int(11) NOT NULL, - - PRIMARY KEY (`id`) + `id` int(11) NOT NULL AUTO_INCREMENT, + `identifier` varchar(60) NOT NULL, + `society` varchar(60) NOT NULL, + `amount` int(11) NOT NULL, + + PRIMARY KEY (`id`) ); diff --git a/server/main.lua b/server/main.lua index 85c5cf77..2fefcd13 100644 --- a/server/main.lua +++ b/server/main.lua @@ -366,49 +366,30 @@ ESX.RegisterServerCallback('esx_society:getVehiclesInGarage', function(source, c end) -function WashMoneyCRON(d, h, m) +function WashMoneyCRON() + MySQL.Async.fetchAll( + 'SELECT * FROM society_moneywash', {}, + function(result) + for i=1, #result, 1 do - MySQL.Async.fetchAll( - 'SELECT * FROM society_moneywash', - {}, - function(result) + -- add society money + local society = GetSociety(result[i].society) + TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) + account.addMoney(result[i].amount) + end) - local xPlayers = ESX.GetPlayers() - - for i=1, #result, 1 do - - local foundPlayer = false - local xPlayer = nil - local society = GetSociety(result[i].society) - - for j=1, #xPlayers, 1 do - local xPlayer2 = ESX.GetPlayerFromId(xPlayers[j]) - if xPlayer2.identifier == result[i].identifier then - foundPlayer = true - xPlayer = xPlayer2 - end - end - - TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) - account.addMoney(result[i].amount) - end) - - if foundPlayer then - TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have_laundered', result[i].amount)) - end - - MySQL.Async.execute( - 'DELETE FROM society_moneywash WHERE id = @id', - { - ['@id'] = result[i].id - } - ) - - end - - end - ) + -- send notification if player is online + local xPlayer = ESX.GetPlayerFromIdentifier(result[i].identifier) + if xPlayer ~= nil then + TriggerClientEvent('esx:showNotification', xPlayer.source, _U('you_have_laundered', result[i].amount)) + end + MySQL.Async.execute('DELETE FROM society_moneywash WHERE id = @id', + { + ['@id'] = result[i].id + }) + end + end) end TriggerEvent('cron:runAt', 3, 0, WashMoneyCRON)