Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ A Menu that:
* Can be opened and closed using E in a clothing shop
* lets you choose from every working model
* lets you fully customise models
* Loads/Saves models to a textfile
* Loads/Saves models to a MySQL database




----------
## Latest change(s)

**My Fork**
* REQUIRES MySQL-Async and EssentialMode Extended
* Added MySQL support instead of .txt file

**Version 3**
* Rebuilt from the ground up
* New UI Modified version of @MrDaGree 's menu
Expand Down
5 changes: 4 additions & 1 deletion clothing/__resource.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ client_scripts {
'config.lua',
}

server_script 'server.lua'
server_scripts {
'@mysql-async/lib/MySQL.lua',
'server.lua'
}
4 changes: 2 additions & 2 deletions clothing/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function accessories(title)
end
end)
Menu.addOption("clothing_accessories", function()
if(Menu.ScrollBarInt("Textures", textureScroller, GetNumberOfPedTextureVariations(GetPlayerPed(-1), componentScroller, subComponentScroller), function(cb) textureScroller = cb end)) then
if(Menu.ScrollBarInt("Textures", textureScroller, GetNumberOfPedPropTextureVariations(GetPlayerPed(-1), componentScroller, subComponentScroller), function(cb) textureScroller = cb end)) then
SetPedPropIndex(GetPlayerPed(-1), componentScroller, subComponentScroller, textureScroller, false)
end
end)
Expand Down Expand Up @@ -372,4 +372,4 @@ AddEventHandler("playerSpawned", function()
else
TriggerServerEvent("clothes:spawn")
end
end)
end)
69 changes: 35 additions & 34 deletions clothing/server.lua
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
models = {}

RegisterServerEvent("clothes:firstspawn")
AddEventHandler("clothes:firstspawn",function()
local source = source
local identifier = getID("steam",source)
print(identifier)
if models[identifier] then
TriggerClientEvent("clothes:spawn", source, models[identifier])
else
local default_models = {1413662315,-781039234,1077785853,2021631368,1423699487,1068876755,2120901815,-106498753,131961260,-1806291497,1641152947,115168927,330231874,-1444213182,1809430156,1822107721,2064532783,-573920724,-782401935,808859815,-1106743555,-1606864033,1004114196,532905404,1699403886,-1656894598,1674107025,-88831029,-1244692252,951767867,1388848350,1090617681,379310561,-569505431,-1332260293,-840346158}
models[identifier] = {
model = default_models[math.random(1,tonumber(#default_models))],
new = true,
clothing = {drawables = {0,0,0,0,0,0,0,0,0,0,0,0},textures = {2,0,1,1,0,0,0,0,0,0,0,0},palette = {0,0,0,0,0,0,0,0,0,0,0,0}},
props = {drawables = {-1,-1,-1,-1,-1,-1,-1,-1}, textures = {-1,-1,-1,-1,-1,-1,-1,-1}},
overlays = {drawables = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, opacity = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, colours = {{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0}}},
}
saveModels()
TriggerClientEvent("clothes:spawn", source, models[identifier])
end
local _source = source
local identifier = getID("steam",_source)
MySQL.Async.fetchAll("SELECT * FROM users WHERE identifier = @identifier", {
['@identifier'] = identifier
},function(result)
local user = result[1]
local skin = user['skin']

if skin == "" or skin == nil then
local default_models = {1413662315,-781039234,1077785853,2021631368,1423699487,1068876755,2120901815,-106498753,131961260,-1806291497,1641152947,115168927,330231874,-1444213182,1809430156,1822107721,2064532783,-573920724,-782401935,808859815,-1106743555,-1606864033,1004114196,532905404,1699403886,-1656894598,1674107025,-88831029,-1244692252,951767867,1388848350,1090617681,379310561,-569505431,-1332260293,-840346158}
models[identifier] = {
model = default_models[math.random(1,tonumber(#default_models))],
new = true,
clothing = {drawables = {0,0,0,0,0,0,0,0,0,0,0,0},textures = {2,0,1,1,0,0,0,0,0,0,0,0},palette = {0,0,0,0,0,0,0,0,0,0,0,0}},
props = {drawables = {-1,-1,-1,-1,-1,-1,-1,-1}, textures = {-1,-1,-1,-1,-1,-1,-1,-1}},
overlays = {drawables = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, opacity = {1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0}, colours = {{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0},{colourType = 0, colour = 0}}},
}
TriggerClientEvent("clothes:spawn", _source, models[identifier])
TriggerEvent("clothes:save", _source, models[identifier])
else
models[identifier] = json.decode(skin)
TriggerClientEvent("clothes:spawn", _source, json.decode(skin))
end
end)
end)

RegisterServerEvent("clothes:spawn")
AddEventHandler("clothes:spawn",function()
local source = source
local identifier = getID("steam",source)
TriggerClientEvent("clothes:spawn", source, models[identifier])
local _source = source
local identifier = getID("steam",_source)
TriggerClientEvent("clothes:spawn", _source, models[identifier])
end)

RegisterServerEvent("clothes:loaded")
Expand All @@ -34,22 +42,17 @@ end)

RegisterServerEvent("clothes:save")
AddEventHandler("clothes:save",function(player_data)
local source = source
local identifier = getID("steam",source)
local _source = source
local identifier = getID("steam",_source)
MySQL.Async.execute("UPDATE users SET skin = @skin WHERE identifier = @identifier", {
['@skin'] = tostring(json.encode(player_data)),
['@identifier'] = identifier
})
models[identifier] = player_data
saveModels()

-- Give weapons etc
end)

function loadModels()
models = LoadResourceFile(GetCurrentResourceName(), "models.txt") or "[]"
models = json.decode(models)
end

function saveModels()
SaveResourceFile(GetCurrentResourceName(), "models.txt", json.encode(models), -1)
end

function getID(type, source)
for k,v in ipairs(GetPlayerIdentifiers(source)) do
if string.sub(tostring(v), 1, string.len("steam:")) == "steam:" and (type == "steam" or type == 1) then
Expand All @@ -62,5 +65,3 @@ function getID(type, source)
end
return nil
end

loadModels()