SHARE
TWEET

Untitled

a guest Aug 23rd, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.     FiveM Scripts
  3.     Copyright C 2018  Sighmir
  4.     This program is free software: you can redistribute it and/or modify
  5.     it under the terms of the GNU Affero General Public License as published
  6.     by the Free Software Foundation, either version 3 of the License, or
  7.     at your option any later version.
  8.     This program is distributed in the hope that it will be useful,
  9.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.     GNU Affero General Public License for more details.
  12.     You should have received a copy of the GNU Affero General Public License
  13.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  14. ]]
  15.  
  16. MySQL = module("vrp_mysql", "MySQL")
  17. local Tunnel = module("vrp", "lib/Tunnel")
  18. local Proxy = module("vrp", "lib/Proxy")
  19.  
  20. vRP = Proxy.getInterface("vRP")
  21. vRPclient = Tunnel.getInterface("vRP","vRP_lscustoms")
  22.  
  23.  
  24. -- vehicle db
  25. MySQL.createCommand("vRP/lscustoms_columns", [[
  26. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS veh_type varchar(255) NOT NULL DEFAULT 'default' ;
  27. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_plate varchar(255) NOT NULL;
  28. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_colorprimary varchar(255) DEFAULT NULL;
  29. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_colorsecondary varchar(255) DEFAULT NULL;
  30. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_pearlescentcolor varchar(255) DEFAULT NULL;
  31. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_wheelcolor varchar(255) DEFAULT NULL;
  32. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_plateindex varchar(255) DEFAULT NULL;
  33. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_neoncolor1 varchar(255) DEFAULT NULL;
  34. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_neoncolor2 varchar(255) DEFAULT NULL;
  35. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_neoncolor3 varchar(255) DEFAULT NULL;
  36. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_windowtint varchar(255) DEFAULT NULL;
  37. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_wheeltype varchar(255) DEFAULT NULL;
  38. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods0 varchar(255) DEFAULT NULL;
  39. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods1 varchar(255) DEFAULT NULL;
  40. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods2 varchar(255) DEFAULT NULL;
  41. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods3 varchar(255) DEFAULT NULL;
  42. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods4 varchar(255) DEFAULT NULL;
  43. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods5 varchar(255) DEFAULT NULL;
  44. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods6 varchar(255) DEFAULT NULL;
  45. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods7 varchar(255) DEFAULT NULL;
  46. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods8 varchar(255) DEFAULT NULL;
  47. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods9 varchar(255) DEFAULT NULL;
  48. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods10 varchar(255) DEFAULT NULL;
  49. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods11 varchar(255) DEFAULT NULL;
  50. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods12 varchar(255) DEFAULT NULL;
  51. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods13 varchar(255) DEFAULT NULL;
  52. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods14 varchar(255) DEFAULT NULL;
  53. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods15 varchar(255) DEFAULT NULL;
  54. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods16 varchar(255) DEFAULT NULL;
  55. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_turbo varchar(255) NOT NULL DEFAULT 'off';
  56. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_tiresmoke varchar(255) NOT NULL DEFAULT 'off';
  57. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_xenon varchar(255) NOT NULL DEFAULT 'off';
  58. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods23 varchar(255) DEFAULT NULL;
  59. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_mods24 varchar(255) DEFAULT NULL;
  60. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_neon0 varchar(255) DEFAULT NULL;
  61. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_neon1 varchar(255) DEFAULT NULL;
  62. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_neon2 varchar(255) DEFAULT NULL;
  63. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_neon3 varchar(255) DEFAULT NULL;
  64. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_bulletproof varchar(255) DEFAULT NULL;
  65. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_smokecolor1 varchar(255) DEFAULT NULL;
  66. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_smokecolor2 varchar(255) DEFAULT NULL;
  67. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_smokecolor3 varchar(255) DEFAULT NULL;
  68. ALTER TABLE vrp_user_vehicles ADD IF NOT EXISTS vehicle_modvariation varchar(255) NOT NULL DEFAULT 'off';
  69. ]])
  70.  
  71. MySQL.createCommand("vRP/ls_customs", "SELECT * FROM vrp_user_vehicles WHERE user_id = @user_id AND vehicle = @vehicle") -- added for lscustoms
  72. MySQL.createCommand("vRP/lsc_get_vehicle","SELECT vehicle FROM vrp_user_vehicles WHERE user_id = @user_id AND vehicle = @vehicle AND vehicle_plate = @plate") -- lscustoms and plygarages
  73. MySQL.createCommand("vRP/lsc_update_vehicle","UPDATE vrp_user_vehicles SET vehicle_plateindex=@plateindex, vehicle_colorprimary=@primarycolor, vehicle_colorsecondary=@secondarycolor, vehicle_pearlescentcolor=@pearlescentcolor, vehicle_wheelcolor=@wheelcolor, vehicle_neoncolor1=@neoncolor1, vehicle_neoncolor2=@neoncolor2, vehicle_neoncolor3=@neoncolor3, vehicle_windowtint=@windowtint, vehicle_wheeltype=@wheeltype, vehicle_mods0=@mods0, vehicle_mods1=@mods1, vehicle_mods2=@mods2, vehicle_mods3=@mods3, vehicle_mods4=@mods4, vehicle_mods5=@mods5, vehicle_mods6=@mods6, vehicle_mods7=@mods7, vehicle_mods8=@mods8, vehicle_mods9=@mods9, vehicle_mods10=@mods10, vehicle_mods11=@mods11, vehicle_mods12=@mods12, vehicle_mods13=@mods13, vehicle_mods14=@mods14, vehicle_mods15=@mods15, vehicle_mods16=@mods16, vehicle_turbo=@turbo, vehicle_tiresmoke=@tiresmoke, vehicle_xenon=@xenon, vehicle_mods23=@mods23, vehicle_mods24=@mods24, vehicle_neon0=@neon0, vehicle_neon1=@neon1, vehicle_neon2=@neon2, vehicle_neon3=@neon3, vehicle_bulletproof=@bulletproof, vehicle_smokecolor1=@smokecolor1, vehicle_smokecolor2=@smokecolor2, vehicle_smokecolor3=@smokecolor3, vehicle_modvariation=@variation WHERE user_id=@user_id AND vehicle=@vehicle")
  74.  
  75. -- init
  76. MySQL.query("vRP/lscustoms_columns")
  77.  
  78. -- LSCUSTOM SERVER LOCKS -- ADD CLIENT POSTION TOO
  79. local tbl = {
  80.     [1] = {locked = false},
  81.     [2] = {locked = false},
  82.     [3] = {locked = false},
  83.     [4] = {locked = false},
  84.     [5] = {locked = false},
  85. }
  86. RegisterServerEvent('lockGarage')
  87. AddEventHandler('lockGarage', function(b,garage)
  88.     tbl[tonumber(garage)].locked = b
  89.     TriggerClientEvent('lockGarage',-1,tbl)
  90.     --print(json.encode(tbl))
  91. end)
  92. RegisterServerEvent('getGarageInfo')
  93. AddEventHandler('getGarageInfo', function()
  94. TriggerClientEvent('lockGarage',-1,tbl)
  95. --print(json.encode(tbl))
  96. end)
  97.  
  98. RegisterServerEvent('lscustoms:payGarage')
  99. AddEventHandler('lscustoms:payGarage', function(button)
  100.   local user_id = vRP.getUserId({source})
  101.   local player = vRP.getUserSource({user_id})
  102.   if button.costs ~= nil then
  103.     if vRP.tryFullPayment({user_id,tonumber(button.costs)}) then
  104.       TriggerClientEvent("lscustoms:buttonSelected", player, button)
  105.     else
  106.       TriggerClientEvent("lscustoms:payGarageFalse", player)
  107.     end
  108.   else
  109.     TriggerClientEvent("lscustoms:buttonSelected", player, button)
  110.   end
  111. end)
  112.  
  113. RegisterServerEvent('lscustoms:UpdateVeh')
  114. AddEventHandler('lscustoms:UpdateVeh', function(vehicle, plate, plateindex, primarycolor, secondarycolor, pearlescentcolor, wheelcolor, neoncolor1, neoncolor2, neoncolor3, windowtint, wheeltype, mods0, mods1, mods2, mods3, mods4, mods5, mods6, mods7, mods8, mods9, mods10, mods11, mods12, mods13, mods14, mods15, mods16, turbo, tiresmoke, xenon, mods23, mods24, neon0, neon1, neon2, neon3, bulletproof, smokecolor1, smokecolor2, smokecolor3, variation)
  115.   local user_id = vRP.getUserId({source})
  116.   local player = vRP.getUserSource({user_id})
  117.   MySQL.query("vRP/lsc_get_vehicle", {user_id = user_id, vehicle = vehicle, plate = plate}, function(rows, affected)
  118.     if #rows > 0 then -- has vehicle
  119.         MySQL.query("vRP/lsc_update_vehicle", {
  120.         user_id = user_id,  
  121.         vehicle = vehicle,  
  122.         plateindex = plateindex,  
  123.         primarycolor = primarycolor,
  124.         secondarycolor = secondarycolor,  
  125.         pearlescentcolor = pearlescentcolor,
  126.         wheelcolor = wheelcolor,
  127.         neoncolor1 = neoncolor1,
  128.         neoncolor2 = neoncolor2,
  129.         neoncolor3 = neoncolor3,
  130.         windowtint = windowtint,
  131.         wheeltype = wheeltype,
  132.         mods0 = mods0,
  133.         mods1 = mods1,
  134.         mods2 = mods2,
  135.         mods3 = mods3,
  136.         mods4 = mods4,
  137.         mods5 = mods5,
  138.         mods6 = mods6,
  139.         mods7 = mods7,
  140.         mods8 = mods8,
  141.         mods9 = mods9,
  142.         mods10 = mods10,
  143.         mods11 = mods11,
  144.         mods12 = mods12,
  145.         mods13 = mods13,
  146.         mods14 = mods14,
  147.         mods15 = mods15,
  148.         mods16 = mods16,
  149.         turbo = turbo,
  150.         tiresmoke = tiresmoke,
  151.         xenon = xenon,
  152.         mods23 = mods23,
  153.         mods24 = mods24,
  154.         neon0 = neon0,
  155.         neon1 = neon1,
  156.         neon2 = neon2,
  157.         neon3 = neon3,
  158.         bulletproof = bulletproof,
  159.         smokecolor1 = smokecolor1,
  160.         smokecolor2 = smokecolor2,
  161.         smokecolor3 = smokecolor3,
  162.         variation = variation})
  163.         TriggerClientEvent('lscustoms:UpdateDone', player)
  164.     else
  165.         TriggerClientEvent('lscustoms:StoreVehicleFalse', player)
  166.     end
  167.   end)
  168. end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top