Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function giveColumnName(collection, valueId)
- local res = nil
- local id = tonumber(valueId)
- if (collection == "component") then
- if (id == 0) then
- res = "face"
- end
- if (id == 1) then
- res = "mask"
- end
- if (id == 2) then
- res = "hair"
- end
- if (id == 3) then
- res = "gloves"
- end
- if (id == 4) then
- res = "pants"
- end
- if (id == 5) then
- res = "bag"
- end
- if (id == 6) then
- res = "shoes"
- end
- if (id == 8) then
- res = "shirt"
- end
- if (id == 9) then
- res = "vest"
- end
- if (id == 11) then
- res = "jacket"
- end
- else
- if (collection == "prop") then
- if (id == 0) then
- res = "hat"
- end
- if (id == 1) then
- res = "glasses"
- end
- if (id == 2) then
- res = "ears"
- end
- end
- end
- return res
- end
- RegisterServerEvent("clothing_shop:SpawnPlayer_server")
- AddEventHandler("clothing_shop:SpawnPlayer_server", function()
- local source = source
- TriggerEvent('es:getPlayerFromId', source, function(user)
- TriggerEvent('weaponshop:GiveWeaponsToPlayer', source)
- local player = user.getIdentifier()
- MySQL.Async.fetchAll("SELECT isFirstConnection FROM users WHERE identifier = @username", {['@username'] = player}, function(result)
- if(result)then
- if (result[1].isFirstConnection == 1) then
- MySQL.Async.execute("INSERT INTO user_clothes(identifier) VALUES ('@identifier')",{['@identifier']=player})
- MySQL.Async.execute("UPDATE users SET isFirstConnection = 0 WHERE identifier = '@username'", {['@username'] = player})
- MySQL.Async.fetchAll("SELECT * FROM user_clothes WHERE identifier = @username", {['@username'] = player}, function(result1)
- if(result1) then
- TriggerClientEvent("clothing_shop:loadItems_client", source, {result[1].face,result[1].face_texture,result[1].hair,result[1].hair_texture,result[1].shirt,result[1].shirt_texture,result[1].pants,result[1].pants_texture,result[1].shoes,result[1].shoes_texture,result[1].vest,result[1].vest_texture,result[1].bag,result[1].bag_texture,result[1].hat,result[1].hat_texture,result[1].mask,result[1].mask_texture,result[1].glasses,result[1].glasses_texture,result[1].gloves,result[1].gloves_texture,result[1].jacket,result[1].jacket_texture,result[1].ears,result[1].ears_texture})
- end
- end)
- end
- end
- end)
- MySQL.Async.fetchAll("SELECT * FROM user_clothes WHERE identifier = @username", {['@username'] = player}, function(result2)
- if(result2) then
- TriggerClientEvent("clothing_shop:loadItems_client", source, {result[1].face,result[1].face_texture,result[1].hair,result[1].hair_texture,result[1].shirt,result[1].shirt_texture,result[1].pants,result[1].pants_texture,result[1].shoes,result[1].shoes_texture,result[1].vest,result[1].vest_texture,result[1].bag,result[1].bag_texture,result[1].hat,result[1].hat_texture,result[1].mask,result[1].mask_texture,result[1].glasses,result[1].glasses_texture,result[1].gloves,result[1].gloves_texture,result[1].jacket,result[1].jacket_texture,result[1].ears,result[1].ears_texture})
- end
- end)
- end)
- end)
- RegisterServerEvent("clothing_shop:SetItems_server")
- AddEventHandler("clothing_shop:SetItems_servers",function()
- local source = source
- TriggerEvent('es:getPlayerFromId', source, function(user)
- local player = user.getIdentifier()
- MySQL.Async.fetchAll("SELECT * FROM user_clothes WHERE identifier = @username", {['@username'] = player}, function(result)
- if(result) then
- TriggerClientEvent("clothing_shop:loadItems_client", source, {result[1].face,result[1].face_texture,result[1].hair,result[1].hair_texture,result[1].shirt,result[1].shirt_texture,result[1].pants,result[1].pants_texture,result[1].shoes,result[1].shoes_texture,result[1].vest,result[1].vest_texture,result[1].bag,result[1].bag_texture,result[1].hat,result[1].hat_texture,result[1].mask,result[1].mask_texture,result[1].glasses,result[1].glasses_texture,result[1].gloves,result[1].gloves_texture,result[1].jacket,result[1].jacket_texture,result[1].ears,result[1].ears_texture})
- end
- end)
- end)
- end)
- RegisterServerEvent("clothing_shop:SaveItem_server")
- AddEventHandler("clothing_shop:SaveItem_server", function(item, values)
- local source = source
- TriggerEvent('es:getPlayerFromId', source, function(user)
- local name = giveColumnName(item.collection, item.id)
- if (name == "skin") then
- MySQL.Async.execute("UPDATE user_clothes SET skin = '@value' WHERE identifier = '@identifier'",{
- ['@value'] = values.value,
- ['@identifier'] = user.getIdentifier()
- }
- )
- else
- MySQL.Async.execute("UPDATE user_clothes SET ".. name .." = '@value', ".. name..'_texture' .." = '@texture_value' WHERE identifier = '@identifier'",{
- ['@value'] = values.value,
- ['@texture_value'] = values.texture_value,
- ['@identifier'] = user.getIdentifier()
- }
- )
- end
- TriggerClientEvent("es_freeroam:notify", source, "CHAR_SOCIAL_CLUB", 1, "Binco Shop", false, "You bought a new item!")
- end)
- end)
- RegisterServerEvent("clothing_shop:WithDraw_server")
- AddEventHandler("clothing_shop:WithDraw_server",function(item, values)
- local source = source
- TriggerEvent('es:getPlayerFromId', source, function(user)
- MySQL.Async.fetchAll("SELECT money FROM users WHERE identifier = '@identifier'", {['@identifier'] = user.getIdentifier()}, function(money)
- if money[1] then
- TriggerClientEvent("clothing_shop:buyItem_client", source, {item=item, values=values, money=money})
- end
- end)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement