├── BLClothingItems ├── ClothingItems.sql ├── Client.lua ├── Server.lua ├── fxmanifest.lua └── Config.lua └── README.md /BLClothingItems/ClothingItems.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `user` 2 | ADD IF NOT EXISTS `clothes` VARCHAR(60) DEFAULT NULL 3 | ; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BLClothingItems 2 | Simple Script for doing outfits as items! 3 | 4 | **Tested, working** 5 | 6 | Update: Added a command /changeback that will allow you to go back to your last used clothing, and return the item to your inventory. 7 | 8 | e.x: apply outfit item, use command /changeback, puts back your standard saved clothing, and gives you item back. 9 | 10 | 11 | You will need to know what number each item is for the clothing. You can either just guess until you find the correct number, or use something like Vmenu or other clothing selector scripts to find the number associated with each piece. 12 | 13 | Don't forget to add the item name to your database for use. The item will be removed on use. You can stop it from being deleted by removing the xPlayer.removeInventoryItem line in server.lua. 14 | 15 | It's not impossible to "save" a used item for clothing, then as you put on a new outfit, it gives you back the old one. 16 | -------------------------------------------------------------------------------- /BLClothingItems/Client.lua: -------------------------------------------------------------------------------- 1 | ESX = nil 2 | 3 | setupEsx = function() 4 | while not ESX do 5 | TriggerEvent("esx:getSharedObject", function(obj) ESX = obj end) 6 | Wait(100) 7 | end 8 | while not ESX.IsPlayerLoaded() do Wait(1000) end 9 | end 10 | 11 | updateClothing = function() 12 | local playerPed = GetPlayerPed(-1) 13 | ESX.TriggerServerCallback('BLClothingItems:GetClothes', function(outfitname) for i = 1, #Config do if Config[i].itemName == outfitname then for k, v in pairs(Config[i].set) do SetPedComponentVariation(playerPed, v.c1, v.c2, v.c3, 0) end end end end) 14 | end 15 | 16 | RegisterNetEvent('BLClothingItems') 17 | AddEventHandler('BLClothingItems', function(number, label) 18 | local playerPed = GetPlayerPed(-1) 19 | for k, v in pairs(Config[number].set) do SetPedComponentVariation(playerPed, v.c1, v.c2, v.c3, 0) end 20 | ESX.ShowNotification("You've put on " .. label) 21 | end) 22 | 23 | Citizen.CreateThread(function() 24 | setupEsx() 25 | updateClothing() 26 | end) 27 | 28 | RegisterCommand('changeback', function() 29 | TriggerEvent('skinchanger:getSkin', function(skin) 30 | if skin == nil then 31 | print("Skin wasn't loaded properly from esx_skin. Report error to Developer Team.") 32 | else 33 | TriggerServerEvent('BLClothingItems:reset') 34 | TriggerEvent('skinchanger:loadSkin', skin) 35 | end 36 | end) 37 | end) 38 | -------------------------------------------------------------------------------- /BLClothingItems/Server.lua: -------------------------------------------------------------------------------- 1 | ESX = nil 2 | 3 | local ClothesList = {} 4 | TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) 5 | 6 | function RegisterClothes() 7 | for i = 1, #Config do 8 | ESX.RegisterUsableItem(Config[i].itemName, function(source) 9 | local xPlayer = ESX.GetPlayerFromId(source) 10 | xPlayer.removeInventoryItem(Config[i].itemName, 1) 11 | TriggerClientEvent('BLClothingItems', source, i, Config[i].label) 12 | updateClothes(Config[i].itemName, source) 13 | end) 14 | end 15 | end 16 | 17 | Citizen.CreateThread(function() 18 | while not ESX do Wait(0) end 19 | RegisterClothes() 20 | print('Items are loaded! Thank you for using BL Clothing Items') 21 | readClothes() 22 | end) 23 | 24 | readClothes = function() MySQL.Async.fetchAll('SELECT * FROM users', {}, function(result) for k, v in pairs(result) do if v.clothing then ClothesList[v.identifier] = v.clothing end end end) end 25 | 26 | updateClothes = function(outfit, src) 27 | local xPlayer = ESX.GetPlayerFromId(src) 28 | local ident = xPlayer.getIdentifier() 29 | if ClothesList[ident] then xPlayer.addInventoryItem(ClothesList[ident], 1) end 30 | ClothesList[ident] = outfit 31 | MySQL.Async.execute('UPDATE users SET clothes = @clothes WHERE identifier = @identifier', { 32 | ['clothes'] = outfit, 33 | ['identifier'] = ident, 34 | }) 35 | end 36 | 37 | ESX.RegisterServerCallback('BLClothingItems:GetClothes', function(source, cb) 38 | local xPlayer = ESX.GetPlayerFromId(source) 39 | cb(ClothesList[xPlayer.getIdentifier()]) 40 | end) 41 | 42 | RegisterCommand('deleteoutfit', function(source, args) 43 | local xPlayer = ESX.GetPlayerFromId(source) 44 | local ident = xPlayer.getIdentifier() 45 | if ClothesList[ident] then 46 | ClothesList[ident] = nil 47 | MySQL.Async.execute('UPDATE users SET clothes = NULL WHERE identifier = @identifier', { 48 | ['identifier'] = ident, 49 | }) 50 | end 51 | end) 52 | 53 | RegisterNetEvent('BLClothingItems:reset') 54 | AddEventHandler('BLClothingItems:reset', function() 55 | local src = source 56 | local xPlayer = ESX.GetPlayerFromId(src) 57 | local ident = xPlayer.getIdentifier() 58 | if ClothesList[ident] then 59 | xPlayer.addInventoryItem(ClothesList[ident], 1) 60 | Citizen.Wait(100) 61 | ClothesList[ident] = nil 62 | Citizen.Wait(100) 63 | MySQL.Async.execute('UPDATE users SET clothes = NULL WHERE identifier = @identifier', { 64 | ['identifier'] = ident, 65 | }) 66 | end 67 | end) 68 | -------------------------------------------------------------------------------- /BLClothingItems/fxmanifest.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 3 | ─██████──────────██████─████████████████──────██████████████───██████─────────██████──██████─██████████████─██████████████─██████████████████─ 4 | ─██░░██████████████░░██─██░░░░░░░░░░░░██──────██░░░░░░░░░░██───██░░██─────────██░░██──██░░██─██░░░░░░░░░░██─██░░░░░░░░░░██─██░░░░░░░░░░░░░░██─ 5 | ─██░░░░░░░░░░░░░░░░░░██─██░░████████░░██──────██░░██████░░██───██░░██─────────██░░██──██░░██─██░░██████████─██░░██████████─████████████░░░░██─ 6 | ─██░░██████░░██████░░██─██░░██────██░░██──────██░░██──██░░██───██░░██─────────██░░██──██░░██─██░░██─────────██░░██─────────────────████░░████─ 7 | ─██░░██──██░░██──██░░██─██░░████████░░██──────██░░██████░░████─██░░██─────────██░░██──██░░██─██░░██████████─██░░██████████───────████░░████─── 8 | ─██░░██──██░░██──██░░██─██░░░░░░░░░░░░██──────██░░░░░░░░░░░░██─██░░██─────────██░░██──██░░██─██░░░░░░░░░░██─██░░░░░░░░░░██─────████░░████───── 9 | ─██░░██──██████──██░░██─██░░██████░░████──────██░░████████░░██─██░░██─────────██░░██──██░░██─██░░██████████─██░░██████████───████░░████─────── 10 | ─██░░██──────────██░░██─██░░██──██░░██────────██░░██────██░░██─██░░██─────────██░░██──██░░██─██░░██─────────██░░██─────────████░░████───────── 11 | ─██░░██──────────██░░██─██░░██──██░░██████────██░░████████░░██─██░░██████████─██░░██████░░██─██░░██─────────██░░██─────────██░░░░████████████─ 12 | ─██░░██──────────██░░██─██░░██──██░░░░░░██────██░░░░░░░░░░░░██─██░░░░░░░░░░██─██░░░░░░░░░░██─██░░██─────────██░░██─────────██░░░░░░░░░░░░░░██─ 13 | ─██████──────────██████─██████──██████████────████████████████─██████████████─██████████████─██████─────────██████─────────██████████████████─ 14 | ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 15 | ]] 16 | 17 | -- #################################################################################### 18 | -- # DISCORD: # 19 | -- # https://discord.gg/QPPSBncbZn # 20 | -- #################################################################################### 21 | 22 | fx_version 'cerulean' 23 | game 'gta5' 24 | 25 | lua54 'yes' 26 | 27 | author 'Mr Bluffz' 28 | description 'Clothing Items' 29 | version '1.1.0' 30 | 31 | client_scripts {'Config.lua', '@es_extended/locale.lua', 'Locales/*.lua', 'Client.lua'} 32 | 33 | server_scripts {'@mysql-async/lib/MySQL.lua', '@es_extended/locale.lua', 'Locales/*.lua', 'Config.lua', 'Server.lua'} 34 | 35 | escrow_ignore {'Locales/*.lua', 'Config.lua', 'Server.lua', 'Client.lua'} 36 | -------------------------------------------------------------------------------- /BLClothingItems/Config.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 3 | ─██████──────────██████─████████████████──────██████████████───██████─────────██████──██████─██████████████─██████████████─██████████████████─ 4 | ─██░░██████████████░░██─██░░░░░░░░░░░░██──────██░░░░░░░░░░██───██░░██─────────██░░██──██░░██─██░░░░░░░░░░██─██░░░░░░░░░░██─██░░░░░░░░░░░░░░██─ 5 | ─██░░░░░░░░░░░░░░░░░░██─██░░████████░░██──────██░░██████░░██───██░░██─────────██░░██──██░░██─██░░██████████─██░░██████████─████████████░░░░██─ 6 | ─██░░██████░░██████░░██─██░░██────██░░██──────██░░██──██░░██───██░░██─────────██░░██──██░░██─██░░██─────────██░░██─────────────────████░░████─ 7 | ─██░░██──██░░██──██░░██─██░░████████░░██──────██░░██████░░████─██░░██─────────██░░██──██░░██─██░░██████████─██░░██████████───────████░░████─── 8 | ─██░░██──██░░██──██░░██─██░░░░░░░░░░░░██──────██░░░░░░░░░░░░██─██░░██─────────██░░██──██░░██─██░░░░░░░░░░██─██░░░░░░░░░░██─────████░░████───── 9 | ─██░░██──██████──██░░██─██░░██████░░████──────██░░████████░░██─██░░██─────────██░░██──██░░██─██░░██████████─██░░██████████───████░░████─────── 10 | ─██░░██──────────██░░██─██░░██──██░░██────────██░░██────██░░██─██░░██─────────██░░██──██░░██─██░░██─────────██░░██─────────████░░████───────── 11 | ─██░░██──────────██░░██─██░░██──██░░██████────██░░████████░░██─██░░██████████─██░░██████░░██─██░░██─────────██░░██─────────██░░░░████████████─ 12 | ─██░░██──────────██░░██─██░░██──██░░░░░░██────██░░░░░░░░░░░░██─██░░░░░░░░░░██─██░░░░░░░░░░██─██░░██─────────██░░██─────────██░░░░░░░░░░░░░░██─ 13 | ─██████──────────██████─██████──██████████────████████████████─██████████████─██████████████─██████─────────██████─────────██████████████████─ 14 | ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 15 | ]] 16 | 17 | -- #################################################################################### 18 | -- # DISCORD: # 19 | -- # https://discord.gg/QPPSBncbZn # 20 | -- #################################################################################### 21 | 22 | Config = { 23 | [1] = { 24 | set = { 25 | face = { 26 | c1 = 0, -- Component ID 0: Face\ 1: Mask\ 2: Hair\ 3: Torso\ 4: Leg\ 5: Parachute / bag\ 6: Shoes\ 7: Accessory\ 8: Undershirt\ 9: Kevlar\ 10: Badge\ 11: Torso 2 27 | c2 = 2, -- Which # within the category 28 | c3 = 3, -- Which color variation of c2 29 | }, 30 | mask = { 31 | c1 = 1, -- Component ID 0: Face\ 1: Mask\ 2: Hair\ 3: Torso\ 4: Leg\ 5: Parachute / bag\ 6: Shoes\ 7: Accessory\ 8: Undershirt\ 9: Kevlar\ 10: Badge\ 11: Torso 2 32 | c2 = 2, -- Which # within the category 33 | c3 = 3, -- Which color variation of c2 34 | }, 35 | torso = { 36 | c1 = 3, -- Component ID 0: Face\ 1: Mask\ 2: Hair\ 3: Torso\ 4: Leg\ 5: Parachute / bag\ 6: Shoes\ 7: Accessory\ 8: Undershirt\ 9: Kevlar\ 10: Badge\ 11: Torso 2 37 | c2 = 2, -- Which # within the category 38 | c3 = 3, -- Which color variation of c2 39 | }, 40 | leg = { 41 | c1 = 4, -- Component ID 0: Face\ 1: Mask\ 2: Hair\ 3: Torso\ 4: Leg\ 5: Parachute / bag\ 6: Shoes\ 7: Accessory\ 8: Undershirt\ 9: Kevlar\ 10: Badge\ 11: Torso 2 42 | c2 = 2, -- Which # within the category 43 | c3 = 3, -- Which color variation of c2 44 | }, 45 | shoes = { 46 | c1 = 6, -- Component ID 0: Face\ 1: Mask\ 2: Hair\ 3: Torso\ 4: Leg\ 5: Parachute / bag\ 6: Shoes\ 7: Accessory\ 8: Undershirt\ 9: Kevlar\ 10: Badge\ 11: Torso 2 47 | c2 = 2, -- Which # within the category 48 | c3 = 3, -- Which color variation of c2 49 | }, 50 | -- Add more pieces to the outfit here! copy past here. 51 | }, 52 | itemName = 'outfit1', -- Item name in your database 53 | label = 'Fancy Outfit', -- Only used for notification. 54 | }, 55 | 56 | [2] = { -- Each time you make a new outfit, copy/paste this entire block and make sure the number goes up by one. 57 | set = { 58 | face = { 59 | c1 = 0, -- Component ID 0: Face\ 1: Mask\ 2: Hair\ 3: Torso\ 4: Leg\ 5: Parachute / bag\ 6: Shoes\ 7: Accessory\ 8: Undershirt\ 9: Kevlar\ 10: Badge\ 11: Torso 2 60 | c2 = 2, -- Which # within the category 61 | c3 = 3, -- Which color variation of c2 62 | }, 63 | mask = { 64 | c1 = 1, -- Component ID 0: Face\ 1: Mask\ 2: Hair\ 3: Torso\ 4: Leg\ 5: Parachute / bag\ 6: Shoes\ 7: Accessory\ 8: Undershirt\ 9: Kevlar\ 10: Badge\ 11: Torso 2 65 | c2 = 2, -- Which # within the category 66 | c3 = 3, -- Which color variation of c2 67 | }, 68 | torso = { 69 | c1 = 3, -- Component ID 0: Face\ 1: Mask\ 2: Hair\ 3: Torso\ 4: Leg\ 5: Parachute / bag\ 6: Shoes\ 7: Accessory\ 8: Undershirt\ 9: Kevlar\ 10: Badge\ 11: Torso 2 70 | c2 = 2, -- Which # within the category 71 | c3 = 3, -- Which color variation of c2 72 | }, 73 | leg = { 74 | c1 = 4, -- Component ID 0: Face\ 1: Mask\ 2: Hair\ 3: Torso\ 4: Leg\ 5: Parachute / bag\ 6: Shoes\ 7: Accessory\ 8: Undershirt\ 9: Kevlar\ 10: Badge\ 11: Torso 2 75 | c2 = 2, -- Which # within the category 76 | c3 = 3, -- Which color variation of c2 77 | }, 78 | shoes = { 79 | c1 = 6, -- Component ID 0: Face\ 1: Mask\ 2: Hair\ 3: Torso\ 4: Leg\ 5: Parachute / bag\ 6: Shoes\ 7: Accessory\ 8: Undershirt\ 9: Kevlar\ 10: Badge\ 11: Torso 2 80 | c2 = 2, -- Which # within the category 81 | c3 = 3, -- Which color variation of c2 82 | }, 83 | -- Add more pieces to the outfit here! copy past here. 84 | }, 85 | itemName = 'outfit2', -- Item name in your database 86 | label = 'Fancy Outfit #2', -- Only used for notification. 87 | }, 88 | } 89 | --------------------------------------------------------------------------------