├── LICENSE ├── README.md ├── client └── client.main.lua ├── config.lua ├── es_extended ├── ESX_1.1 │ ├── commands.lua │ └── player.lua ├── ESX_1.2 │ ├── commands.lua │ └── player.lua └── README.md ├── esx_ambulancejob └── server │ └── main.lua ├── esx_drugs ├── README.md ├── chemicals.lua ├── coke.lua ├── heroin.lua ├── lsd.lua ├── main.lua ├── meth.lua ├── moneywash.lua └── weed.lua ├── esx_society └── server │ └── main.lua ├── fxmanifest.lua ├── locales ├── de.lua ├── en.lua └── lt.lua └── server ├── server.custom.lua └── server.main.lua /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 TopicElite 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Topic-DiscordLogs 2 | 3 | Good day, I have finished something small here. 4 | 5 | I know there are already several Discord log scripts. Nevertheless, I present you my free DiscordLog script. 6 | 7 | What do I offer? 8 | - Support for questions 9 | - Change requests / ideas are welcome 10 | - bug fixes 11 | - Will be updated 12 | - Log for: Commands | Items | Weapons | Money | Drugs | Resources | Ambulance | Society 13 | - Create your own log events. 14 | 15 | If you want to use the logs: Commands, Items, Weapons, Money you have to make changes in es_extended. 16 | See [es_extended/README.md](https://github.com/TopicElite/Topic-DiscordLogs/tree/main/es_extended). 17 | 18 | If you want to use the DrugsLog, I offer a template for esx_drugs, otherwise you can find all events in [esx_drugs/README.md](https://github.com/TopicElite/Topic-DiscordLogs/tree/main/esx_drugs). 19 | 20 | If you want to use the AmbulanceLog, I offer a template for [esx_ambulancejob](https://github.com/esx-framework/esx-legacy/tree/main/%5Besx_addons%5D/esx_ambulancejob). 21 | 22 | If you want to use the SocietyLog, I offer a template for [esx_society](https://github.com/esx-framework/esx-legacy/tree/main/%5Besx_addons%5D/esx_society). 23 | 24 | For further questions I am available on my Discord server. 25 | 26 | Bugs or requests are welcome to be reported via my [Discord Server](https://discord.gg/TymDT77Fvd) 27 | 28 | **Please do not republish this script or sell it on other platforms.** 29 | -------------------------------------------------------------------------------- /client/client.main.lua: -------------------------------------------------------------------------------- 1 | ESX = nil 2 | Citizen.CreateThread(function() 3 | while ESX == nil do 4 | TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) 5 | Citizen.Wait(0) 6 | end 7 | end) 8 | -------------------------------------------------------------------------------- /config.lua: -------------------------------------------------------------------------------- 1 | Config = {} 2 | 3 | Config.Locale = 'en' 4 | 5 | Config.username = "RP Server" 6 | Config.avatar = "https://via.placeholder.com/30x30" 7 | Config.communtiyName = "RP Server" 8 | Config.communtiyLogo = "https://via.placeholder.com/30x30" 9 | Config.FooterIcon = "https://via.placeholder.com/30x30" 10 | 11 | Config.ActionColors = { -- https://www.colorhexa.com/ -> decimal value 12 | ['Add'] = 65280, -- Green (#00ff00) 13 | ['Remove'] = 16711680, -- Red (#ff0000) 14 | ['Set'] = 16747264, -- Orange (#ff8b00) 15 | ['Command'] = 16711680, -- Red (#ff0000) 16 | ['Sell'] = 65484, -- Turquoise (#00ffcc) 17 | ['Harvest'] = 65280, -- Green (#00ff00) 18 | ['Processed'] = 16747264, -- Orange (#ff8b00) 19 | ['Wash'] = 16747264, -- Orange (#ff8b00) 20 | ['Starting'] = 16747264, -- Orange (#ff8b00) 21 | ['Start'] = 65280, -- Green (#00ff00) 22 | ['Stop'] = 16711680, -- Red (#ff0000) 23 | ['Revive'] = 65280, -- Green (#00ff00) 24 | ['Heal'] = 16747264, -- Orange (#ff8b00) 25 | ['Hire'] = 65280, -- Green (#00ff00 26 | ['Promote'] = 16747264, -- Orange (#ff8b00)) 27 | ['Fire'] = 16711680, -- Red (#ff0000) 28 | ['Nothing'] = 16777215, -- White (#ffffff) 29 | } 30 | 31 | Config.MinMoneyAmount = 0 -- Sends a money log only when this number is exceeded 32 | 33 | Config.webhooks = { 34 | commands = "", 35 | items = "", 36 | weapon = "", 37 | money = "", 38 | drugs = "", 39 | resource = "", 40 | ambulance = "", 41 | society = "", 42 | afterRPDeath = "", 43 | } 44 | 45 | Config.CustomLog = { 46 | 47 | {-- Example 48 | webhook = "", 49 | embedColor = 16777215, -- White (#ffffff) 50 | serverEventName = "TestLog", 51 | }, 52 | } 53 | 54 | -- Example 55 | RegisterCommand("testLog", function(source , args , rawCommand) 56 | TriggerEvent('7DiscordLog:TestLog', "Test Title", "Test Description") 57 | end, true) 58 | -------------------------------------------------------------------------------- /es_extended/ESX_1.1/commands.lua: -------------------------------------------------------------------------------- 1 | TriggerEvent('es:addGroupCommand', 'tp', 'admin', function(source, args, user) 2 | local x = tonumber(args[1]) 3 | local y = tonumber(args[2]) 4 | local z = tonumber(args[3]) 5 | 6 | if x and y and z then 7 | TriggerClientEvent('esx:teleport', source, { 8 | x = x, 9 | y = y, 10 | z = z 11 | }) 12 | else 13 | TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Invalid coordinates!") 14 | end 15 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/tp', x .. " " .. y .. " " .. z) 16 | end, function(source, args, user) 17 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 18 | end, {help = "Teleport to coordinates", params = {{name = "x", help = "X coords"}, {name = "y", help = "Y coords"}, {name = "z", help = "Z coords"}}}) 19 | 20 | TriggerEvent('es:addGroupCommand', 'setjob', 'mod', function(source, args, user) 21 | if tonumber(args[1]) and args[2] and tonumber(args[3]) then 22 | local xPlayer = ESX.GetPlayerFromId(args[1]) 23 | 24 | if xPlayer then 25 | if ESX.DoesJobExist(args[2], args[3]) then 26 | xPlayer.setJob(args[2], args[3]) 27 | else 28 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'That job does not exist.' } }) 29 | end 30 | 31 | else 32 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Player not online.' } }) 33 | end 34 | else 35 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Invalid usage.' } }) 36 | end 37 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/setjob', xPlayer.getName() .. " " .. args[2] .. " " .. args[3]) 38 | end, function(source, args, user) 39 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 40 | end, {help = _U('setjob'), params = {{name = "id", help = _U('id_param')}, {name = "job", help = _U('setjob_param2')}, {name = "grade_id", help = _U('setjob_param3')}}}) 41 | 42 | 43 | 44 | TriggerEvent('es:addGroupCommand', 'loadipl', 'admin', function(source, args, user) 45 | TriggerClientEvent('esx:loadIPL', -1, args[1]) 46 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/loadipl', ESX.GetPlayerFromId(args[1]).getName()) 47 | end, function(source, args, user) 48 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 49 | end, {help = _U('load_ipl')}) 50 | 51 | TriggerEvent('es:addGroupCommand', 'unloadipl', 'admin', function(source, args, user) 52 | TriggerClientEvent('esx:unloadIPL', -1, args[1]) 53 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/unloadipl', ESX.GetPlayerFromId(args[1]).getName()) 54 | end, function(source, args, user) 55 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 56 | end, {help = _U('unload_ipl')}) 57 | 58 | TriggerEvent('es:addGroupCommand', 'playanim', 'admin', function(source, args, user) 59 | TriggerClientEvent('esx:playAnim', -1, args[1], args[3]) 60 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/playanim', args[1] .. " " .. args[3]) 61 | end, function(source, args, user) 62 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 63 | end, {help = _U('play_anim')}) 64 | 65 | TriggerEvent('es:addGroupCommand', 'playemote', 'admin', function(source, args, user) 66 | TriggerClientEvent('esx:playEmote', -1, args[1]) 67 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/playemote', args[1]) 68 | end, function(source, args, user) 69 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 70 | end, {help = _U('play_emote')}) 71 | 72 | TriggerEvent('es:addGroupCommand', 'car', 'mod', function(source, args, user) 73 | TriggerClientEvent('esx:spawnVehicle', source, args[1]) 74 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/car', args[1]) 75 | end, function(source, args, user) 76 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 77 | end, {help = _U('spawn_car'), params = {{name = "car", help = _U('spawn_car_param')}}}) 78 | 79 | TriggerEvent('es:addGroupCommand', 'cardel', 'admin', function(source, args, user) 80 | TriggerClientEvent('esx:deleteVehicle', source) 81 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/cardel', " ") 82 | end, function(source, args, user) 83 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 84 | end, {help = _U('delete_vehicle')}) 85 | 86 | TriggerEvent('es:addGroupCommand', 'dv', 'mod', function(source, args, user) 87 | TriggerClientEvent('esx:deleteVehicle', source) 88 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/dv', " ") 89 | end, function(source, args, user) 90 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 91 | end, {help = _U('delete_vehicle')}) 92 | 93 | TriggerEvent('es:addGroupCommand', 'spawnped', 'superadmin', function(source, args, user) 94 | TriggerClientEvent('esx:spawnPed', source, args[1]) 95 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/spawnped', args[1]) 96 | end, function(source, args, user) 97 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 98 | end, {help = _U('spawn_ped'), params = {{name = "name", help = _U('spawn_ped_param')}}}) 99 | 100 | TriggerEvent('es:addGroupCommand', 'spawnobject', 'superadmin', function(source, args, user) 101 | TriggerClientEvent('esx:spawnObject', source, args[1]) 102 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/spawnobject', args[1]) 103 | end, function(source, args, user) 104 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 105 | end, {help = _U('spawn_object'), params = {{name = "name"}}}) 106 | 107 | TriggerEvent('es:addGroupCommand', 'setmoney', 'superadmin', function(source, args, user) 108 | local _source = source 109 | local target = tonumber(args[1]) 110 | local money_type = args[2] 111 | local money_amount = tonumber(args[3]) 112 | 113 | local xPlayer = ESX.GetPlayerFromId(target) 114 | 115 | if target and money_type and money_amount and xPlayer ~= nil then 116 | if money_type == 'cash' then 117 | xPlayer.setMoney(money_amount) 118 | elseif money_type == 'bank' then 119 | xPlayer.setAccountMoney('bank', money_amount) 120 | elseif money_type == 'black' then 121 | xPlayer.setAccountMoney('black_money', money_amount) 122 | else 123 | TriggerClientEvent('chatMessage', _source, "SYSTEM", {255, 0, 0}, "^2" .. money_type .. " ^0 is not a valid money type!") 124 | return 125 | end 126 | else 127 | TriggerClientEvent('chatMessage', _source, "SYSTEM", {255, 0, 0}, "Invalid arguments.") 128 | return 129 | end 130 | 131 | print('es_extended: ' .. GetPlayerName(source) .. ' just set $' .. money_amount .. ' (' .. money_type .. ') to ' .. xPlayer.name) 132 | 133 | if xPlayer.source ~= _source then 134 | TriggerClientEvent('esx:showNotification', xPlayer.source, _U('money_set', money_amount, money_type)) 135 | end 136 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(_source), '/setmoney', xPlayer.getName() .. " " .. args[2] .. " " .. args[3]) 137 | end, function(source, args, user) 138 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 139 | end, {help = _U('setmoney'), params = {{name = "id", help = _U('id_param')}, {name = "money type", help = _U('money_type')}, {name = "amount", help = _U('money_amount')}}}) 140 | 141 | TriggerEvent('es:addGroupCommand', 'giveaccountmoney', 'superadmin', function(source, args, user) 142 | local _source = source 143 | local xPlayer = ESX.GetPlayerFromId(args[1]) 144 | local account = args[2] 145 | local amount = tonumber(args[3]) 146 | 147 | if amount ~= nil then 148 | if xPlayer.getAccount(account) ~= nil then 149 | xPlayer.addAccountMoney(account, amount) 150 | exports['JD_logs']:discord(GetPlayerName(xPlayer.source)..' gaf aan: '..GetPlayerName(args.playerId).." **"..ESX.Math.GroupDigits(args.amount)..' '..args.account..'**', xPlayer.source, args.playerId, '#000000', 'givemoney') 151 | else 152 | TriggerClientEvent('esx:showNotification', _source, _U('invalid_account')) 153 | end 154 | else 155 | TriggerClientEvent('esx:showNotification', _source, _U('amount_invalid')) 156 | end 157 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(_source), '/giveaccountmoney', xPlayer.getName() .. " " .. args[2] .. " " .. args[3]) 158 | end, function(source, args, user) 159 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 160 | end, {help = _U('giveaccountmoney'), params = {{name = "id", help = _U('id_param')}, {name = "account", help = _U('account')}, {name = "amount", help = _U('money_amount')}}}) 161 | 162 | TriggerEvent('es:addGroupCommand', 'giveitem', 'superadmin', function(source, args, user) 163 | local _source = source 164 | local xPlayer = ESX.GetPlayerFromId(args[1]) 165 | local item = args[2] 166 | local count = (args[3] == nil and 1 or tonumber(args[3])) 167 | 168 | if count ~= nil then 169 | if xPlayer.getInventoryItem(item) ~= nil then 170 | xPlayer.addInventoryItem(item, count) 171 | else 172 | TriggerClientEvent('esx:showNotification', _source, _U('invalid_item')) 173 | end 174 | else 175 | TriggerClientEvent('esx:showNotification', _source, _U('invalid_amount')) 176 | end 177 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(_source), '/giveitem', xPlayer.getName() .. " " .. args[2] .. " " .. count) 178 | end, function(source, args, user) 179 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 180 | end, {help = _U('giveitem'), params = {{name = "id", help = _U('id_param')}, {name = "item", help = _U('item')}, {name = "amount", help = _U('amount')}}}) 181 | 182 | TriggerEvent('es:addGroupCommand', 'giveweapon', 'superadmin', function(source, args, user) 183 | local xPlayer = ESX.GetPlayerFromId(args[1]) 184 | local weaponName = string.upper(args[2]) 185 | 186 | xPlayer.addWeapon(weaponName, tonumber(args[3])) 187 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/giveweapon', xPlayer.getName() .. " " .. args[2] .. " " .. args[3]) 188 | end, function(source, args, user) 189 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 190 | end, {help = _U('giveweapon'), params = {{name = "id", help = _U('id_param')}, {name = "weapon", help = _U('weapon')}, {name = "ammo", help = _U('amountammo')}}}) 191 | 192 | TriggerEvent('es:addGroupCommand', 'disc', 'admin', function(source, args, user) 193 | DropPlayer(source, 'You have been disconnected') 194 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/disc', " ") 195 | end, function(source, args, user) 196 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 197 | end) 198 | 199 | TriggerEvent('es:addGroupCommand', 'disconnect', 'admin', function(source, args, user) 200 | DropPlayer(source, 'You have been disconnected') 201 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/disconnect', " ") 202 | end, function(source, args, user) 203 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 204 | end, {help = _U('disconnect')}) 205 | 206 | TriggerEvent('es:addGroupCommand', 'clear', 'user', function(source, args, user) 207 | TriggerClientEvent('chat:clear', source) 208 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/clear', " ") 209 | end, function(source, args, user) 210 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 211 | end, {help = _U('chat_clear')}) 212 | 213 | TriggerEvent('es:addGroupCommand', 'cls', 'user', function(source, args, user) 214 | TriggerClientEvent('chat:clear', source) 215 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/cls', " ") 216 | end, function(source, args, user) 217 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 218 | end) 219 | 220 | TriggerEvent('es:addGroupCommand', 'clsall', 'admin', function(source, args, user) 221 | TriggerClientEvent('chat:clear', -1) 222 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/clsall', " ") 223 | end, function(source, args, user) 224 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 225 | end) 226 | 227 | TriggerEvent('es:addGroupCommand', 'clearall', 'admin', function(source, args, user) 228 | TriggerClientEvent('chat:clear', -1) 229 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/clearall', " ") 230 | end, function(source, args, user) 231 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 232 | end, {help = _U('chat_clear_all')}) 233 | 234 | TriggerEvent('es:addGroupCommand', 'clearinventory', 'superadmin', function(source, args, user) 235 | local xPlayer 236 | 237 | if args[1] then 238 | xPlayer = ESX.GetPlayerFromId(args[1]) 239 | else 240 | xPlayer = ESX.GetPlayerFromId(source) 241 | end 242 | 243 | if not xPlayer then 244 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Player not online.' } }) 245 | return 246 | end 247 | 248 | for i=1, #xPlayer.inventory, 1 do 249 | if xPlayer.inventory[i].count > 0 then 250 | xPlayer.setInventoryItem(xPlayer.inventory[i].name, 0) 251 | end 252 | end 253 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/clearinventory', xPlayer.getName()) 254 | end, function(source, args, user) 255 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 256 | end, {help = _U('command_clearinventory'), params = {{name = "playerId", help = _U('command_playerid_param')}}}) 257 | 258 | TriggerEvent('es:addGroupCommand', 'clearloadout', 'superadmin', function(source, args, user) 259 | local xPlayer 260 | 261 | if args[1] then 262 | xPlayer = ESX.GetPlayerFromId(args[1]) 263 | else 264 | xPlayer = ESX.GetPlayerFromId(source) 265 | end 266 | 267 | if not xPlayer then 268 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Player not online.' } }) 269 | return 270 | end 271 | 272 | for i=#xPlayer.loadout, 1, -1 do 273 | xPlayer.removeWeapon(xPlayer.loadout[i].name) 274 | end 275 | TriggerEvent('7DiscordLog:CommandLog', ESX.GetPlayerFromId(source), '/clearloadout', xPlayer.getName()) 276 | end, function(source, args, user) 277 | TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) 278 | end, {help = _U('command_clearloadout'), params = {{name = "playerId", help = _U('command_playerid_param')}}}) 279 | -------------------------------------------------------------------------------- /es_extended/ESX_1.1/player.lua: -------------------------------------------------------------------------------- 1 | function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, lastPosition) 2 | local self = {} 3 | 4 | self.player = player 5 | self.accounts = accounts 6 | self.inventory = inventory 7 | self.job = job 8 | self.loadout = loadout 9 | self.name = name 10 | self.lastPosition = lastPosition 11 | 12 | self.source = self.player.get('source') 13 | self.identifier = self.player.get('identifier') 14 | 15 | self.setMoney = function(money) 16 | money = ESX.Math.Round(money) 17 | 18 | if money >= 0 then 19 | self.player.setMoney(money) 20 | else 21 | print(('es_extended: %s attempted exploiting! (reason: player tried setting -1 cash balance)'):format(self.identifier)) 22 | end 23 | end 24 | 25 | self.getMoney = function() 26 | return self.player.get('money') 27 | end 28 | 29 | self.setBankBalance = function(money) 30 | money = ESX.Math.Round(money) 31 | 32 | if money >= 0 then 33 | self.player.setBankBalance(money) 34 | else 35 | print(('es_extended: %s attempted exploiting! (reason: player tried setting -1 bank balance)'):format(self.identifier)) 36 | end 37 | end 38 | 39 | self.getBank = function() 40 | return self.player.get('bank') 41 | end 42 | 43 | self.getCoords = function() 44 | return self.player.get('coords') 45 | end 46 | 47 | self.setCoords = function(x, y, z) 48 | self.player.coords = {x = x, y = y, z = z} 49 | end 50 | 51 | self.kick = function(reason) 52 | self.player.kick(reason) 53 | end 54 | 55 | self.addMoney = function(money) 56 | money = ESX.Math.Round(money) 57 | 58 | if money >= 0 then 59 | self.player.addMoney(money) 60 | else 61 | print(('es_extended: %s attempted exploiting! (reason: player tried adding -1 cash balance)'):format(self.identifier)) 62 | end 63 | end 64 | 65 | self.removeMoney = function(money) 66 | money = ESX.Math.Round(money) 67 | 68 | if money >= 0 then 69 | self.player.removeMoney(money) 70 | else 71 | print(('es_extended: %s attempted exploiting! (reason: player tried removing -1 cash balance)'):format(self.identifier)) 72 | end 73 | end 74 | 75 | self.addBank = function(money) 76 | money = ESX.Math.Round(money) 77 | 78 | if money >= 0 then 79 | self.player.addBank(money) 80 | else 81 | print(('es_extended: %s attempted exploiting! (reason: player tried adding -1 bank balance)'):format(self.identifier)) 82 | end 83 | end 84 | 85 | self.removeBank = function(money) 86 | money = ESX.Math.Round(money) 87 | 88 | if money >= 0 then 89 | self.player.removeBank(money) 90 | else 91 | print(('es_extended: %s attempted exploiting! (reason: player tried removing -1 bank balance)'):format(self.identifier)) 92 | end 93 | end 94 | 95 | self.displayMoney = function(money) 96 | self.player.displayMoney(money) 97 | end 98 | 99 | self.displayBank = function(money) 100 | self.player.displayBank(money) 101 | end 102 | 103 | self.setSessionVar = function(key, value) 104 | self.player.setSessionVar(key, value) 105 | end 106 | 107 | self.getSessionVar = function(k) 108 | return self.player.getSessionVar(k) 109 | end 110 | 111 | self.getPermissions = function() 112 | return self.player.getPermissions() 113 | end 114 | 115 | self.setPermissions = function(p) 116 | self.player.setPermissions(p) 117 | end 118 | 119 | self.getIdentifier = function() 120 | return self.player.getIdentifier() 121 | end 122 | 123 | self.getGroup = function() 124 | return self.player.getGroup() 125 | end 126 | 127 | self.set = function(k, v) 128 | self.player.set(k, v) 129 | end 130 | 131 | self.get = function(k) 132 | return self.player.get(k) 133 | end 134 | 135 | self.getPlayer = function() 136 | return self.player 137 | end 138 | 139 | self.getAccounts = function() 140 | local accounts = {} 141 | 142 | for i=1, #Config.Accounts, 1 do 143 | if Config.Accounts[i] == 'bank' then 144 | 145 | table.insert(accounts, { 146 | name = 'bank', 147 | money = self.get('bank'), 148 | label = Config.AccountLabels['bank'] 149 | }) 150 | 151 | else 152 | 153 | for j=1, #self.accounts, 1 do 154 | if self.accounts[j].name == Config.Accounts[i] then 155 | table.insert(accounts, self.accounts[j]) 156 | end 157 | end 158 | 159 | end 160 | end 161 | 162 | return accounts 163 | end 164 | 165 | self.getAccount = function(a) 166 | if a == 'bank' then 167 | return { 168 | name = 'bank', 169 | money = self.get('bank'), 170 | label = Config.AccountLabels['bank'] 171 | } 172 | end 173 | 174 | for i=1, #self.accounts, 1 do 175 | if self.accounts[i].name == a then 176 | return self.accounts[i] 177 | end 178 | end 179 | end 180 | 181 | self.getInventory = function() 182 | return self.inventory 183 | end 184 | 185 | self.getJob = function() 186 | return self.job 187 | end 188 | 189 | 190 | self.getLoadout = function() 191 | return self.loadout 192 | end 193 | 194 | self.getName = function() 195 | return self.name 196 | end 197 | 198 | self.setName = function(newName) 199 | self.name = newName 200 | end 201 | 202 | self.getLastPosition = function() 203 | if self.lastPosition and self.lastPosition.x and self.lastPosition.y and self.lastPosition.z then 204 | self.lastPosition.x = ESX.Math.Round(self.lastPosition.x, 1) 205 | self.lastPosition.y = ESX.Math.Round(self.lastPosition.y, 1) 206 | self.lastPosition.z = ESX.Math.Round(self.lastPosition.z, 1) 207 | end 208 | 209 | return self.lastPosition 210 | end 211 | 212 | self.setLastPosition = function(position) 213 | self.lastPosition = position 214 | end 215 | 216 | self.getMissingAccounts = function(cb) 217 | MySQL.Async.fetchAll('SELECT * FROM `user_accounts` WHERE `identifier` = @identifier', { 218 | ['@identifier'] = self.getIdentifier() 219 | }, function(result) 220 | local missingAccounts = {} 221 | 222 | for i=1, #Config.Accounts, 1 do 223 | if Config.Accounts[i] ~= 'bank' then 224 | local found = false 225 | 226 | for j=1, #result, 1 do 227 | if Config.Accounts[i] == result[j].name then 228 | found = true 229 | break 230 | end 231 | end 232 | 233 | if not found then 234 | table.insert(missingAccounts, Config.Accounts[i]) 235 | end 236 | end 237 | end 238 | 239 | cb(missingAccounts) 240 | end) 241 | end 242 | 243 | self.createAccounts = function(missingAccounts, cb) 244 | for i=1, #missingAccounts, 1 do 245 | MySQL.Async.execute('INSERT INTO `user_accounts` (identifier, name) VALUES (@identifier, @name)', { 246 | ['@identifier'] = self.getIdentifier(), 247 | ['@name'] = missingAccounts[i] 248 | }, function(rowsChanged) 249 | if cb ~= nil then 250 | cb() 251 | end 252 | end) 253 | end 254 | end 255 | 256 | self.setAccountMoney = function(acc, money) 257 | if money < 0 then 258 | print(('es_extended: %s attempted exploiting! (reason: player tried setting -1 account balance)'):format(self.identifier)) 259 | return 260 | end 261 | 262 | local account = self.getAccount(acc) 263 | local prevMoney = account.money 264 | local newMoney = ESX.Math.Round(money) 265 | 266 | account.money = newMoney 267 | 268 | if acc == 'bank' then 269 | self.set('bank', newMoney) 270 | end 271 | 272 | TriggerClientEvent('esx:setAccountMoney', self.source, account) 273 | TriggerEvent('7DiscordLog:MoneyLog', self, 'Set', acc, money) 274 | end 275 | 276 | self.addAccountMoney = function(acc, money) 277 | if money < 0 then 278 | print(('es_extended: %s attempted exploiting! (reason: player tried adding -1 account balance)'):format(self.identifier)) 279 | return 280 | end 281 | 282 | local account = self.getAccount(acc) 283 | local newMoney = account.money + ESX.Math.Round(money) 284 | 285 | account.money = newMoney 286 | 287 | if acc == 'bank' then 288 | self.set('bank', newMoney) 289 | end 290 | 291 | TriggerClientEvent('esx:setAccountMoney', self.source, account) 292 | TriggerEvent('7DiscordLog:MoneyLog', self, 'Add', acc, money) 293 | end 294 | 295 | self.removeAccountMoney = function(a, m) 296 | if m < 0 then 297 | print(('es_extended: %s attempted exploiting! (reason: player tried removing -1 account balance)'):format(self.identifier)) 298 | return 299 | end 300 | 301 | local account = self.getAccount(a) 302 | local newMoney = account.money - m 303 | 304 | account.money = newMoney 305 | 306 | if a == 'bank' then 307 | self.set('bank', newMoney) 308 | end 309 | 310 | TriggerClientEvent('esx:setAccountMoney', self.source, account) 311 | TriggerEvent('7DiscordLog:MoneyLog', self, 'Remove', a, m) 312 | end 313 | 314 | self.getInventoryItem = function(name) 315 | for i=1, #self.inventory, 1 do 316 | if self.inventory[i].name == name then 317 | return self.inventory[i] 318 | end 319 | end 320 | end 321 | 322 | self.addInventoryItem = function(name, count) 323 | local item = self.getInventoryItem(name) 324 | local newCount = item.count + count 325 | item.count = newCount 326 | 327 | TriggerEvent('esx:onAddInventoryItem', self.source, item, count) 328 | TriggerClientEvent('esx:addInventoryItem', self.source, item, count) 329 | TriggerEvent('7DiscordLog:ItemsLog', self, 'Add', item.name, count) 330 | end 331 | 332 | self.removeInventoryItem = function(name, count) 333 | local item = self.getInventoryItem(name) 334 | local newCount = item.count - count 335 | item.count = newCount 336 | 337 | TriggerEvent('esx:onRemoveInventoryItem', self.source, item, count) 338 | TriggerClientEvent('esx:removeInventoryItem', self.source, item, count) 339 | TriggerEvent('7DiscordLog:ItemsLog', self, 'Remove', item.name, count) 340 | end 341 | 342 | self.setInventoryItem = function(name, count) 343 | local item = self.getInventoryItem(name) 344 | local oldCount = item.count 345 | item.count = count 346 | 347 | if oldCount > item.count then 348 | TriggerEvent('esx:onRemoveInventoryItem', self.source, item, oldCount - item.count) 349 | TriggerClientEvent('esx:removeInventoryItem', self.source, item, oldCount - item.count) 350 | else 351 | TriggerEvent('esx:onAddInventoryItem', self.source, item, item.count - oldCount) 352 | TriggerClientEvent('esx:addInventoryItem', self.source, item, item.count - oldCount) 353 | end 354 | end 355 | 356 | self.setJob = function(job, grade) 357 | grade = tostring(grade) 358 | local lastJob = json.decode(json.encode(self.job)) 359 | 360 | if ESX.DoesJobExist(job, grade) then 361 | local jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade] 362 | 363 | self.job.id = jobObject.id 364 | self.job.name = jobObject.name 365 | self.job.label = jobObject.label 366 | 367 | self.job.grade = tonumber(grade) 368 | self.job.grade_name = gradeObject.name 369 | self.job.grade_label = gradeObject.label 370 | self.job.grade_salary = gradeObject.salary 371 | 372 | self.job.skin_male = {} 373 | self.job.skin_female = {} 374 | 375 | if gradeObject.skin_male ~= nil then 376 | self.job.skin_male = json.decode(gradeObject.skin_male) 377 | end 378 | 379 | if gradeObject.skin_female ~= nil then 380 | self.job.skin_female = json.decode(gradeObject.skin_female) 381 | end 382 | 383 | TriggerEvent('esx:setJob', self.source, self.job, lastJob) 384 | TriggerClientEvent('esx:setJob', self.source, self.job) 385 | else 386 | print(('es_extended: ignoring setJob for %s due to job not found!'):format(self.source)) 387 | end 388 | end 389 | 390 | 391 | self.addWeapon = function(weaponName, ammo) 392 | local weaponLabel = ESX.GetWeaponLabel(weaponName) 393 | 394 | if not self.hasWeapon(weaponName) then 395 | table.insert(self.loadout, { 396 | name = weaponName, 397 | ammo = ammo, 398 | label = weaponLabel, 399 | components = {} 400 | }) 401 | end 402 | 403 | TriggerClientEvent('esx:addWeapon', self.source, weaponName, ammo) 404 | TriggerClientEvent('esx:addInventoryItem', self.source, {label = weaponLabel}, 1) 405 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Add', 'weapon', weaponName, ammo) 406 | end 407 | 408 | self.addWeaponComponent = function(weaponName, weaponComponent) 409 | local loadoutNum, weapon = self.getWeapon(weaponName) 410 | 411 | if self.hasWeaponComponent(weaponName, weaponComponent) then 412 | return 413 | end 414 | 415 | table.insert(self.loadout[loadoutNum].components, weaponComponent) 416 | 417 | TriggerClientEvent('esx:addWeaponComponent', self.source, weaponName, weaponComponent) 418 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Add', 'component', weaponName, weaponComponent) 419 | end 420 | 421 | self.removeWeapon = function(weaponName, ammo) 422 | local weaponLabel 423 | 424 | for i=1, #self.loadout, 1 do 425 | if self.loadout[i].name == weaponName then 426 | weaponLabel = self.loadout[i].label 427 | 428 | for j=1, #self.loadout[i].components, 1 do 429 | TriggerClientEvent('esx:removeWeaponComponent', self.source, weaponName, self.loadout[i].components[j]) 430 | end 431 | 432 | table.remove(self.loadout, i) 433 | break 434 | end 435 | end 436 | 437 | if weaponLabel then 438 | TriggerClientEvent('esx:removeWeapon', self.source, weaponName, ammo) 439 | TriggerClientEvent('esx:removeInventoryItem', self.source, {label = weaponLabel}, 1) 440 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Remove', 'weapon', weaponName, ammo) 441 | end 442 | end 443 | 444 | self.removeWeaponComponent = function(weaponName, weaponComponent) 445 | local loadoutNum, weapon = self.getWeapon(weaponName) 446 | 447 | if not weapon then 448 | return 449 | end 450 | 451 | for i=1, #self.loadout[loadoutNum].components, 1 do 452 | if self.loadout[loadoutNum].components.name == weaponComponent then 453 | table.remove(self.loadout[loadoutNum].components, i) 454 | break 455 | end 456 | end 457 | 458 | TriggerClientEvent('esx:removeWeaponComponent', self.source, weaponName, weaponComponent) 459 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Remove', 'component', weaponName, weaponComponent) 460 | end 461 | 462 | self.hasWeaponComponent = function(weaponName, weaponComponent) 463 | local loadoutNum, weapon = self.getWeapon(weaponName) 464 | 465 | if not weapon then 466 | return false 467 | end 468 | 469 | for i=1, #weapon.components, 1 do 470 | if weapon.components[i] == weaponComponent then 471 | return true 472 | end 473 | end 474 | 475 | return false 476 | end 477 | 478 | self.hasWeapon = function(weaponName) 479 | for i=1, #self.loadout, 1 do 480 | if self.loadout[i].name == weaponName then 481 | return true 482 | end 483 | end 484 | 485 | return false 486 | end 487 | 488 | self.getWeapon = function(weaponName) 489 | for i=1, #self.loadout, 1 do 490 | if self.loadout[i].name == weaponName then 491 | return i, self.loadout[i] 492 | end 493 | end 494 | 495 | return nil 496 | end 497 | 498 | return self 499 | end 500 | -------------------------------------------------------------------------------- /es_extended/ESX_1.2/commands.lua: -------------------------------------------------------------------------------- 1 | ESX.RegisterCommand('setcoords', 'admin', function(xPlayer, args, showError) 2 | xPlayer.setCoords({x = args.x, y = args.y, z = args.z}) 3 | end, false, {help = _U('command_setcoords'), validate = true, arguments = { 4 | {name = 'x', help = _U('command_setcoords_x'), type = 'number'}, 5 | {name = 'y', help = _U('command_setcoords_y'), type = 'number'}, 6 | {name = 'z', help = _U('command_setcoords_z'), type = 'number'} 7 | }}) 8 | 9 | ESX.RegisterCommand('setjob', 'admin', function(xPlayer, args, showError) 10 | if ESX.DoesJobExist(args.job, args.grade) then 11 | args.playerId.setJob(args.job, args.grade) 12 | else 13 | showError(_U('command_setjob_invalid')) 14 | end 15 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/setjob', args.playerId.getName() .. " " .. args.job .. " " .. args.grade) 16 | end, true, {help = _U('command_setjob'), validate = true, arguments = { 17 | {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}, 18 | {name = 'job', help = _U('command_setjob_job'), type = 'string'}, 19 | {name = 'grade', help = _U('command_setjob_grade'), type = 'number'} 20 | }}) 21 | 22 | ESX.RegisterCommand('car', 'admin', function(xPlayer, args, showError) 23 | xPlayer.triggerEvent('esx:spawnVehicle', args.car) 24 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/car', args.car) 25 | end, false, {help = _U('command_car'), validate = false, arguments = { 26 | {name = 'car', help = _U('command_car_car'), type = 'any'} 27 | }}) 28 | 29 | ESX.RegisterCommand({'cardel', 'dv'}, 'admin', function(xPlayer, args, showError) 30 | xPlayer.triggerEvent('esx:deleteVehicle', args.radius) 31 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/cardel', "") 32 | end, false, {help = _U('command_cardel'), validate = false, arguments = { 33 | {name = 'radius', help = _U('command_cardel_radius'), type = 'any'} 34 | }}) 35 | 36 | ESX.RegisterCommand('setaccountmoney', 'admin', function(xPlayer, args, showError) 37 | if args.playerId.getAccount(args.account) then 38 | args.playerId.setAccountMoney(args.account, args.amount) 39 | else 40 | showError(_U('command_giveaccountmoney_invalid')) 41 | end 42 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/setaccountmoney', args.playerId.getName() .. " " .. args.account .. " " .. args.amount) 43 | end, true, {help = _U('command_setaccountmoney'), validate = true, arguments = { 44 | {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}, 45 | {name = 'account', help = _U('command_giveaccountmoney_account'), type = 'string'}, 46 | {name = 'amount', help = _U('command_setaccountmoney_amount'), type = 'number'} 47 | }}) 48 | 49 | ESX.RegisterCommand('giveaccountmoney', 'admin', function(xPlayer, args, showError) 50 | if args.playerId.getAccount(args.account) then 51 | args.playerId.addAccountMoney(args.account, args.amount) 52 | else 53 | showError(_U('command_giveaccountmoney_invalid')) 54 | end 55 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/giveaccountmoney', args.playerId.getName() .. " " .. args.account .. " " .. args.amount) 56 | end, true, {help = _U('command_giveaccountmoney'), validate = true, arguments = { 57 | {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}, 58 | {name = 'account', help = _U('command_giveaccountmoney_account'), type = 'string'}, 59 | {name = 'amount', help = _U('command_giveaccountmoney_amount'), type = 'number'} 60 | }}) 61 | 62 | ESX.RegisterCommand('giveitem', 'admin', function(xPlayer, args, showError) 63 | args.playerId.addInventoryItem(args.item, args.count) 64 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/giveitem', args.playerId.getName() .. " " .. args.item .. " " .. args.count) 65 | end, true, {help = _U('command_giveitem'), validate = true, arguments = { 66 | {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}, 67 | {name = 'item', help = _U('command_giveitem_item'), type = 'item'}, 68 | {name = 'count', help = _U('command_giveitem_count'), type = 'number'} 69 | }}) 70 | 71 | ESX.RegisterCommand('giveweapon', 'admin', function(xPlayer, args, showError) 72 | if args.playerId.hasWeapon(args.weapon) then 73 | showError(_U('command_giveweapon_hasalready')) 74 | else 75 | xPlayer.addWeapon(args.weapon, args.ammo) 76 | end 77 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/giveweapon', args.playerId.getName() .. " " .. args.weapon .. " " .. args.ammo) 78 | end, true, {help = _U('command_giveweapon'), validate = true, arguments = { 79 | {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}, 80 | {name = 'weapon', help = _U('command_giveweapon_weapon'), type = 'weapon'}, 81 | {name = 'ammo', help = _U('command_giveweapon_ammo'), type = 'number'} 82 | }}) 83 | 84 | ESX.RegisterCommand('giveweaponcomponent', 'admin', function(xPlayer, args, showError) 85 | if args.playerId.hasWeapon(args.weaponName) then 86 | local component = ESX.GetWeaponComponent(args.weaponName, args.componentName) 87 | 88 | if component then 89 | if xPlayer.hasWeaponComponent(args.weaponName, args.componentName) then 90 | showError(_U('command_giveweaponcomponent_hasalready')) 91 | else 92 | xPlayer.addWeaponComponent(args.weaponName, args.componentName) 93 | end 94 | else 95 | showError(_U('command_giveweaponcomponent_invalid')) 96 | end 97 | else 98 | showError(_U('command_giveweaponcomponent_missingweapon')) 99 | end 100 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/giveweaponcomponent', args.playerId.getName() .. " " .. args.weaponName .. " " .. args.componentName) 101 | end, true, {help = _U('command_giveweaponcomponent'), validate = true, arguments = { 102 | {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}, 103 | {name = 'weaponName', help = _U('command_giveweapon_weapon'), type = 'weapon'}, 104 | {name = 'componentName', help = _U('command_giveweaponcomponent_component'), type = 'string'} 105 | }}) 106 | 107 | ESX.RegisterCommand({'clear', 'cls'}, 'user', function(xPlayer, args, showError) 108 | xPlayer.triggerEvent('chat:clear') 109 | end, false, {help = _U('command_clear')}) 110 | 111 | ESX.RegisterCommand({'clearall', 'clsall'}, 'admin', function(xPlayer, args, showError) 112 | TriggerClientEvent('chat:clear', -1) 113 | end, false, {help = _U('command_clearall')}) 114 | 115 | ESX.RegisterCommand('clearinventory', 'admin', function(xPlayer, args, showError) 116 | for k,v in ipairs(args.playerId.inventory) do 117 | if v.count > 0 then 118 | args.playerId.setInventoryItem(v.name, 0) 119 | end 120 | end 121 | end, true, {help = _U('command_clearinventory'), validate = true, arguments = { 122 | {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'} 123 | }}) 124 | 125 | ESX.RegisterCommand('clearloadout', 'admin', function(xPlayer, args, showError) 126 | for k,v in ipairs(args.playerId.loadout) do 127 | args.playerId.removeWeapon(v.name) 128 | end 129 | end, true, {help = _U('command_clearloadout'), validate = true, arguments = { 130 | {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'} 131 | }}) 132 | 133 | ESX.RegisterCommand('setgroup', 'admin', function(xPlayer, args, showError) 134 | args.playerId.setGroup(args.group) 135 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/setgroup', args.playerId.getName() .. " " .. args.group) 136 | end, true, {help = _U('command_setgroup'), validate = true, arguments = { 137 | {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'}, 138 | {name = 'group', help = _U('command_setgroup_group'), type = 'string'}, 139 | }}) 140 | 141 | ESX.RegisterCommand('save', 'admin', function(xPlayer, args, showError) 142 | ESX.SavePlayer(args.playerId) 143 | end, true, {help = _U('command_save'), validate = true, arguments = { 144 | {name = 'playerId', help = _U('commandgeneric_playerid'), type = 'player'} 145 | }}) 146 | 147 | ESX.RegisterCommand('saveall', 'admin', function(xPlayer, args, showError) 148 | ESX.SavePlayers() 149 | end, true, {help = _U('command_saveall')}) 150 | -------------------------------------------------------------------------------- /es_extended/ESX_1.2/player.lua: -------------------------------------------------------------------------------- 1 | function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory, weight, job, loadout, name, coords) 2 | local self = {} 3 | 4 | self.accounts = accounts 5 | self.coords = coords 6 | self.group = group 7 | self.identifier = identifier 8 | self.inventory = inventory 9 | self.job = job 10 | self.loadout = loadout 11 | self.name = name 12 | self.playerId = playerId 13 | self.source = playerId 14 | self.variables = {} 15 | self.weight = weight 16 | self.maxWeight = Config.MaxWeight 17 | 18 | ExecuteCommand(('add_principal identifier.license:%s group.%s'):format(self.identifier, self.group)) 19 | 20 | self.triggerEvent = function(eventName, ...) 21 | TriggerClientEvent(eventName, self.source, ...) 22 | end 23 | 24 | self.setCoords = function(coords) 25 | self.updateCoords(coords) 26 | self.triggerEvent('esx:teleport', coords) 27 | end 28 | 29 | self.updateCoords = function(coords) 30 | self.coords = {x = ESX.Math.Round(coords.x, 1), y = ESX.Math.Round(coords.y, 1), z = ESX.Math.Round(coords.z, 1), heading = ESX.Math.Round(coords.heading or 0.0, 1)} 31 | end 32 | 33 | self.getCoords = function(vector) 34 | if vector then 35 | return vector3(self.coords.x, self.coords.y, self.coords.z) 36 | else 37 | return self.coords 38 | end 39 | end 40 | 41 | self.kick = function(reason) 42 | DropPlayer(self.source, reason) 43 | end 44 | 45 | self.setMoney = function(money) 46 | money = ESX.Math.Round(money) 47 | self.setAccountMoney('money', money) 48 | end 49 | 50 | self.getMoney = function() 51 | return self.getAccount('money').money 52 | end 53 | 54 | self.addMoney = function(money) 55 | money = ESX.Math.Round(money) 56 | self.addAccountMoney('money', money) 57 | end 58 | 59 | self.removeMoney = function(money) 60 | money = ESX.Math.Round(money) 61 | self.removeAccountMoney('money', money) 62 | end 63 | 64 | self.getIdentifier = function() 65 | return self.identifier 66 | end 67 | 68 | self.setGroup = function(newGroup) 69 | ExecuteCommand(('remove_principal identifier.license:%s group.%s'):format(self.identifier, self.group)) 70 | self.group = newGroup 71 | ExecuteCommand(('add_principal identifier.license:%s group.%s'):format(self.identifier, self.group)) 72 | end 73 | 74 | self.getGroup = function() 75 | return self.group 76 | end 77 | 78 | self.set = function(k, v) 79 | self.variables[k] = v 80 | end 81 | 82 | self.get = function(k) 83 | return self.variables[k] 84 | end 85 | 86 | self.getAccounts = function(minimal) 87 | if minimal then 88 | local minimalAccounts = {} 89 | 90 | for k,v in ipairs(self.accounts) do 91 | minimalAccounts[v.name] = v.money 92 | end 93 | 94 | return minimalAccounts 95 | else 96 | return self.accounts 97 | end 98 | end 99 | 100 | self.getAccount = function(account) 101 | for k,v in ipairs(self.accounts) do 102 | if v.name == account then 103 | return v 104 | end 105 | end 106 | end 107 | 108 | self.getInventory = function(minimal) 109 | if minimal then 110 | local minimalInventory = {} 111 | 112 | for k,v in ipairs(self.inventory) do 113 | if v.count > 0 then 114 | minimalInventory[v.name] = v.count 115 | end 116 | end 117 | 118 | return minimalInventory 119 | else 120 | return self.inventory 121 | end 122 | end 123 | 124 | self.getJob = function() 125 | return self.job 126 | end 127 | 128 | self.getLoadout = function(minimal) 129 | if minimal then 130 | local minimalLoadout = {} 131 | 132 | for k,v in ipairs(self.loadout) do 133 | minimalLoadout[v.name] = {ammo = v.ammo} 134 | if v.tintIndex > 0 then minimalLoadout[v.name].tintIndex = v.tintIndex end 135 | 136 | if #v.components > 0 then 137 | local components = {} 138 | 139 | for k2,component in ipairs(v.components) do 140 | if component ~= 'clip_default' then 141 | table.insert(components, component) 142 | end 143 | end 144 | 145 | if #components > 0 then 146 | minimalLoadout[v.name].components = components 147 | end 148 | end 149 | end 150 | 151 | return minimalLoadout 152 | else 153 | return self.loadout 154 | end 155 | end 156 | 157 | self.getName = function() 158 | return self.name 159 | end 160 | 161 | self.setName = function(newName) 162 | self.name = newName 163 | end 164 | 165 | self.setAccountMoney = function(accountName, money) 166 | if money >= 0 then 167 | local account = self.getAccount(accountName) 168 | 169 | if account then 170 | local prevMoney = account.money 171 | local newMoney = ESX.Math.Round(money) 172 | account.money = newMoney 173 | 174 | self.triggerEvent('esx:setAccountMoney', account) 175 | TriggerEvent('7DiscordLog:MoneyLog', self, 'Set', accountName, money) 176 | end 177 | end 178 | end 179 | 180 | self.addAccountMoney = function(accountName, money) 181 | if money > 0 then 182 | local account = self.getAccount(accountName) 183 | 184 | if account then 185 | local newMoney = account.money + ESX.Math.Round(money) 186 | account.money = newMoney 187 | 188 | self.triggerEvent('esx:setAccountMoney', account) 189 | TriggerEvent('7DiscordLog:MoneyLog', self, 'Add', accountName, money) 190 | end 191 | end 192 | end 193 | 194 | self.removeAccountMoney = function(accountName, money) 195 | if money > 0 then 196 | local account = self.getAccount(accountName) 197 | 198 | if account then 199 | local newMoney = account.money - ESX.Math.Round(money) 200 | account.money = newMoney 201 | 202 | self.triggerEvent('esx:setAccountMoney', account) 203 | TriggerEvent('7DiscordLog:MoneyLog', self, 'Remove', accountName, money) 204 | end 205 | end 206 | end 207 | 208 | self.getInventoryItem = function(name) 209 | for k,v in ipairs(self.inventory) do 210 | if v.name == name then 211 | return v 212 | end 213 | end 214 | 215 | return 216 | end 217 | 218 | self.addInventoryItem = function(name, count) 219 | local item = self.getInventoryItem(name) 220 | 221 | if item then 222 | count = ESX.Math.Round(count) 223 | item.count = item.count + count 224 | self.weight = self.weight + (item.weight * count) 225 | 226 | TriggerEvent('esx:onAddInventoryItem', self.source, item.name, item.count) 227 | self.triggerEvent('esx:addInventoryItem', item.name, item.count) 228 | TriggerEvent('7DiscordLog:ItemsLog', self, 'Add', item.name, count) 229 | end 230 | end 231 | 232 | self.removeInventoryItem = function(name, count) 233 | local item = self.getInventoryItem(name) 234 | 235 | if item then 236 | count = ESX.Math.Round(count) 237 | local newCount = item.count - count 238 | 239 | if newCount >= 0 then 240 | item.count = newCount 241 | self.weight = self.weight - (item.weight * count) 242 | 243 | TriggerEvent('esx:onRemoveInventoryItem', self.source, item.name, item.count) 244 | self.triggerEvent('esx:removeInventoryItem', item.name, item.count) 245 | TriggerEvent('7DiscordLog:ItemsLog', self, 'Remove', item.name, count) 246 | end 247 | end 248 | end 249 | 250 | self.setInventoryItem = function(name, count) 251 | local item = self.getInventoryItem(name) 252 | 253 | if item and count >= 0 then 254 | count = ESX.Math.Round(count) 255 | 256 | if count > item.count then 257 | self.addInventoryItem(item.name, count - item.count) 258 | else 259 | self.removeInventoryItem(item.name, item.count - count) 260 | end 261 | end 262 | end 263 | 264 | self.getWeight = function() 265 | return self.weight 266 | end 267 | 268 | self.getMaxWeight = function() 269 | return self.maxWeight 270 | end 271 | 272 | self.canCarryItem = function(name, count) 273 | local currentWeight, itemWeight = self.weight, ESX.Items[name].weight 274 | local newWeight = currentWeight + (itemWeight * count) 275 | 276 | return newWeight <= self.maxWeight 277 | end 278 | 279 | self.canSwapItem = function(firstItem, firstItemCount, testItem, testItemCount) 280 | local firstItemObject = self.getInventoryItem(firstItem) 281 | local testItemObject = self.getInventoryItem(testItem) 282 | 283 | if firstItemObject.count >= firstItemCount then 284 | local weightWithoutFirstItem = ESX.Math.Round(self.weight - (firstItemObject.weight * firstItemCount)) 285 | local weightWithTestItem = ESX.Math.Round(weightWithoutFirstItem + (testItemObject.weight * testItemCount)) 286 | 287 | return weightWithTestItem <= self.maxWeight 288 | end 289 | 290 | return false 291 | end 292 | 293 | self.setMaxWeight = function(newWeight) 294 | self.maxWeight = newWeight 295 | self.triggerEvent('esx:setMaxWeight', self.maxWeight) 296 | end 297 | 298 | self.setJob = function(job, grade) 299 | grade = tostring(grade) 300 | local lastJob = json.decode(json.encode(self.job)) 301 | 302 | if ESX.DoesJobExist(job, grade) then 303 | local jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade] 304 | 305 | self.job.id = jobObject.id 306 | self.job.name = jobObject.name 307 | self.job.label = jobObject.label 308 | 309 | self.job.grade = tonumber(grade) 310 | self.job.grade_name = gradeObject.name 311 | self.job.grade_label = gradeObject.label 312 | self.job.grade_salary = gradeObject.salary 313 | 314 | if gradeObject.skin_male then 315 | self.job.skin_male = json.decode(gradeObject.skin_male) 316 | else 317 | self.job.skin_male = {} 318 | end 319 | 320 | if gradeObject.skin_female then 321 | self.job.skin_female = json.decode(gradeObject.skin_female) 322 | else 323 | self.job.skin_female = {} 324 | end 325 | 326 | TriggerEvent('esx:setJob', self.source, self.job, lastJob) 327 | self.triggerEvent('esx:setJob', self.job) 328 | else 329 | print(('[es_extended] [^3WARNING^7] Ignoring invalid .setJob() usage for "%s"'):format(self.identifier)) 330 | end 331 | end 332 | 333 | self.addWeapon = function(weaponName, ammo) 334 | if not self.hasWeapon(weaponName) then 335 | local weaponLabel = ESX.GetWeaponLabel(weaponName) 336 | 337 | table.insert(self.loadout, { 338 | name = weaponName, 339 | ammo = ammo, 340 | label = weaponLabel, 341 | components = {}, 342 | tintIndex = 0 343 | }) 344 | 345 | self.triggerEvent('esx:addWeapon', weaponName, ammo) 346 | self.triggerEvent('esx:addInventoryItem', weaponLabel, false, true) 347 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Add', 'weapon', weaponName, ammo) 348 | end 349 | end 350 | 351 | self.addWeaponComponent = function(weaponName, weaponComponent) 352 | local loadoutNum, weapon = self.getWeapon(weaponName) 353 | 354 | if weapon then 355 | local component = ESX.GetWeaponComponent(weaponName, weaponComponent) 356 | 357 | if component then 358 | if not self.hasWeaponComponent(weaponName, weaponComponent) then 359 | table.insert(self.loadout[loadoutNum].components, weaponComponent) 360 | self.triggerEvent('esx:addWeaponComponent', weaponName, weaponComponent) 361 | self.triggerEvent('esx:addInventoryItem', component.label, false, true) 362 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Add', 'component', weaponName, weaponComponent) 363 | end 364 | end 365 | end 366 | end 367 | 368 | self.addWeaponAmmo = function(weaponName, ammoCount) 369 | local loadoutNum, weapon = self.getWeapon(weaponName) 370 | 371 | if weapon then 372 | weapon.ammo = weapon.ammo + ammoCount 373 | self.triggerEvent('esx:setWeaponAmmo', weaponName, weapon.ammo) 374 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Add', 'ammo', weaponName, ammoCount) 375 | end 376 | end 377 | 378 | self.updateWeaponAmmo = function(weaponName, ammoCount) 379 | local loadoutNum, weapon = self.getWeapon(weaponName) 380 | 381 | if weapon then 382 | if ammoCount < weapon.ammo then 383 | weapon.ammo = ammoCount 384 | end 385 | end 386 | end 387 | 388 | self.setWeaponTint = function(weaponName, weaponTintIndex) 389 | local loadoutNum, weapon = self.getWeapon(weaponName) 390 | 391 | if weapon then 392 | local weaponNum, weaponObject = ESX.GetWeapon(weaponName) 393 | 394 | if weaponObject.tints and weaponObject.tints[weaponTintIndex] then 395 | self.loadout[loadoutNum].tintIndex = weaponTintIndex 396 | self.triggerEvent('esx:setWeaponTint', weaponName, weaponTintIndex) 397 | self.triggerEvent('esx:addInventoryItem', weaponObject.tints[weaponTintIndex], false, true) 398 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Set', 'tint', weaponName, weaponTintIndex) 399 | end 400 | end 401 | end 402 | 403 | self.getWeaponTint = function(weaponName) 404 | local loadoutNum, weapon = self.getWeapon(weaponName) 405 | 406 | if weapon then 407 | return weapon.tintIndex 408 | end 409 | 410 | return 0 411 | end 412 | 413 | self.removeWeapon = function(weaponName) 414 | local weaponLabel 415 | 416 | for k,v in ipairs(self.loadout) do 417 | if v.name == weaponName then 418 | weaponLabel = v.label 419 | 420 | for k2,v2 in ipairs(v.components) do 421 | self.removeWeaponComponent(weaponName, v2) 422 | end 423 | 424 | table.remove(self.loadout, k) 425 | break 426 | end 427 | end 428 | 429 | if weaponLabel then 430 | self.triggerEvent('esx:removeWeapon', weaponName) 431 | self.triggerEvent('esx:removeInventoryItem', weaponLabel, false, true) 432 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Remove', 'weapon', weaponName, 0) 433 | end 434 | end 435 | 436 | self.removeWeaponComponent = function(weaponName, weaponComponent) 437 | local loadoutNum, weapon = self.getWeapon(weaponName) 438 | 439 | if weapon then 440 | local component = ESX.GetWeaponComponent(weaponName, weaponComponent) 441 | 442 | if component then 443 | if self.hasWeaponComponent(weaponName, weaponComponent) then 444 | for k,v in ipairs(self.loadout[loadoutNum].components) do 445 | if v == weaponComponent then 446 | table.remove(self.loadout[loadoutNum].components, k) 447 | break 448 | end 449 | end 450 | 451 | self.triggerEvent('esx:removeWeaponComponent', weaponName, weaponComponent) 452 | self.triggerEvent('esx:removeInventoryItem', component.label, false, true) 453 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Remove', 'component', weaponName, weaponComponent) 454 | end 455 | end 456 | end 457 | end 458 | 459 | self.removeWeaponAmmo = function(weaponName, ammoCount) 460 | local loadoutNum, weapon = self.getWeapon(weaponName) 461 | 462 | if weapon then 463 | weapon.ammo = weapon.ammo - ammoCount 464 | self.triggerEvent('esx:setWeaponAmmo', weaponName, weapon.ammo) 465 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Remove', 'ammo', weaponName, ammoCount) 466 | end 467 | end 468 | 469 | self.hasWeaponComponent = function(weaponName, weaponComponent) 470 | local loadoutNum, weapon = self.getWeapon(weaponName) 471 | 472 | if weapon then 473 | for k,v in ipairs(weapon.components) do 474 | if v == weaponComponent then 475 | return true 476 | end 477 | end 478 | 479 | return false 480 | else 481 | return false 482 | end 483 | end 484 | 485 | self.hasWeapon = function(weaponName) 486 | for k,v in ipairs(self.loadout) do 487 | if v.name == weaponName then 488 | return true 489 | end 490 | end 491 | 492 | return false 493 | end 494 | 495 | self.getWeapon = function(weaponName) 496 | for k,v in ipairs(self.loadout) do 497 | if v.name == weaponName then 498 | return k, v 499 | end 500 | end 501 | 502 | return 503 | end 504 | 505 | self.showNotification = function(msg) 506 | self.triggerEvent('esx:showNotification', msg) 507 | end 508 | 509 | self.showHelpNotification = function(msg, thisFrame, beep, duration) 510 | self.triggerEvent('esx:showHelpNotification', msg, thisFrame, beep, duration) 511 | end 512 | 513 | return self 514 | end 515 | -------------------------------------------------------------------------------- /es_extended/README.md: -------------------------------------------------------------------------------- 1 | # Topic-DiscordLogs: es_extended 2 | 3 | The following changes must be made in es_extended. 4 | 5 | If you are using **ESX 1.2** and you have not changed anything in *"server/commands.lua"*, you can use the file that is included in the download. 6 | 7 | Otherwise you have to maintain it on your own. 8 | 9 | ***TEMPLATE:*** 10 | ```lua 11 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/COMMAND', 'INFORMATION BEHIND COMMANDS') 12 | ``` 13 | 14 | 15 | **Command Log:** 16 | *"setjob":* 17 | ```lua 18 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/setjob', args.playerId.getName() .. " " .. args.job .. " " .. args.grade) 19 | ``` 20 | 21 | *"car":* 22 | ```lua 23 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/car', args.car) 24 | ``` 25 | 26 | *"cardel, dv":* 27 | ```lua 28 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/cardel', "") 29 | ``` 30 | 31 | *"setaccountmoney":* 32 | ```lua 33 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/setaccountmoney', args.playerId.getName() .. " " .. args.account .. " " .. args.amount) 34 | ``` 35 | 36 | *"giveaccountmoney":* 37 | ```lua 38 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/giveaccountmoney', args.playerId.getName() .. " " .. args.account .. " " .. args.amount) 39 | ``` 40 | 41 | *"giveitem":* 42 | ```lua 43 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/giveitem', args.playerId.getName() .. " " .. args.item .. " " .. args.count) 44 | ``` 45 | 46 | *"giveweapon":* 47 | ```lua 48 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/giveweapon', args.playerId.getName() .. " " .. args.weapon .. " " .. args.ammo) 49 | ``` 50 | 51 | *"giveweaponcomponent":* 52 | ```lua 53 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/giveweaponcomponent', args.playerId.getName() .. " " .. args.weaponName .. " " .. args.componentName) 54 | ``` 55 | 56 | *"setgroup":* 57 | ```lua 58 | TriggerEvent('7DiscordLog:CommandLog', xPlayer, '/setgroup', args.playerId.getName() .. " " .. args.group) 59 | ``` 60 | 61 | 62 | If you are using ESX 1.2 and you have not changed anything in *"server/classes/player.lua"*, you can use the file that is included in the download. 63 | 64 | Otherwise you have to maintain it on your own. 65 | 66 | ***TEMPLATE MONEY:*** 67 | ```lua 68 | TriggerEvent('7DiscordLog:MoneyLog', xPlayer, 'Add, Remove, Set', ACCOUNT_NAME, money) 69 | ``` 70 | 71 | ***TEMPLATE ITEM:*** 72 | ```lua 73 | TriggerEvent('7DiscordLog:ItemsLog', xPlayer, 'Add, Remove', 'ITEM_NAME', AMOUNT) 74 | ``` 75 | 76 | ***TEMPLATE WEAPON:*** 77 | ```lua 78 | TriggerEvent('7DiscordLog:WeaponLog', xPlayer, 'Add, Remove, Set', 'weapon, component, ammo, tint', weaponName, information) 79 | ``` 80 | 81 | 82 | **Money Log:** 83 | *"setAccountMoney":* 84 | ```lua 85 | TriggerEvent('7DiscordLog:MoneyLog', self, 'Set', accountName, money) 86 | ``` 87 | 88 | *"addAccountMoney":* 89 | ```lua 90 | TriggerEvent('7DiscordLog:MoneyLog', self, 'Add', accountName, money) 91 | ``` 92 | 93 | *"removeAccountMoney":* 94 | ```lua 95 | TriggerEvent('7DiscordLog:MoneyLog', self, 'Remove', accountName, money) 96 | ``` 97 | 98 | **Item Log:** 99 | *"addInventoryItem":* 100 | ```lua 101 | TriggerEvent('7DiscordLog:ItemsLog', self, 'Add', item.name, count) 102 | ``` 103 | 104 | *"removeInventoryItem":* 105 | ```lua 106 | TriggerEvent('7DiscordLog:ItemsLog', self, 'Remove', item.name, count) 107 | ``` 108 | 109 | **Weapon Log:** 110 | *"addWeapon":* 111 | ```lua 112 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Add', 'weapon', weaponName, ammo) 113 | ``` 114 | 115 | *"addWeaponComponent":* 116 | ```lua 117 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Add', 'component', weaponName, weaponComponent) 118 | ``` 119 | 120 | *"addWeaponAmmo":* 121 | ```lua 122 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Add', 'ammo', weaponName, ammoCount) 123 | ``` 124 | 125 | *"setWeaponTint":* 126 | ```lua 127 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Set', 'tint', weaponName, weaponTintIndex) 128 | ``` 129 | 130 | *"removeWeapon":* 131 | ```lua 132 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Remove', 'weapon', weaponName, 0) 133 | ``` 134 | 135 | *"removeWeaponComponent":* 136 | ```lua 137 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Remove', 'component', weaponName, weaponComponent) 138 | ``` 139 | 140 | *"removeWeaponAmmo":* 141 | ```lua 142 | TriggerEvent('7DiscordLog:WeaponLog', self, 'Remove', 'ammo', weaponName, ammoCount) 143 | ``` -------------------------------------------------------------------------------- /esx_ambulancejob/server/main.lua: -------------------------------------------------------------------------------- 1 | local playersHealing, deadPlayers = {}, {} 2 | 3 | if GetResourceState("esx_phone") ~= 'missing' then 4 | TriggerEvent('esx_phone:registerNumber', 'ambulance', _U('alert_ambulance'), true, true) 5 | end 6 | 7 | if GetResourceState("esx_society") ~= 'missing' then 8 | TriggerEvent('esx_society:registerSociety', 'ambulance', 'Ambulance', 'society_ambulance', 'society_ambulance', 'society_ambulance', {type = 'public'}) 9 | end 10 | 11 | RegisterNetEvent('esx_ambulancejob:revive') 12 | AddEventHandler('esx_ambulancejob:revive', function(playerId) 13 | playerId = tonumber(playerId) 14 | local xPlayer = source and ESX.GetPlayerFromId(source) 15 | 16 | if xPlayer and xPlayer.job.name == 'ambulance' then 17 | local xTarget = ESX.GetPlayerFromId(playerId) 18 | 19 | if xTarget then 20 | if deadPlayers[playerId] then 21 | if Config.ReviveReward > 0 then 22 | xPlayer.showNotification(_U('revive_complete_award', xTarget.name, Config.ReviveReward)) 23 | xPlayer.addMoney(Config.ReviveReward) 24 | xTarget.triggerEvent('esx_ambulancejob:revive') 25 | TriggerEvent('7DiscordLog:AmbulanceLog', xPlayer, 'Revive', xTarget, Config.ReviveReward) 26 | else 27 | xPlayer.showNotification(_U('revive_complete', xTarget.name)) 28 | xTarget.triggerEvent('esx_ambulancejob:revive') 29 | TriggerEvent('7DiscordLog:AmbulanceLog', xPlayer, 'Revive', xTarget) 30 | end 31 | else 32 | xPlayer.showNotification(_U('player_not_unconscious')) 33 | end 34 | else 35 | xPlayer.showNotification(_U('revive_fail_offline')) 36 | end 37 | end 38 | end) 39 | 40 | AddEventHandler('txAdmin:events:healedPlayer', function(eventData) 41 | if GetInvokingResource() ~= "monitor" or type(eventData) ~= "table" or type(eventData.id) ~= "number" then 42 | return 43 | end 44 | if deadPlayers[eventData.id] then 45 | TriggerClientEvent('esx_ambulancejob:revive', eventData.id) 46 | end 47 | end) 48 | 49 | RegisterNetEvent('esx:onPlayerDeath') 50 | AddEventHandler('esx:onPlayerDeath', function(data) 51 | deadPlayers[source] = 'dead' 52 | TriggerClientEvent('esx_ambulancejob:setDeadPlayers', -1, deadPlayers) 53 | end) 54 | 55 | RegisterServerEvent('esx_ambulancejob:svsearch') 56 | AddEventHandler('esx_ambulancejob:svsearch', function() 57 | TriggerClientEvent('esx_ambulancejob:clsearch', -1, source) 58 | end) 59 | 60 | RegisterNetEvent('esx_ambulancejob:onPlayerDistress') 61 | AddEventHandler('esx_ambulancejob:onPlayerDistress', function() 62 | if deadPlayers[source] then 63 | deadPlayers[source] = 'distress' 64 | TriggerClientEvent('esx_ambulancejob:setDeadPlayers', -1, deadPlayers) 65 | end 66 | end) 67 | 68 | RegisterNetEvent('esx:onPlayerSpawn') 69 | AddEventHandler('esx:onPlayerSpawn', function() 70 | if deadPlayers[source] then 71 | deadPlayers[source] = nil 72 | TriggerClientEvent('esx_ambulancejob:setDeadPlayers', -1, deadPlayers) 73 | end 74 | end) 75 | 76 | AddEventHandler('esx:playerDropped', function(playerId, reason) 77 | if deadPlayers[playerId] then 78 | deadPlayers[playerId] = nil 79 | TriggerClientEvent('esx_ambulancejob:setDeadPlayers', -1, deadPlayers) 80 | end 81 | end) 82 | 83 | RegisterNetEvent('esx_ambulancejob:heal') 84 | AddEventHandler('esx_ambulancejob:heal', function(target, type) 85 | local xPlayer = ESX.GetPlayerFromId(source) 86 | 87 | if xPlayer.job.name == 'ambulance' then 88 | TriggerClientEvent('esx_ambulancejob:heal', target, type) 89 | TriggerEvent('7DiscordLog:AmbulanceLog', xPlayer, 'Heal', xTarget) 90 | end 91 | end) 92 | 93 | RegisterNetEvent('esx_ambulancejob:putInVehicle') 94 | AddEventHandler('esx_ambulancejob:putInVehicle', function(target) 95 | local xPlayer = ESX.GetPlayerFromId(source) 96 | 97 | if xPlayer.job.name == 'ambulance' then 98 | TriggerClientEvent('esx_ambulancejob:putInVehicle', target) 99 | end 100 | end) 101 | 102 | ESX.RegisterServerCallback('esx_ambulancejob:removeItemsAfterRPDeath', function(source, cb) 103 | local xPlayer = ESX.GetPlayerFromId(source) 104 | 105 | if Config.OxInventory and Config.RemoveItemsAfterRPDeath then 106 | exports.ox_inventory:ClearInventory(xPlayer.source) 107 | return cb() 108 | end 109 | 110 | if Config.RemoveCashAfterRPDeath then 111 | if xPlayer.getMoney() > 0 then 112 | xPlayer.removeMoney(xPlayer.getMoney()) 113 | end 114 | 115 | if xPlayer.getAccount('black_money').money > 0 then 116 | xPlayer.setAccountMoney('black_money', 0) 117 | end 118 | end 119 | 120 | if Config.RemoveItemsAfterRPDeath then 121 | for i=1, #xPlayer.inventory, 1 do 122 | if xPlayer.inventory[i].count > 0 then 123 | xPlayer.setInventoryItem(xPlayer.inventory[i].name, 0) 124 | end 125 | end 126 | end 127 | 128 | if Config.OxInventory then return cb() end 129 | 130 | local playerLoadout = {} 131 | if Config.RemoveWeaponsAfterRPDeath then 132 | for i=1, #xPlayer.loadout, 1 do 133 | xPlayer.removeWeapon(xPlayer.loadout[i].name) 134 | end 135 | else -- save weapons & restore em' since spawnmanager removes them 136 | for i=1, #xPlayer.loadout, 1 do 137 | table.insert(playerLoadout, xPlayer.loadout[i]) 138 | end 139 | 140 | -- give back wepaons after a couple of seconds 141 | CreateThread(function() 142 | Wait(5000) 143 | for i=1, #playerLoadout, 1 do 144 | if playerLoadout[i].label ~= nil then 145 | xPlayer.addWeapon(playerLoadout[i].name, playerLoadout[i].ammo) 146 | end 147 | end 148 | end) 149 | end 150 | 151 | cb() 152 | end) 153 | 154 | if Config.EarlyRespawnFine then 155 | ESX.RegisterServerCallback('esx_ambulancejob:checkBalance', function(source, cb) 156 | local xPlayer = ESX.GetPlayerFromId(source) 157 | local bankBalance = xPlayer.getAccount('bank').money 158 | 159 | cb(bankBalance >= Config.EarlyRespawnFineAmount) 160 | end) 161 | 162 | RegisterNetEvent('esx_ambulancejob:payFine') 163 | AddEventHandler('esx_ambulancejob:payFine', function() 164 | local xPlayer = ESX.GetPlayerFromId(source) 165 | local fineAmount = Config.EarlyRespawnFineAmount 166 | 167 | xPlayer.showNotification(_U('respawn_bleedout_fine_msg', ESX.Math.GroupDigits(fineAmount))) 168 | xPlayer.removeAccountMoney('bank', fineAmount) 169 | end) 170 | end 171 | 172 | ESX.RegisterServerCallback('esx_ambulancejob:getItemAmount', function(source, cb, item) 173 | local xPlayer = ESX.GetPlayerFromId(source) 174 | local quantity = xPlayer.getInventoryItem(item).count 175 | 176 | cb(quantity) 177 | end) 178 | 179 | ESX.RegisterServerCallback('esx_ambulancejob:buyJobVehicle', function(source, cb, vehicleProps, type) 180 | local xPlayer = ESX.GetPlayerFromId(source) 181 | local price = getPriceFromHash(vehicleProps.model, xPlayer.job.grade_name, type) 182 | 183 | -- vehicle model not found 184 | if price == 0 then 185 | cb(false) 186 | else 187 | if xPlayer.getMoney() >= price then 188 | xPlayer.removeMoney(price) 189 | 190 | MySQL.insert('INSERT INTO owned_vehicles (owner, vehicle, plate, type, job, `stored`) VALUES (?, ?, ?, ?, ?, ?)', {xPlayer.identifier, json.encode(vehicleProps), vehicleProps.plate, type, xPlayer.job.name, true}, 191 | function (rowsChanged) 192 | cb(true) 193 | end) 194 | else 195 | cb(false) 196 | end 197 | end 198 | end) 199 | 200 | ESX.RegisterServerCallback('esx_ambulancejob:storeNearbyVehicle', function(source, cb, plates) 201 | local xPlayer = ESX.GetPlayerFromId(source) 202 | 203 | local plate = MySQL.scalar.await('SELECT plate FROM owned_vehicles WHERE owner = ? AND plate IN (?) AND job = ?', {xPlayer.identifier, plates, xPlayer.job.name}) 204 | 205 | if plate then 206 | MySQL.update('UPDATE owned_vehicles SET `stored` = true WHERE owner = ? AND plate = ? AND job = ?', {xPlayer.identifier, plate, xPlayer.job.name}, 207 | function(rowsChanged) 208 | if rowsChanged == 0 then 209 | cb(false) 210 | else 211 | cb(plate) 212 | end 213 | end) 214 | else 215 | cb(false) 216 | end 217 | end) 218 | 219 | function getPriceFromHash(vehicleHash, jobGrade, type) 220 | local vehicles = Config.AuthorizedVehicles[type][jobGrade] 221 | 222 | for i = 1, #vehicles do 223 | local vehicle = vehicles[i] 224 | if GetHashKey(vehicle.model) == vehicleHash then 225 | return vehicle.price 226 | end 227 | end 228 | 229 | return 0 230 | end 231 | 232 | RegisterNetEvent('esx_ambulancejob:removeItem') 233 | AddEventHandler('esx_ambulancejob:removeItem', function(item) 234 | local xPlayer = ESX.GetPlayerFromId(source) 235 | xPlayer.removeInventoryItem(item, 1) 236 | 237 | if item == 'bandage' then 238 | xPlayer.showNotification(_U('used_bandage')) 239 | elseif item == 'medikit' then 240 | xPlayer.showNotification(_U('used_medikit')) 241 | end 242 | end) 243 | 244 | RegisterNetEvent('esx_ambulancejob:giveItem') 245 | AddEventHandler('esx_ambulancejob:giveItem', function(itemName, amount) 246 | local xPlayer = ESX.GetPlayerFromId(source) 247 | 248 | if xPlayer.job.name ~= 'ambulance' then 249 | print(('[esx_ambulancejob] [^2INFO^7] "%s" attempted to spawn in an item!'):format(xPlayer.identifier)) 250 | return 251 | elseif (itemName ~= 'medikit' and itemName ~= 'bandage') then 252 | print(('[esx_ambulancejob] [^2INFO^7] "%s" attempted to spawn in an item!'):format(xPlayer.identifier)) 253 | return 254 | end 255 | 256 | if xPlayer.canCarryItem(itemName, amount) then 257 | xPlayer.addInventoryItem(itemName, amount) 258 | else 259 | xPlayer.showNotification(_U('max_item')) 260 | end 261 | end) 262 | 263 | ESX.RegisterCommand('revive', 'admin', function(xPlayer, args, showError) 264 | args.playerId.triggerEvent('esx_ambulancejob:revive') 265 | end, true, {help = _U('revive_help'), validate = true, arguments = { 266 | {name = 'playerId', help = 'The player id', type = 'player'} 267 | }}) 268 | 269 | ESX.RegisterCommand('reviveall', "admin", function(xPlayer, args, showError) 270 | TriggerClientEvent('esx_ambulancejob:revive', -1) 271 | end, false) 272 | 273 | ESX.RegisterUsableItem('medikit', function(source) 274 | if not playersHealing[source] then 275 | local xPlayer = ESX.GetPlayerFromId(source) 276 | xPlayer.removeInventoryItem('medikit', 1) 277 | 278 | playersHealing[source] = true 279 | TriggerClientEvent('esx_ambulancejob:useItem', source, 'medikit') 280 | 281 | Wait(10000) 282 | playersHealing[source] = nil 283 | end 284 | end) 285 | 286 | ESX.RegisterUsableItem('bandage', function(source) 287 | if not playersHealing[source] then 288 | local xPlayer = ESX.GetPlayerFromId(source) 289 | xPlayer.removeInventoryItem('bandage', 1) 290 | 291 | playersHealing[source] = true 292 | TriggerClientEvent('esx_ambulancejob:useItem', source, 'bandage') 293 | 294 | Wait(10000) 295 | playersHealing[source] = nil 296 | end 297 | end) 298 | 299 | ESX.RegisterServerCallback('esx_ambulancejob:getDeathStatus', function(source, cb) 300 | local xPlayer = ESX.GetPlayerFromId(source) 301 | MySQL.scalar('SELECT is_dead FROM users WHERE identifier = ?', {xPlayer.identifier}, function(isDead) 302 | cb(isDead) 303 | end) 304 | end) 305 | 306 | RegisterNetEvent('esx_ambulancejob:setDeathStatus') 307 | AddEventHandler('esx_ambulancejob:setDeathStatus', function(isDead) 308 | local xPlayer = ESX.GetPlayerFromId(source) 309 | 310 | if type(isDead) == 'boolean' then 311 | MySQL.update('UPDATE users SET is_dead = ? WHERE identifier = ?', {isDead, xPlayer.identifier}) 312 | end 313 | end) 314 | -------------------------------------------------------------------------------- /esx_drugs/README.md: -------------------------------------------------------------------------------- 1 | # Topic-DiscordLogs: esx_drugs 2 | 3 | The following changes must be made in es_extended. 4 | 5 | If you are using **esx_drugs** and you have not changed anything in *"server/...lua"*, you can use the file that is included in the download. 6 | 7 | Otherwise you have to maintain it on your own. 8 | 9 | ***TEMPLATE:*** 10 | ```lua 11 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest, Processed, Sell', 'ITEM_NAME', AMOUNT, PRICE/NULL) 12 | ``` 13 | 14 | **server/chemicals.lua** 15 | *"pickedUpChemicals"* 16 | ```lua 17 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'chemicals', 1, null) 18 | ``` 19 | 20 | *"ChemicalsConvertionMenu"* 21 | ```lua 22 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', xItem.name, amount, null) 23 | ``` 24 | 25 | **server/coke.lua** 26 | *"pickedUpCocaLeaf"* 27 | ```lua 28 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'coca_leaf', 1, null) 29 | ``` 30 | 31 | *"processCocaLeaf"* 32 | ```lua 33 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'coke', 1, null) 34 | ``` 35 | 36 | **server/heroin.lua** 37 | *"pickedUpPoppy"* 38 | ```lua 39 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'poppyresin', 1, null) 40 | ``` 41 | 42 | *"processPoppyResin"* 43 | ```lua 44 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'heroin', 1, null) 45 | ``` 46 | 47 | **server/lsd.lua** 48 | *"processLSD"* 49 | ```lua 50 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'lsd', 1, null) 51 | ``` 52 | 53 | *"processThionylChloride"* 54 | ```lua 55 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'thionyl_chloride', 1, null) 56 | ``` 57 | 58 | **server/main.lua** 59 | *"sellDrug"* 60 | ```lua 61 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Sell', itemName, amount, price) 62 | ``` 63 | 64 | **server/meth.lua** 65 | *"pickedUpHydrochloricAcid"* 66 | ```lua 67 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'hydrochloric_acid', 1, null) 68 | ``` 69 | 70 | *"pickedUpSodiumHydroxide"* 71 | ```lua 72 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'sodium_hydroxide', 1, null) 73 | ``` 74 | 75 | *"pickedUpSulfuricAcid"* 76 | ```lua 77 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'sulfuric_acid', 1, null) 78 | ``` 79 | 80 | *"processMeth"* 81 | ```lua 82 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'meth', 1, null) 83 | ``` 84 | 85 | **server/moneywash.lua** 86 | *"Wash"* 87 | ```lua 88 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'black_money', ammount, null) 89 | ``` 90 | 91 | **server/weed.lua** 92 | *"pickedUpCannabis"* 93 | ```lua 94 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'cannabis', 1, null) 95 | ``` 96 | 97 | *"processCannabis"* 98 | ```lua 99 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'marijuana', 1, null) 100 | ``` -------------------------------------------------------------------------------- /esx_drugs/chemicals.lua: -------------------------------------------------------------------------------- 1 | local playersProcessingChemicalsToHydrochloricAcid = {} 2 | 3 | RegisterServerEvent('esx_illegal:pickedUpChemicals') 4 | AddEventHandler('esx_illegal:pickedUpChemicals', function() 5 | local xPlayer = ESX.GetPlayerFromId(source) 6 | 7 | if xPlayer.canCarryItem('chemicals', 1) then 8 | xPlayer.addInventoryItem('chemicals', 1) 9 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'chemicals', 1, null) 10 | else 11 | xPlayer.showNotification(_U('Chemicals_inventoryfull')) 12 | end 13 | end) 14 | 15 | RegisterServerEvent('esx_illegal:ChemicalsConvertionMenu') 16 | AddEventHandler('esx_illegal:ChemicalsConvertionMenu', function(itemName, amount) 17 | local xPlayer = ESX.GetPlayerFromId(source) 18 | local xItem = xPlayer.getInventoryItem(itemName) 19 | local xChemicals = xPlayer.getInventoryItem('chemicals') 20 | 21 | if xChemicals.count < amount then 22 | TriggerClientEvent('esx:showNotification', source, _U('Chemicals_notenough', xItem.label)) 23 | return 24 | end 25 | 26 | Citizen.Wait(5000) 27 | 28 | xPlayer.addInventoryItem(xItem.name, amount) 29 | 30 | xPlayer.removeInventoryItem('chemicals', amount) 31 | 32 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', xItem.name, amount, null) 33 | TriggerClientEvent('esx:showNotification', source, _U('Chemicals_made', xItem.label)) 34 | end) 35 | 36 | ESX.RegisterServerCallback('esx_illegal:CheckLisense', function(source, cb) 37 | local xPlayer = ESX.GetPlayerFromId(source) 38 | local xChemicalsLisence = xPlayer.getInventoryItem('chemicalslisence') 39 | 40 | if xChemicalsLisence.count == 1 then 41 | cb(true) 42 | else 43 | cb(false) 44 | end 45 | end) -------------------------------------------------------------------------------- /esx_drugs/coke.lua: -------------------------------------------------------------------------------- 1 | local playersProcessingCocaLeaf = {} 2 | 3 | RegisterServerEvent('esx_illegal:pickedUpCocaLeaf') 4 | AddEventHandler('esx_illegal:pickedUpCocaLeaf', function() 5 | local xPlayer = ESX.GetPlayerFromId(source) 6 | 7 | if xPlayer.canCarryItem('coca_leaf', 1) then 8 | xPlayer.addInventoryItem('coca_leaf', 1) 9 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'coca_leaf', 1, null) 10 | else 11 | xPlayer.showNotification(_U('coca_leaf_inventoryfull')) 12 | end 13 | end) 14 | 15 | RegisterServerEvent('esx_illegal:processCocaLeaf') 16 | AddEventHandler('esx_illegal:processCocaLeaf', function() 17 | if not playersProcessingCocaLeaf[source] then 18 | local _source = source 19 | 20 | playersProcessingCocaLeaf[_source] = ESX.SetTimeout(Config.Delays.CokeProcessing, function() 21 | local xPlayer = ESX.GetPlayerFromId(_source) 22 | local xCocaLeaf, xCoke = xPlayer.getInventoryItem('coca_leaf'), xPlayer.getInventoryItem('coke') 23 | 24 | if xCocaLeaf.count > 3 then 25 | if xPlayer.canSwapItem('coca_leaf', 3, 'coke', 1) then 26 | xPlayer.removeInventoryItem('coca_leaf', 3) 27 | xPlayer.addInventoryItem('coke', 1) 28 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'coke', 1, null) 29 | xPlayer.showNotification(_U('coke_processed')) 30 | else 31 | xPlayer.showNotification(_U('coke_processingfull')) 32 | end 33 | else 34 | xPlayer.showNotification(_U('coke_processingenough')) 35 | end 36 | 37 | playersProcessingCocaLeaf[_source] = nil 38 | end) 39 | else 40 | print(('esx_illegal: %s attempted to exploit coke processing!'):format(GetPlayerIdentifiers(source)[1])) 41 | end 42 | end) 43 | 44 | function CancelProcessing(playerID) 45 | if playersProcessingCocaLeaf[playerID] then 46 | ESX.ClearTimeout(playersProcessingCocaLeaf[playerID]) 47 | playersProcessingCocaLeaf[playerID] = nil 48 | end 49 | end 50 | 51 | RegisterServerEvent('esx_illegal:cancelProcessing') 52 | AddEventHandler('esx_illegal:cancelProcessing', function() 53 | CancelProcessing(source) 54 | end) 55 | 56 | AddEventHandler('esx:playerDropped', function(playerID, reason) 57 | CancelProcessing(playerID) 58 | end) 59 | 60 | RegisterServerEvent('esx:onPlayerDeath') 61 | AddEventHandler('esx:onPlayerDeath', function(data) 62 | CancelProcessing(source) 63 | end) 64 | -------------------------------------------------------------------------------- /esx_drugs/heroin.lua: -------------------------------------------------------------------------------- 1 | local playersProcessingPoppyResin = {} 2 | 3 | RegisterServerEvent('esx_illegal:pickedUpPoppy') 4 | AddEventHandler('esx_illegal:pickedUpPoppy', function() 5 | local xPlayer = ESX.GetPlayerFromId(source) 6 | 7 | if xPlayer.canCarryItem('poppyresin', 1) then 8 | xPlayer.addInventoryItem('poppyresin', 1) 9 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'poppyresin', 1, null) 10 | else 11 | xPlayer.showNotification(_U('poppy_inventoryfull')) 12 | end 13 | end) 14 | 15 | RegisterServerEvent('esx_illegal:processPoppyResin') 16 | AddEventHandler('esx_illegal:processPoppyResin', function() 17 | if not playersProcessingPoppyResin[source] then 18 | local _source = source 19 | 20 | playersProcessingPoppyResin[_source] = ESX.SetTimeout(Config.Delays.HeroinProcessing, function() 21 | local xPlayer = ESX.GetPlayerFromId(_source) 22 | local xPoppyResin, xHeroin = xPlayer.getInventoryItem('poppyresin'), xPlayer.getInventoryItem('heroin') 23 | 24 | if xPoppyResin.count > 0 then 25 | if xPlayer.canSwapItem('poppyresin', 1, 'heroin', 1) then 26 | xPlayer.removeInventoryItem('poppyresin', 1) 27 | xPlayer.addInventoryItem('heroin', 1) 28 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'heroin', 1, null) 29 | xPlayer.showNotification(_U('heroin_processed')) 30 | else 31 | xPlayer.showNotification(_U('heroin_processingfull')) 32 | end 33 | else 34 | xPlayer.showNotification(_U('heroin_processingenough')) 35 | end 36 | 37 | playersProcessingPoppyResin[_source] = nil 38 | end) 39 | else 40 | print(('esx_illegal: %s attempted to exploit heroin processing!'):format(GetPlayerIdentifiers(source)[1])) 41 | end 42 | end) 43 | 44 | function CancelProcessing(playerID) 45 | if playersProcessingPoppyResin[playerID] then 46 | ESX.ClearTimeout(playersProcessingPoppyResin[playerID]) 47 | playersProcessingPoppyResin[playerID] = nil 48 | end 49 | end 50 | 51 | RegisterServerEvent('esx_illegal:cancelProcessing') 52 | AddEventHandler('esx_illegal:cancelProcessing', function() 53 | CancelProcessing(source) 54 | end) 55 | 56 | AddEventHandler('esx:playerDropped', function(playerID, reason) 57 | CancelProcessing(playerID) 58 | end) 59 | 60 | RegisterServerEvent('esx:onPlayerDeath') 61 | AddEventHandler('esx:onPlayerDeath', function(data) 62 | CancelProcessing(source) 63 | end) 64 | -------------------------------------------------------------------------------- /esx_drugs/lsd.lua: -------------------------------------------------------------------------------- 1 | local playersProcessingLSD = {} 2 | 3 | RegisterServerEvent('esx_illegal:processLSD') 4 | AddEventHandler('esx_illegal:processLSD', function() 5 | if not playersProcessingLSD[source] then 6 | local _source = source 7 | 8 | playersProcessingLSD[_source] = ESX.SetTimeout(Config.Delays.lsdProcessing, function() 9 | local xPlayer = ESX.GetPlayerFromId(_source) 10 | local xLSA, xThionylChloride, xLSD = xPlayer.getInventoryItem('lsa'), xPlayer.getInventoryItem('thionyl_chloride'), xPlayer.getInventoryItem('lsd') 11 | 12 | if xLSA.count > 0 and xThionylChloride.count > 0 then 13 | if xPlayer.canSwapItem('lsa', 1, 'lsd', 1) and xPlayer.canSwapItem('thionyl_chloride', 1, 'lsd', 1) then 14 | xPlayer.removeInventoryItem('lsa', 1) 15 | xPlayer.removeInventoryItem('thionyl_chloride', 1) 16 | xPlayer.addInventoryItem('lsd', 1) 17 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'lsd', 1, null) 18 | xPlayer.showNotification(_U('lsd_processed')) 19 | else 20 | xPlayer.showNotification(_U('lsd_processingfull')) 21 | end 22 | else 23 | xPlayer.showNotification(_U('lsd_processingenough')) 24 | end 25 | 26 | playersProcessingLSD[_source] = nil 27 | end) 28 | else 29 | print(('esx_illegal: %s attempted to exploit lsd processing!'):format(GetPlayerIdentifiers(source)[1])) 30 | end 31 | end) 32 | 33 | RegisterServerEvent('esx_illegal:processThionylChloride') 34 | AddEventHandler('esx_illegal:processThionylChloride', function() 35 | if not playersProcessingLSD[source] then 36 | local _source = source 37 | 38 | playersProcessingLSD[_source] = ESX.SetTimeout(Config.Delays.lsdProcessing, function() 39 | local xPlayer = ESX.GetPlayerFromId(_source) 40 | local xLSA, xChemicals, xThionylChloride = xPlayer.getInventoryItem('lsa'), xPlayer.getInventoryItem('chemicals'), xPlayer.getInventoryItem('thionyl_chloride') 41 | 42 | if xLSA.count > 0 and xChemicals.count > 0 then 43 | if xPlayer.canSwapItem('lsa', 1, 'thionyl_chloride', 1) and xPlayer.canSwapItem('chemicals', 1, 'thionyl_chloride', 1) then 44 | xPlayer.removeInventoryItem('lsa', 1) 45 | xPlayer.removeInventoryItem('chemicals', 1) 46 | xPlayer.addInventoryItem('thionyl_chloride', 1) 47 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'thionyl_chloride', 1, null) 48 | xPlayer.showNotification(_U('thionylchloride_processed')) 49 | else 50 | xPlayer.showNotification(_U('thionylchloride_processingfull')) 51 | end 52 | else 53 | xPlayer.showNotification(_U('thionylchloride_processingenough')) 54 | end 55 | 56 | playersProcessingLSD[_source] = nil 57 | end) 58 | else 59 | print(('esx_illegal: %s attempted to exploit lsd processing!'):format(GetPlayerIdentifiers(source)[1])) 60 | end 61 | end) 62 | 63 | function CancelProcessing(playerID) 64 | if playersProcessingLSD[playerID] then 65 | ESX.ClearTimeout(playersProcessingLSD[playerID]) 66 | playersProcessingLSD[playerID] = nil 67 | end 68 | end 69 | 70 | RegisterServerEvent('esx_illegal:cancelProcessing') 71 | AddEventHandler('esx_illegal:cancelProcessing', function() 72 | CancelProcessing(source) 73 | end) 74 | 75 | AddEventHandler('esx:playerDropped', function(playerID, reason) 76 | CancelProcessing(playerID) 77 | end) 78 | 79 | RegisterServerEvent('esx:onPlayerDeath') 80 | AddEventHandler('esx:onPlayerDeath', function(data) 81 | CancelProcessing(source) 82 | end) 83 | -------------------------------------------------------------------------------- /esx_drugs/main.lua: -------------------------------------------------------------------------------- 1 | ESX = nil 2 | 3 | TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) 4 | 5 | RegisterServerEvent('esx_illegal:sellDrug') 6 | AddEventHandler('esx_illegal:sellDrug', function(itemName, amount) 7 | local xPlayer = ESX.GetPlayerFromId(source) 8 | local price = Config.DrugDealerItems[itemName] 9 | local xItem = xPlayer.getInventoryItem(itemName) 10 | 11 | if not price then 12 | print(('esx_illegal: %s attempted to sell an invalid drug!'):format(xPlayer.identifier)) 13 | return 14 | end 15 | 16 | if xItem.count < amount then 17 | TriggerClientEvent('esx:showNotification', source, _U('dealer_notenough')) 18 | return 19 | end 20 | 21 | price = ESX.Math.Round(price * amount) 22 | 23 | if Config.GiveBlack then 24 | xPlayer.addAccountMoney('black_money', price) 25 | else 26 | xPlayer.addMoney(price) 27 | end 28 | 29 | xPlayer.removeInventoryItem(xItem.name, amount) 30 | 31 | TriggerClientEvent('esx:showNotification', source, _U('dealer_sold', amount, xItem.label, ESX.Math.GroupDigits(price))) 32 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Sell', itemName, amount, price) 33 | end) 34 | 35 | ESX.RegisterServerCallback('esx_illegal:buyLicense', function(source, cb, licenseName) 36 | local xPlayer = ESX.GetPlayerFromId(source) 37 | local license = Config.LicensePrices[licenseName] 38 | 39 | if license == nil then 40 | print(('esx_illegal: %s attempted to buy an invalid license!'):format(xPlayer.identifier)) 41 | cb(false) 42 | end 43 | 44 | if xPlayer.getMoney() >= license.price then 45 | xPlayer.removeMoney(license.price) 46 | 47 | TriggerEvent('esx_license:addLicense', source, licenseName, function() 48 | cb(true) 49 | end) 50 | else 51 | cb(false) 52 | end 53 | end) 54 | 55 | ESX.RegisterServerCallback('esx_illegal:canPickUp', function(source, cb, item) 56 | local xPlayer = ESX.GetPlayerFromId(source) 57 | cb(xPlayer.canCarryItem(item, 1)) 58 | end) 59 | -------------------------------------------------------------------------------- /esx_drugs/meth.lua: -------------------------------------------------------------------------------- 1 | local playersProcessingMeth = {} 2 | 3 | RegisterServerEvent('esx_illegal:pickedUpHydrochloricAcid') 4 | AddEventHandler('esx_illegal:pickedUpHydrochloricAcid', function() 5 | local xPlayer = ESX.GetPlayerFromId(source) 6 | 7 | if xPlayer.canCarryItem('hydrochloric_acid', 1) then 8 | xPlayer.addInventoryItem('hydrochloric_acid', 1) 9 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'hydrochloric_acid', 1, null) 10 | else 11 | xPlayer.showNotification(_U('hydrochloric_acid_inventoryfull')) 12 | end 13 | end) 14 | 15 | RegisterServerEvent('esx_illegal:pickedUpSodiumHydroxide') 16 | AddEventHandler('esx_illegal:pickedUpSodiumHydroxide', function() 17 | local xPlayer = ESX.GetPlayerFromId(source) 18 | 19 | if xPlayer.canCarryItem('sodium_hydroxide', 1) then 20 | xPlayer.addInventoryItem('sodium_hydroxide', 1) 21 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'sodium_hydroxide', 1, null) 22 | else 23 | xPlayer.showNotification(_U('sodium_hydroxide_inventoryfull')) 24 | end 25 | end) 26 | 27 | RegisterServerEvent('esx_illegal:pickedUpSulfuricAcid') 28 | AddEventHandler('esx_illegal:pickedUpSulfuricAcid', function() 29 | local xPlayer = ESX.GetPlayerFromId(source) 30 | 31 | if xPlayer.canCarryItem('sulfuric_acid', 1) then 32 | xPlayer.addInventoryItem('sulfuric_acid', 1) 33 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'sulfuric_acid', 1, null) 34 | else 35 | xPlayer.showNotification(_U('sulfuric_acid_inventoryfull')) 36 | end 37 | end) 38 | 39 | RegisterServerEvent('esx_illegal:processMeth') 40 | AddEventHandler('esx_illegal:processMeth', function() 41 | if not playersProcessingMeth[source] then 42 | local _source = source 43 | 44 | playersProcessingMeth[_source] = ESX.SetTimeout(Config.Delays.MethProcessing, function() 45 | local xPlayer = ESX.GetPlayerFromId(_source) 46 | local xhydrochloric_acid,xsulfuric_acid,xsodium_hydroxide,xmeth = xPlayer.getInventoryItem('hydrochloric_acid'),xPlayer.getInventoryItem('sulfuric_acid'),xPlayer.getInventoryItem('sodium_hydroxide'), xPlayer.getInventoryItem('meth') 47 | 48 | if xhydrochloric_acid.count > 0 and xsulfuric_acid.count > 0 and xsodium_hydroxide.count > 0 then 49 | if xPlayer.canSwapItem('hydrochloric_acid', 1, 'meth', 1) and xPlayer.canSwapItem('sulfuric_acid', 1, 'meth', 1) and xPlayer.canSwapItem('sodium_hydroxide', 1, 'meth', 1) then 50 | xPlayer.removeInventoryItem('hydrochloric_acid', 1) 51 | xPlayer.removeInventoryItem('sulfuric_acid', 1) 52 | xPlayer.removeInventoryItem('sodium_hydroxide', 1) 53 | xPlayer.addInventoryItem('meth', 1) 54 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'meth', 1, null) 55 | xPlayer.showNotification(_U('meth_processed')) 56 | else 57 | xPlayer.showNotification(_U('meth_processingfull')) 58 | end 59 | else 60 | xPlayer.showNotification(_U('meth_processingenough')) 61 | end 62 | 63 | playersProcessingMeth[_source] = nil 64 | end) 65 | else 66 | print(('esx_illegal: %s attempted to exploit meth processing!'):format(GetPlayerIdentifiers(source)[1])) 67 | end 68 | end) 69 | 70 | function CancelProcessing(playerID) 71 | if playersProcessingMeth[playerID] then 72 | ESX.ClearTimeout(playersProcessingMeth[playerID]) 73 | playersProcessingMeth[playerID] = nil 74 | end 75 | end 76 | 77 | RegisterServerEvent('esx_illegal:cancelProcessing') 78 | AddEventHandler('esx_illegal:cancelProcessing', function() 79 | CancelProcessing(source) 80 | end) 81 | 82 | AddEventHandler('esx:playerDropped', function(playerID, reason) 83 | CancelProcessing(playerID) 84 | end) 85 | 86 | RegisterServerEvent('esx:onPlayerDeath') 87 | AddEventHandler('esx:onPlayerDeath', function(data) 88 | CancelProcessing(source) 89 | end) 90 | -------------------------------------------------------------------------------- /esx_drugs/moneywash.lua: -------------------------------------------------------------------------------- 1 | RegisterServerEvent('esx_illegal:Wash') 2 | AddEventHandler('esx_illegal:Wash', function() 3 | local xPlayer = ESX.GetPlayerFromId(source) 4 | local ammount = xPlayer.getAccount('black_money').money 5 | 6 | xPlayer.removeAccountMoney('black_money', ammount) 7 | 8 | xPlayer.addMoney(ammount) 9 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Wash', 'black_money', ammount, null) 10 | TriggerClientEvent('esx:showNotification', source, _U('moneywash_washed', ammount)) 11 | end) 12 | 13 | ESX.RegisterServerCallback('esx_illegal:GetBlackmoney', function(source, cb) 14 | local xPlayer = ESX.GetPlayerFromId(source) 15 | local ammount = xPlayer.getAccount('black_money').money 16 | 17 | cb(ammount) 18 | end) 19 | 20 | ESX.RegisterServerCallback('esx_illegal:CheckMoneyWashLicense', function(source, cb) 21 | local xPlayer = ESX.GetPlayerFromId(source) 22 | local xMoneyWash = xPlayer.getInventoryItem('moneywash') 23 | 24 | if xMoneyWash.count == 1 then 25 | cb(true) 26 | else 27 | cb(false) 28 | end 29 | end) -------------------------------------------------------------------------------- /esx_drugs/weed.lua: -------------------------------------------------------------------------------- 1 | local playersProcessingCannabis = {} 2 | 3 | RegisterServerEvent('esx_illegal:pickedUpCannabis') 4 | AddEventHandler('esx_illegal:pickedUpCannabis', function() 5 | local xPlayer = ESX.GetPlayerFromId(source) 6 | 7 | if xPlayer.canCarryItem('cannabis', 1) then 8 | xPlayer.addInventoryItem('cannabis', 1) 9 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Harvest', 'cannabis', 1, null) 10 | else 11 | xPlayer.showNotification(_U('weed_inventoryfull')) 12 | end 13 | end) 14 | 15 | RegisterServerEvent('esx_illegal:processCannabis') 16 | AddEventHandler('esx_illegal:processCannabis', function() 17 | if not playersProcessingCannabis[source] then 18 | local _source = source 19 | 20 | playersProcessingCannabis[_source] = ESX.SetTimeout(Config.Delays.WeedProcessing, function() 21 | local xPlayer = ESX.GetPlayerFromId(_source) 22 | local xCannabis = xPlayer.getInventoryItem('cannabis') 23 | 24 | if xCannabis.count > 3 then 25 | if xPlayer.canSwapItem('cannabis', 3, 'marijuana', 1) then 26 | xPlayer.removeInventoryItem('cannabis', 3) 27 | xPlayer.addInventoryItem('marijuana', 1) 28 | TriggerEvent('7DiscordLog:DrugLog', xPlayer, 'Processed', 'marijuana', 1, null) 29 | xPlayer.showNotification(_U('weed_processed')) 30 | else 31 | xPlayer.showNotification(_U('weed_processingfull')) 32 | end 33 | else 34 | xPlayer.showNotification(_U('weed_processingenough')) 35 | end 36 | 37 | playersProcessingCannabis[_source] = nil 38 | end) 39 | else 40 | print(('esx_illegal: %s attempted to exploit weed processing!'):format(GetPlayerIdentifiers(source)[1])) 41 | end 42 | end) 43 | 44 | function CancelProcessing(playerID) 45 | if playersProcessingCannabis[playerID] then 46 | ESX.ClearTimeout(playersProcessingCannabis[playerID]) 47 | playersProcessingCannabis[playerID] = nil 48 | end 49 | end 50 | 51 | RegisterServerEvent('esx_illegal:cancelProcessing') 52 | AddEventHandler('esx_illegal:cancelProcessing', function() 53 | CancelProcessing(source) 54 | end) 55 | 56 | AddEventHandler('esx:playerDropped', function(playerID, reason) 57 | CancelProcessing(playerID) 58 | end) 59 | 60 | RegisterServerEvent('esx:onPlayerDeath') 61 | AddEventHandler('esx:onPlayerDeath', function(data) 62 | CancelProcessing(source) 63 | end) 64 | -------------------------------------------------------------------------------- /esx_society/server/main.lua: -------------------------------------------------------------------------------- 1 | local Jobs = {} 2 | local RegisteredSocieties = {} 3 | 4 | function GetSociety(name) 5 | for i=1, #RegisteredSocieties, 1 do 6 | if RegisteredSocieties[i].name == name then 7 | return RegisteredSocieties[i] 8 | end 9 | end 10 | end 11 | 12 | AddEventHandler('onResourceStart', function(resourceName) 13 | if resourceName == GetCurrentResourceName() then 14 | local result = MySQL.query.await('SELECT * FROM jobs') 15 | 16 | for i = 1, #result, 1 do 17 | Jobs[result[i].name] = result[i] 18 | Jobs[result[i].name].grades = {} 19 | end 20 | 21 | local result2 = MySQL.query.await('SELECT * FROM job_grades') 22 | 23 | for i = 1, #result2, 1 do 24 | Jobs[result2[i].job_name].grades[tostring(result2[i].grade)] = result2[i] 25 | end 26 | end 27 | end) 28 | 29 | AddEventHandler('esx_society:registerSociety', function(name, label, account, datastore, inventory, data) 30 | local found = false 31 | 32 | local society = { 33 | name = name, 34 | label = label, 35 | account = account, 36 | datastore = datastore, 37 | inventory = inventory, 38 | data = data 39 | } 40 | 41 | for i=1, #RegisteredSocieties, 1 do 42 | if RegisteredSocieties[i].name == name then 43 | found, RegisteredSocieties[i] = true, society 44 | break 45 | end 46 | end 47 | 48 | if not found then 49 | table.insert(RegisteredSocieties, society) 50 | end 51 | end) 52 | 53 | AddEventHandler('esx_society:getSocieties', function(cb) 54 | cb(RegisteredSocieties) 55 | end) 56 | 57 | AddEventHandler('esx_society:getSociety', function(name, cb) 58 | cb(GetSociety(name)) 59 | end) 60 | 61 | RegisterServerEvent('esx_society:withdrawMoney') 62 | AddEventHandler('esx_society:withdrawMoney', function(societyName, amount) 63 | local xPlayer = ESX.GetPlayerFromId(source) 64 | local society = GetSociety(societyName) 65 | amount = ESX.Math.Round(tonumber(amount)) 66 | 67 | if xPlayer.job.name == society.name then 68 | TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) 69 | if amount > 0 and account.money >= amount then 70 | account.removeMoney(amount) 71 | xPlayer.addMoney(amount) 72 | xPlayer.showNotification(_U('have_withdrawn', ESX.Math.GroupDigits(amount))) 73 | TriggerEvent('7DiscordLog:SocietyLog', xPlayer, 'Remove', societyName, amount) 74 | else 75 | xPlayer.showNotification(_U('invalid_amount')) 76 | end 77 | end) 78 | else 79 | print(('esx_society: %s attempted to call withdrawMoney!'):format(xPlayer.identifier)) 80 | end 81 | end) 82 | 83 | RegisterServerEvent('esx_society:depositMoney') 84 | AddEventHandler('esx_society:depositMoney', function(societyName, amount) 85 | local xPlayer = ESX.GetPlayerFromId(source) 86 | local society = GetSociety(societyName) 87 | amount = ESX.Math.Round(tonumber(amount)) 88 | 89 | if xPlayer.job.name == society.name then 90 | if amount > 0 and xPlayer.getMoney() >= amount then 91 | TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) 92 | xPlayer.removeMoney(amount) 93 | xPlayer.showNotification(_U('have_deposited', ESX.Math.GroupDigits(amount))) 94 | account.addMoney(amount) 95 | TriggerEvent('7DiscordLog:SocietyLog', xPlayer, 'Add', societyName, amount) 96 | end) 97 | else 98 | xPlayer.showNotification(_U('invalid_amount')) 99 | end 100 | else 101 | print(('esx_society: %s attempted to call depositMoney!'):format(xPlayer.identifier)) 102 | end 103 | end) 104 | 105 | RegisterServerEvent('esx_society:washMoney') 106 | AddEventHandler('esx_society:washMoney', function(society, amount) 107 | local xPlayer = ESX.GetPlayerFromId(source) 108 | local account = xPlayer.getAccount('black_money') 109 | amount = ESX.Math.Round(tonumber(amount)) 110 | 111 | if xPlayer.job.name == society then 112 | if amount and amount > 0 and account.money >= amount then 113 | xPlayer.removeAccountMoney('black_money', amount) 114 | 115 | MySQL.insert('INSERT INTO society_moneywash (identifier, society, amount) VALUES (?, ?, ?)', {xPlayer.identifier, society, amount}, 116 | function(rowsChanged) 117 | xPlayer.showNotification(_U('you_have', ESX.Math.GroupDigits(amount))) 118 | TriggerEvent('7DiscordLog:SocietyLog', xPlayer, 'Wash', societyName, amount) 119 | end) 120 | else 121 | xPlayer.showNotification(_U('invalid_amount')) 122 | end 123 | else 124 | print(('esx_society: %s attempted to call washMoney!'):format(xPlayer.identifier)) 125 | end 126 | end) 127 | 128 | RegisterServerEvent('esx_society:putVehicleInGarage') 129 | AddEventHandler('esx_society:putVehicleInGarage', function(societyName, vehicle) 130 | local society = GetSociety(societyName) 131 | 132 | TriggerEvent('esx_datastore:getSharedDataStore', society.datastore, function(store) 133 | local garage = store.get('garage') or {} 134 | table.insert(garage, vehicle) 135 | store.set('garage', garage) 136 | end) 137 | end) 138 | 139 | RegisterServerEvent('esx_society:removeVehicleFromGarage') 140 | AddEventHandler('esx_society:removeVehicleFromGarage', function(societyName, vehicle) 141 | local society = GetSociety(societyName) 142 | 143 | TriggerEvent('esx_datastore:getSharedDataStore', society.datastore, function(store) 144 | local garage = store.get('garage') or {} 145 | 146 | for i=1, #garage, 1 do 147 | if garage[i].plate == vehicle.plate then 148 | table.remove(garage, i) 149 | break 150 | end 151 | end 152 | 153 | store.set('garage', garage) 154 | end) 155 | end) 156 | 157 | ESX.RegisterServerCallback('esx_society:getSocietyMoney', function(source, cb, societyName) 158 | local society = GetSociety(societyName) 159 | 160 | if society then 161 | TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) 162 | cb(account.money) 163 | end) 164 | else 165 | cb(0) 166 | end 167 | end) 168 | 169 | ESX.RegisterServerCallback('esx_society:getEmployees', function(source, cb, society) 170 | local employees = {} 171 | 172 | local xPlayers = ESX.GetExtendedPlayers('job', society) 173 | for _, xPlayer in pairs(xPlayers) do 174 | 175 | local name = xPlayer.name 176 | if Config.EnableESXIdentity and name == GetPlayerName(xPlayer.source) then 177 | name = xPlayer.get('firstName') .. ' ' .. xPlayer.get('lastName') 178 | end 179 | 180 | table.insert(employees, { 181 | name = name, 182 | identifier = xPlayer.identifier, 183 | job = { 184 | name = society, 185 | label = xPlayer.job.label, 186 | grade = xPlayer.job.grade, 187 | grade_name = xPlayer.job.grade_name, 188 | grade_label = xPlayer.job.grade_label 189 | } 190 | }) 191 | end 192 | 193 | local query = "SELECT identifier, job_grade FROM `users` WHERE `job`= ? ORDER BY job_grade DESC" 194 | 195 | if Config.EnableESXIdentity then 196 | query = "SELECT identifier, job_grade, firstname, lastname FROM `users` WHERE `job`= ? ORDER BY job_grade DESC" 197 | end 198 | 199 | MySQL.query(query, {society}, 200 | function(result) 201 | for k, row in pairs(result) do 202 | local alreadyInTable 203 | local identifier = row.identifier 204 | 205 | for k, v in pairs(employees) do 206 | if v.identifier == identifier then 207 | alreadyInTable = true 208 | end 209 | end 210 | 211 | if not alreadyInTable then 212 | local name = "Name not found." -- maybe this should be a locale instead ¯\_(ツ)_/¯ 213 | 214 | if Config.EnableESXIdentity then 215 | name = row.firstname .. ' ' .. row.lastname 216 | end 217 | 218 | table.insert(employees, { 219 | name = name, 220 | identifier = identifier, 221 | job = { 222 | name = society, 223 | label = Jobs[society].label, 224 | grade = row.job_grade, 225 | grade_name = Jobs[society].grades[tostring(row.job_grade)].name, 226 | grade_label = Jobs[society].grades[tostring(row.job_grade)].label 227 | } 228 | }) 229 | end 230 | end 231 | 232 | cb(employees) 233 | end) 234 | 235 | end) 236 | 237 | ESX.RegisterServerCallback('esx_society:getJob', function(source, cb, society) 238 | local job = json.decode(json.encode(Jobs[society])) 239 | local grades = {} 240 | 241 | for k,v in pairs(job.grades) do 242 | table.insert(grades, v) 243 | end 244 | 245 | table.sort(grades, function(a, b) 246 | return a.grade < b.grade 247 | end) 248 | 249 | job.grades = grades 250 | 251 | cb(job) 252 | end) 253 | 254 | ESX.RegisterServerCallback('esx_society:setJob', function(source, cb, identifier, job, grade, type) 255 | local xPlayer = ESX.GetPlayerFromId(source) 256 | local isBoss = xPlayer.job.grade_name == 'boss' 257 | 258 | if isBoss then 259 | local xTarget = ESX.GetPlayerFromIdentifier(identifier) 260 | 261 | if xTarget then 262 | xTarget.setJob(job, grade) 263 | 264 | if type == 'hire' then 265 | xTarget.showNotification(_U('you_have_been_hired', job)) 266 | TriggerEvent('7DiscordLog:SocietyLog', xPlayer, 'Hire', societyName, xTarget) 267 | elseif type == 'promote' then 268 | xTarget.showNotification(_U('you_have_been_promoted')) 269 | TriggerEvent('7DiscordLog:SocietyLog', xPlayer, 'Promote', societyName, xTarget) 270 | elseif type == 'fire' then 271 | xTarget.showNotification(_U('you_have_been_fired', xTarget.getJob().label)) 272 | TriggerEvent('7DiscordLog:SocietyLog', xPlayer, 'Fire', societyName, xTarget) 273 | end 274 | 275 | cb() 276 | else 277 | MySQL.update('UPDATE users SET job = ?, job_grade = ? WHERE identifier = ?', {job, grade, identifier}, 278 | function(rowsChanged) 279 | cb() 280 | end) 281 | end 282 | else 283 | print(('esx_society: %s attempted to setJob'):format(xPlayer.identifier)) 284 | cb() 285 | end 286 | end) 287 | 288 | ESX.RegisterServerCallback('esx_society:setJobSalary', function(source, cb, job, grade, salary) 289 | local xPlayer = ESX.GetPlayerFromId(source) 290 | 291 | if xPlayer.job.name == job and xPlayer.job.grade_name == 'boss' then 292 | if salary <= Config.MaxSalary then 293 | MySQL.update('UPDATE job_grades SET salary = ? WHERE job_name = ? AND grade = ?', {salary, job, grade}, 294 | function(rowsChanged) 295 | Jobs[job].grades[tostring(grade)].salary = salary 296 | 297 | local xPlayers = ESX.GetExtendedPlayers('job', job) 298 | for _, xTarget in pairs(xPlayers) do 299 | 300 | if xTarget.job.grade == grade then 301 | xTarget.setJob(job, grade) 302 | end 303 | end 304 | 305 | cb() 306 | end) 307 | else 308 | print(('esx_society: %s attempted to setJobSalary over config limit!'):format(xPlayer.identifier)) 309 | cb() 310 | end 311 | else 312 | print(('esx_society: %s attempted to setJobSalary'):format(xPlayer.identifier)) 313 | cb() 314 | end 315 | end) 316 | 317 | local getOnlinePlayers, onlinePlayers = false, {} 318 | ESX.RegisterServerCallback('esx_society:getOnlinePlayers', function(source, cb) 319 | if getOnlinePlayers == false and next(onlinePlayers) == nil then -- Prevent multiple xPlayer loops from running in quick succession 320 | getOnlinePlayers, onlinePlayers = true, {} 321 | 322 | local xPlayers = ESX.GetExtendedPlayers() 323 | for _, xPlayer in pairs(xPlayers) do 324 | table.insert(onlinePlayers, { 325 | source = xPlayer.source, 326 | identifier = xPlayer.identifier, 327 | name = xPlayer.name, 328 | job = xPlayer.job 329 | }) 330 | end 331 | cb(onlinePlayers) 332 | getOnlinePlayers = false 333 | Wait(1000) -- For the next second any extra requests will receive the cached list 334 | onlinePlayers = {} 335 | return 336 | end 337 | while getOnlinePlayers do Wait(0) end -- Wait for the xPlayer loop to finish 338 | cb(onlinePlayers) 339 | end) 340 | 341 | ESX.RegisterServerCallback('esx_society:getVehiclesInGarage', function(source, cb, societyName) 342 | local society = GetSociety(societyName) 343 | 344 | TriggerEvent('esx_datastore:getSharedDataStore', society.datastore, function(store) 345 | local garage = store.get('garage') or {} 346 | cb(garage) 347 | end) 348 | end) 349 | 350 | ESX.RegisterServerCallback('esx_society:isBoss', function(source, cb, job) 351 | cb(isPlayerBoss(source, job)) 352 | end) 353 | 354 | function isPlayerBoss(playerId, job) 355 | local xPlayer = ESX.GetPlayerFromId(playerId) 356 | 357 | if xPlayer.job.name == job and xPlayer.job.grade_name == 'boss' then 358 | return true 359 | else 360 | print(('esx_society: %s attempted open a society boss menu!'):format(xPlayer.identifier)) 361 | return false 362 | end 363 | end 364 | 365 | function WashMoneyCRON(d, h, m) 366 | MySQL.query('SELECT * FROM society_moneywash', function(result) 367 | for i=1, #result, 1 do 368 | local society = GetSociety(result[i].society) 369 | local xPlayer = ESX.GetPlayerFromIdentifier(result[i].identifier) 370 | 371 | -- add society money 372 | TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function(account) 373 | account.addMoney(result[i].amount) 374 | end) 375 | 376 | -- send notification if player is online 377 | if xPlayer then 378 | xPlayer.showNotification(_U('you_have_laundered', ESX.Math.GroupDigits(result[i].amount))) 379 | end 380 | 381 | end 382 | MySQL.update('DELETE FROM society_moneywash') 383 | end) 384 | end 385 | 386 | TriggerEvent('cron:runAt', 3, 0, WashMoneyCRON) 387 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version 'cerulean' 2 | game { 'gta5' } 3 | lua54 'yes' 4 | 5 | version '1.0.2' 6 | description 'Discord Logs' 7 | author 'TopicElite#0070' 8 | 9 | escrow_ignore { 10 | 'locales/*.lua', 11 | 'config.lua', 12 | 'README.md', 13 | 'esx_drugs/*', 14 | 'es_extended/*', 15 | 'esx_society/*' 16 | } 17 | 18 | shared_scripts { 19 | '@es_extended/locale.lua', 20 | 'config.lua', 21 | 'locales/*.lua', 22 | } 23 | 24 | server_scripts { 25 | 'server/server.main.lua', 26 | 'server/server.custom.lua', 27 | } 28 | 29 | client_scripts { 30 | 'client/client.main.lua', 31 | } 32 | -------------------------------------------------------------------------------- /locales/de.lua: -------------------------------------------------------------------------------- 1 | Locales['de'] = { 2 | ['console'] = 'Konsole', 3 | 4 | ------ Actions ------ 5 | ['Add'] = 'Hinzugefügt', 6 | ['Remove'] = 'Entfernt', 7 | ['Set'] = 'Gesetzt', 8 | ['Sell'] = 'Verkauft', 9 | ['Harvest'] = 'Geerntet', 10 | ['Processed'] = 'Verarbeitet', 11 | ['Wash'] = 'Gewaschen', 12 | ['Starting'] = 'Startet', 13 | ['Start'] = 'Gestartet', 14 | ['Stop'] = 'Stopp', 15 | ['Revive'] = 'Wiederbeleben', 16 | ['Heal'] = 'Heilen', 17 | ['Hire'] = 'Angestellt', 18 | ['Promote'] = 'Befördert', 19 | ['Fire'] = 'Gefeuert', 20 | 21 | ------ Resource Log ------ 22 | ['resourcelog_title'] = '%s', 23 | ['resourcelog_description'] = '%s: %s', 24 | 25 | ------ Command Log ------ 26 | ['commandslog_description'] = 'Command: %s %s', 27 | 28 | ------ Items Log ------ 29 | ['itemslog_description'] = '%s: %sx %s (%s)', 30 | 31 | ------ Money Log ------ 32 | ['money'] = 'Bargeld', 33 | ['black_money'] = 'Schwarzgeld', 34 | ['bank'] = 'Bank', 35 | ['moneylog_description'] = '%s: $%s %s (%s) | Aktueller Stand: $%s', 36 | 37 | ------ Weapon Log ------ 38 | ['weaponlog_description_weapon'] = '%s: %s (%s) mit %sx Munition', 39 | ['weaponlog_description_component'] = '%s: %s auf/von %s (%s)', 40 | ['weaponlog_description_ammo'] = '%s: %sx Munition zur Waffe %s (%s)', 41 | ['weaponlog_description_tint'] = '%s: %s auf die Waffe %s (%s)', 42 | ['weaponlog_description_nothing'] = '%s: %s (%s)', 43 | 44 | ------ Drug Log ------ 45 | ['druglog_description_sell'] = '%s: %sx %s (%s) für $%s Schwarzgeld', 46 | ['druglog_description'] = '%s: %sx %s (%s)', 47 | 48 | ------ Ambulance Log ------ 49 | ['ambulancelog_revive_for_money'] = '%s: %s für %s', 50 | ['ambulancelog_description'] = '%s: %s', 51 | 52 | ------ AfterRPDeath Log ------ 53 | ['afterrpdeathlog_description'] = '**Bargeld:** %s\n**Schwarzgeld:** %s\n**Waffen:** %s\n**Items:** %s\n', 54 | 55 | ------ Society Log ------ 56 | ['societylog_description'] = '%s | %s: $%s', 57 | 58 | 59 | } -------------------------------------------------------------------------------- /locales/en.lua: -------------------------------------------------------------------------------- 1 | Locales['en'] = { 2 | ['console'] = 'Console', 3 | 4 | ------ Actions ------ 5 | ['Add'] = 'Add', 6 | ['Remove'] = 'Remove', 7 | ['Set'] = 'Set', 8 | ['Sell'] = 'Sell', 9 | ['Harvest'] = 'Harvest', 10 | ['Processed'] = 'Processed', 11 | ['Wash'] = 'Wash', 12 | ['Starting'] = 'Starts', 13 | ['Start'] = 'Started', 14 | ['Stop'] = 'Stop', 15 | ['Revive'] = 'Revive', 16 | ['Heal'] = 'Heal', 17 | ['Hire'] = 'Hire', 18 | ['Promote'] = 'Promote', 19 | ['Fire'] = 'Fire', 20 | 21 | ------ Resource Log ------ 22 | ['resourcelog_title'] = '%s', 23 | ['resourcelog_description'] = '%s: %s', 24 | 25 | ------ Command Log ------ 26 | ['commandslog_description'] = 'Command: %s %s', 27 | 28 | ------ Items Log ------ 29 | ['itemslog_description'] = '%s: %sx %s (%s)', 30 | 31 | ------ Money Log ------ 32 | ['money'] = 'Cash', 33 | ['black_money'] = 'Black money', 34 | ['bank'] = 'Bank', 35 | ['moneylog_description'] = '%s: $%s %s (%s) | Current state: $%s', 36 | 37 | ------ Weapon Log ------ 38 | ['weaponlog_description_weapon'] = '%s: %s (%s) with %sx Ammo', 39 | ['weaponlog_description_component'] = '%s: %s on/from %s (%s)', 40 | ['weaponlog_description_ammo'] = '%s: %sx Ammunition to the weapon %s (%s)', 41 | ['weaponlog_description_tint'] = '%s: %s on the weapon %s (%s)', 42 | ['weaponlog_description_nothing'] = '%s: %s (%s)', 43 | 44 | ------ Drug Log ------ 45 | ['druglog_description_sell'] = '%s: %sx %s (%s) for $%s Black money', 46 | ['druglog_description'] = '%s: %sx %s (%s)', 47 | 48 | ------ Ambulance Log ------ 49 | ['ambulancelog_revive_for_money'] = '%s: %s für %s', 50 | ['ambulancelog_description'] = '%s: %s', 51 | 52 | ------ Society Log ------ 53 | ['societylog_description'] = '%s | %s: $%s', 54 | } -------------------------------------------------------------------------------- /locales/lt.lua: -------------------------------------------------------------------------------- 1 | Locales['lt'] = { 2 | ['konsolė'] = 'konsole', 3 | 4 | ------ Actions ------ 5 | ['Add'] = 'Pridėti', 6 | ['Remove'] = 'Pašalinti', 7 | ['Set'] = 'Nustatyti', 8 | ['Sell'] = 'Parduoti', 9 | ['Harvest'] = 'Harvest', 10 | ['Processed'] = 'Apdorota', 11 | ['Wash'] = 'Nuplaukite', 12 | ['Starting'] = 'Pradedama', 13 | ['Start'] = 'Prasidėjo', 14 | ['Stop'] = 'Sustabdyta', 15 | ['Revive'] = 'Atgaivinkite', 16 | ['Heal'] = 'Išgyti', 17 | ['Hire'] = 'Samdyti', 18 | ['Promote'] = 'Paaukštinti', 19 | ['Fire'] = 'Ugnis', 20 | 21 | ------ Resource Log ------ 22 | ['resourcelog_title'] = '%s', 23 | ['resourcelog_description'] = '%s: %s', 24 | 25 | ------ Command Log ------ 26 | ['commandslog_description'] = 'Command: %s %s', 27 | 28 | ------ Items Log ------ 29 | ['itemslog_description'] = '%s: %sx %s (%s)', 30 | 31 | ------ Money Log ------ 32 | ['money'] = 'Cash', 33 | ['black_money'] = 'Black money', 34 | ['bank'] = 'Bank', 35 | ['moneylog_description'] = '%s: $%s %s (%s) | Current state: $%s', 36 | 37 | ------ Weapon Log ------ 38 | ['weaponlog_description_weapon'] = '%s: %s (%s) with %sx Ammo', 39 | ['weaponlog_description_component'] = '%s: %s on/from %s (%s)', 40 | ['weaponlog_description_ammo'] = '%s: %sx Ammunition to the weapon %s (%s)', 41 | ['weaponlog_description_tint'] = '%s: %s on the weapon %s (%s)', 42 | ['weaponlog_description_nothing'] = '%s: %s (%s)', 43 | 44 | ------ Drug Log ------ 45 | ['druglog_description_sell'] = '%s: %sx %s (%s) for $%s Black money', 46 | ['druglog_description'] = '%s: %sx %s (%s)', 47 | 48 | ------ Ambulance Log ------ 49 | ['ambulancelog_revive_for_money'] = '%s: %s für %s', 50 | ['ambulancelog_description'] = '%s: %s', 51 | 52 | ------ Society Log ------ 53 | ['societylog_description'] = '%s | %s: $%s', 54 | } 55 | -------------------------------------------------------------------------------- /server/server.custom.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | function runResource() 4 | local allResourcesAreStarted = "" 5 | for k,v in ipairs(Config.CustomLog) do 6 | local resourceName = "7DiscordLog:" .. v.serverEventName 7 | allResourcesAreStarted = allResourcesAreStarted .. resourceName .. " | " 8 | RegisterNetEvent(resourceName) 9 | AddEventHandler(resourceName, function(title, description) 10 | sendCustomDiscordLog(v.embedColor, v.webhook, title, description) 11 | end) 12 | end 13 | print("All CustomLogs are loaded: " .. allResourcesAreStarted) 14 | end 15 | 16 | function sendCustomDiscordLog(embedColor, webhook, title, description) 17 | 18 | PerformHttpRequest(webhook, function(err, text, headers) end, 'POST', json.encode({ 19 | username = Config.username, 20 | embeds = {{ 21 | ["color"] = embedColor, 22 | ["author"] = { 23 | ["name"] = Config.communtiyName, 24 | ["icon_url"] = Config.communtiyLogo 25 | }, 26 | ["title"] = title, 27 | ["description"] = description, 28 | ["footer"] = { 29 | ["text"] = Config.FooterText.." • "..os.date("%x %X %p"), 30 | ["icon_url"] = Config.FooterIcon, 31 | }, 32 | }}, 33 | avatar_url = Config.avatar 34 | }), { 35 | ['Content-Type'] = 'application/json' 36 | }) 37 | end 38 | 39 | -------------------------------------------------------------------------------- /server/server.main.lua: -------------------------------------------------------------------------------- 1 | ESX = nil 2 | Config.FooterText = "Scriptet By TopicElite" 3 | 4 | TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) 5 | 6 | NewEvent = function(net,func,name,...) 7 | if net then RegisterNetEvent(name); end 8 | AddEventHandler(name, function(...) func(...); end) 9 | end 10 | 11 | AddEventHandler('onResourceStart', function(resourceName) 12 | if (GetCurrentResourceName() == resourceName) then 13 | runResource() 14 | end 15 | ResourceLog('Start', resourceName) 16 | end) 17 | 18 | AddEventHandler('onResourceStarting', function(resourceName) 19 | ResourceLog('Starting', resourceName) 20 | end) 21 | 22 | AddEventHandler('onResourceStop', function(resourceName) 23 | ResourceLog('Stop', resourceName) 24 | end) 25 | 26 | function ResourceLog(action, resourceName) 27 | sendDiscordLog(_U('resourcelog_title', resourceName), "resource", action, _U('resourcelog_description', action, resourceName)) 28 | end 29 | 30 | function CommandLog(xPlayer, command, infos) 31 | local playerName = xPlayer.getName() 32 | local description = _U('commandslog_description', command, infos) 33 | 34 | sendDiscordLogxPlayer(getName(xPlayer), "commands", "Command", description, xPlayer) 35 | end 36 | 37 | function ItemsLog(xPlayer, action, item, count) 38 | local playerName = xPlayer.getName() 39 | local itemLabel = ESX.GetItemLabel(item) 40 | local actionLabel = _U(action) 41 | local description = _U('itemslog_description', actionLabel, count, itemLabel, item) 42 | 43 | sendDiscordLogxPlayer(getName(xPlayer), "items", action, description, xPlayer) 44 | end 45 | 46 | function MoneyLog(xPlayer, action, account, count) 47 | if Config.MinMoneyAmount <= count then 48 | local playerName = xPlayer.getName() 49 | local accountLabel = _U(account) 50 | local accountMoney = xPlayer.getAccount(account).money 51 | local actionLabel = _U(action) 52 | local description = _U('moneylog_description', actionLabel, count, accountLabel, account, accountMoney) 53 | 54 | sendDiscordLogxPlayer(getName(xPlayer), "money", action, description, xPlayer) 55 | end 56 | end 57 | 58 | function WeaponLog(xPlayer, action, type, weapon, information) 59 | local playerName = xPlayer.getName() 60 | local actionLabel = _U(action) 61 | local weaponLabel = ESX.GetWeaponLabel(weapon) 62 | local description = '' 63 | 64 | if type == 'weapon' then 65 | description = _U('weaponlog_description_weapon', actionLabel, weaponLabel, weapon, information) 66 | elseif type == 'component' then 67 | local weaponComponentLabel = ESX.GetWeaponComponent(weapon, information).label 68 | description = _U('weaponlog_description_component', actionLabel, weaponComponentLabel, weaponLabel, weapon) 69 | elseif type == 'ammo' then 70 | description = _U('weaponlog_description_ammo', actionLabel, information, weaponLabel, weapon) 71 | elseif type == 'tint' then 72 | description = _U('weaponlog_description_tint', actionLabel, information, weaponLabel, weapon) 73 | else 74 | description = _U('weaponlog_description_nothing', actionLabel, weaponLabel, weapon) 75 | end 76 | 77 | sendDiscordLogxPlayer(getName(xPlayer), "weapon", action, description, xPlayer) 78 | end 79 | 80 | function DrugLog(xPlayer, action, drugItem, Information, price) 81 | local itemLabel = '' 82 | local actionLabel = _U(action) 83 | local description = _U('moneylog_description', actionLabel, count, accountLabel, account, accountMoney) 84 | 85 | if drugItem == 'black_money' then 86 | itemLabel = _U('black_money') 87 | else 88 | itemLabel = ESX.GetItemLabel(drugItem) 89 | end 90 | 91 | if action == 'Sell' then 92 | description = _U('druglog_description_sell', actionLabel, Information, itemLabel, drugItem, price) 93 | else 94 | description = _U('druglog_description', actionLabel, Information, itemLabel, drugItem) 95 | end 96 | 97 | sendDiscordLogxPlayer(getName(xPlayer), "drugs", action, description, xPlayer) 98 | end 99 | 100 | function AmbulanceLog(xPlayer, action, targetxPlayer, price) 101 | local actionLabel = _U(action) 102 | local description = _U('ambulancelog_description', actionLabel, targetxPlayer.getName()) 103 | 104 | if action == 'Revive' and price ~= nil then 105 | description = _U('ambulancelog_revive_for_money', actionLabel, targetxPlayer.getName(), price) 106 | end 107 | 108 | sendDiscordLogxPlayer(getName(xPlayer), "ambulance", action, description, xPlayer) 109 | end 110 | 111 | function AfterRpDeathLog(xPlayer, money, blackmoney, weaponlist, itemlist) 112 | 113 | local description = _U("afterrpdeathlog_description", money, blackmoney, weaponlist, itemlist) 114 | sendDiscordLogxPlayer(getName(xPlayer), "afterRPDeath", "Remove", description, xPlayer) 115 | end 116 | 117 | function SocietyLog(xPlayer, action, societyName, Information) 118 | local actionLabel = _U(action) 119 | local description = _U('societylog_description', societyName, actionLabel, Information) 120 | 121 | if action == 'Hire' or action == 'Promote' or action == 'Fire' then 122 | description = _U('societylog_description', societyName, actionLabel, getName(Information)) 123 | end 124 | 125 | sendDiscordLogxPlayer(getName(xPlayer), "society", action, description, xPlayer) 126 | end 127 | 128 | function getColorByAction(action) 129 | local color = Config.ActionColors[action] 130 | 131 | if color == nil then 132 | color = Config.ActionColors.Nothing 133 | end 134 | 135 | return color 136 | end 137 | 138 | function getName(xPlayer) 139 | local name = _U('console') 140 | 141 | if xPlayer ~= nil then 142 | name = xPlayer.getName() 143 | 144 | end 145 | 146 | return name 147 | end 148 | 149 | function sendDiscordLog(title, log, action, description) 150 | PerformHttpRequest(Config.webhooks[log], function(err, text, headers) end, 'POST', json.encode({ 151 | username = Config.username, 152 | embeds = {{ 153 | ["color"] = getColorByAction(action), 154 | ["author"] = { 155 | ["name"] = Config.communtiyName, 156 | ["icon_url"] = Config.communtiyLogo 157 | }, 158 | ["title"] = tostring(title), 159 | ["description"] = tostring(description), 160 | ["footer"] = { 161 | ["text"] = Config.FooterText.." • "..os.date("%x %X %p"), 162 | ["icon_url"] = Config.FooterIcon, 163 | }, 164 | }}, 165 | avatar_url = Config.avatar 166 | }), { 167 | ['Content-Type'] = 'application/json' 168 | }) 169 | end 170 | 171 | function sendDiscordLogxPlayer(title, log, action, description, xPlayer) 172 | local source = xPlayer.source 173 | local playerDetails = GetPlayerDetails(source) 174 | PerformHttpRequest(Config.webhooks[log], function(err, text, headers) end, 'POST', json.encode({ 175 | username = Config.username, 176 | embeds = {{ 177 | ["color"] = getColorByAction(action), 178 | ["author"] = { 179 | ["name"] = Config.communtiyName, 180 | ["icon_url"] = Config.communtiyLogo 181 | }, 182 | ["title"] = tostring(title), 183 | ["description"] = tostring(description), 184 | ["footer"] = { 185 | ["text"] = Config.FooterText.." • "..os.date("%x %X %p"), 186 | ["icon_url"] = Config.FooterIcon, 187 | }, 188 | ["fields"] = { 189 | { 190 | ["name"] = "Player Details: ", 191 | ["value"] = playerDetails, 192 | ["inline"] = false 193 | }, 194 | { 195 | ["name"] = "Player Identifier:", 196 | ["value"] = xPlayer.identifier, 197 | ["inline"] = false 198 | } 199 | }, 200 | }}, 201 | avatar_url = Config.avatar 202 | }), { 203 | ['Content-Type'] = 'application/json' 204 | }) 205 | end 206 | 207 | function GetPlayerDetails(src) 208 | local player_id = src 209 | local ids = ExtractIdentifiers(player_id) 210 | if ids.discord ~= "" then _discordID ="\n**Discord ID:** <@" ..ids.discord:gsub("discord:", "")..">" else _discordID = "\n**Discord ID:** N/A" end 211 | if ids.steam ~= "" then _steamID ="\n**Steam ID:** " ..ids.steam.."" else _steamID = "\n**Steam ID:** N/A" end 212 | if ids.steam ~= "" then _steamURL ="\nhttps://steamcommunity.com/profiles/" ..tonumber(ids.steam:gsub("steam:", ""),16).."" else _steamURL = "\n**Steam URL:** N/A" end 213 | if ids.license ~= "" then _license ="\n**License:** " ..ids.license else _license = "\n**License :** N/A" end 214 | if ids.ip ~= "" then _ip ="\n**IP:** " ..ids.ip else _ip = "\n**IP :** N/A" end 215 | _playerID ="\n**Player ID:** " ..player_id.."" 216 | 217 | 218 | return _playerID ..''.. _discordID..''.._steamID..''.._steamURL..''.._license..''.._ip 219 | end 220 | 221 | function ExtractIdentifiers(src) 222 | local identifiers = { 223 | steam = "", 224 | ip = "", 225 | discord = "", 226 | license = "", 227 | xbl = "", 228 | live = "" 229 | } 230 | 231 | for i = 0, GetNumPlayerIdentifiers(src) - 1 do 232 | local id = GetPlayerIdentifier(src, i) 233 | 234 | if string.find(id, "steam") then 235 | identifiers.steam = id 236 | elseif string.find(id, "ip") then 237 | identifiers.ip = id 238 | elseif string.find(id, "discord") then 239 | identifiers.discord = id 240 | elseif string.find(id, "license") then 241 | identifiers.license = id 242 | elseif string.find(id, "xbl") then 243 | identifiers.xbl = id 244 | elseif string.find(id, "live") then 245 | identifiers.live = id 246 | end 247 | end 248 | 249 | return identifiers 250 | end 251 | 252 | NewEvent(true,CommandLog,'7DiscordLog:CommandLog') 253 | NewEvent(true,ItemsLog,'7DiscordLog:ItemsLog') 254 | NewEvent(true,MoneyLog,'7DiscordLog:MoneyLog') 255 | NewEvent(true,WeaponLog,'7DiscordLog:WeaponLog') 256 | NewEvent(true,DrugLog,'7DiscordLog:DrugLog') 257 | NewEvent(true,AmbulanceLog,'7DiscordLog:AmbulanceLog') 258 | NewEvent(true,SocietyLog,'7DiscordLog:SocietyLog') 259 | NewEvent(true,AfterRpDeathLog,'7DiscordLog:AfterRpDeathLog') --------------------------------------------------------------------------------