From f619a9ff53f0a40a2d704ed77597bc088f7fc922 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Wed, 25 Jul 2018 22:55:02 +0200 Subject: [PATCH] Minor changes, readme improvements --- README.md | 60 ++++++++++++++++++++++++++++++++++--------------- __resource.lua | 2 ++ server/main.lua | 44 ++++++++++++++---------------------- 3 files changed, 61 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index caae750b..79b83fa8 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,61 @@ -# fxserver-esx_addonaccount -ESX AddonAccount +# esx_addonaccount -[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_addonaccount esx_addonaccount +fvm install --save --folder=esx esx-org/esx_addonaccount ``` -3) Import esx_addonaccount.sql in your database -4) Add this in your server.cfg : + +### Using Git +``` +cd resources +git clone https://github.com/ESX-Org/esx_addonaccount [esx]/esx_addonaccount +``` + +### Manually +- Download https://github.com/ESX-Org/esx_addonaccount/archive/master.zip +- Put it in the `[esx]` directory + +## Installation +- Import `esx_addonaccount.sql` in your database +- Add this in your `server.cfg`: ``` start esx_addonaccount ``` -[USAGE] +## Usage +There is two types of accounts: shared and not shared. -There is two types of accounts : shared and not shared. +- Shared accounts doesn't belong to a specific user. Example: society accounts. +- None-shared accounts are created for every user in the server. They are created in db when player is loaded, Example: property black money -- Shared accounts dont belong to a specific user. Example : society account. -- Not shared accounts are created for every user in the server. They are created in db when player is loaded, Example : property black money +### `addon_account` database information +You must create an account in the database -You must create the account in the database (addon_account) before using it : +| `name` | `label` | `shared` | +| -------- | ------- | -------- | +| name of the account | label of the account (not used) | is the account shared with others? (boolean either `0` or `1`) | -name = name of the account, label = label of the account, shared (0 or 1) = Is account shared - -``` +```lua TriggerEvent('esx_addonaccount:getSharedAccount', 'society_realestateagent', function(account) - account.addMoney(500) + account.addMoney(500) end) TriggerEvent('esx_addonaccount:getAccount', 'property_black_money', 'steam:0123456789', function(account) - account.removeMoney(500) + account.removeMoney(500) end) ``` + +# Legal +### License +esx_addonaccount - addon account 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 e740147b..4b545468 100644 --- a/__resource.lua +++ b/__resource.lua @@ -9,3 +9,5 @@ server_scripts { 'server/classes/addonaccount.lua', 'server/main.lua' } + +dependency 'es_extended' \ No newline at end of file diff --git a/server/main.lua b/server/main.lua index d8633de7..37614381 100644 --- a/server/main.lua +++ b/server/main.lua @@ -15,25 +15,19 @@ AddEventHandler('onMySQLReady', function () local label = result[i].label local shared = result[i].shared - local result2 = MySQL.Sync.fetchAll( - 'SELECT * FROM addon_account_data WHERE account_name = @account_name', - { - ['@account_name'] = name - } - ) + local result2 = MySQL.Sync.fetchAll('SELECT * FROM addon_account_data WHERE account_name = @account_name', { + ['@account_name'] = name + }) if shared == 0 then table.insert(AccountsIndex, name) - + Accounts[name] = {} - + for j=1, #result2, 1 do - local addonAccount = CreateAddonAccount(name, result2[j].owner, result2[j].money) - table.insert(Accounts[name], addonAccount) - end else @@ -42,13 +36,11 @@ AddEventHandler('onMySQLReady', function () if #result2 == 0 then - MySQL.Sync.execute( - 'INSERT INTO addon_account_data (account_name, money, owner) VALUES (@account_name, @money, NULL)', - { - ['@account_name'] = name, - ['@money'] = 0 - } - ) + MySQL.Sync.execute('INSERT INTO addon_account_data (account_name, money, owner) VALUES (@account_name, @money, NULL)', + { + ['@account_name'] = name, + ['@money'] = 0 + }) money = 0 @@ -87,7 +79,7 @@ end) AddEventHandler('esx:playerLoaded', function(source) local _source = source - local xPlayer = ESX.GetPlayerFromId(_source) + local xPlayer = ESX.GetPlayerFromId(_source) local addonAccounts = {} for i=1, #AccountsIndex, 1 do @@ -97,14 +89,12 @@ AddEventHandler('esx:playerLoaded', function(source) if account == nil then - MySQL.Async.execute( - 'INSERT INTO addon_account_data (account_name, money, owner) VALUES (@account_name, @money, @owner)', - { - ['@account_name'] = name, - ['@money'] = 0, - ['@owner'] = xPlayer.identifier - } - ) + MySQL.Async.execute('INSERT INTO addon_account_data (account_name, money, owner) VALUES (@account_name, @money, @owner)', + { + ['@account_name'] = name, + ['@money'] = 0, + ['@owner'] = xPlayer.identifier + }) account = CreateAddonAccount(name, xPlayer.identifier, 0) table.insert(Accounts[name], account)