Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. -- vRP framework
  2. local Tunnel = module("vrp", "lib/Tunnel")
  3. local Proxy = module("vrp", "lib/Proxy")
  4. local MySQL = module("vrp_mysql", "lib/MySQL/MySQL")
  5.  
  6. local sql = MySQL.open("127.0.0.1","vRP","1202","vrp") -- EDIT these values to the values of your sql servers
  7.  
  8. vRP = Proxy.getInterface("vRP") --call the server-side API functions, get the vRP interface.
  9. vRPclient = Tunnel.getInterface("vRP","lscustoms") -- Tunnel access client to vRP with unique id
  10.  
  11. local tbl = {
  12. [1] = {locked = false},
  13. [2] = {locked = false},
  14. [3] = {locked = false},
  15. [4] = {locked = false},
  16. }
  17. local paymentInfo = {}
  18.  
  19. RegisterServerEvent('lockGarage')
  20. AddEventHandler('lockGarage', function(b,garage)
  21. tbl[tonumber(garage)].locked = b
  22. TriggerClientEvent('lockGarage',-1,tbl)
  23. print(json.encode(tbl))
  24. end)
  25.  
  26. RegisterServerEvent('getGarageInfo')
  27. AddEventHandler('getGarageInfo', function()
  28. TriggerClientEvent('lockGarage',-1,tbl)
  29. print(json.encode(tbl))
  30. end)
  31.  
  32. RegisterServerEvent('UpdateVeh')
  33. AddEventHandler('UpdateVeh', function(plate, primarycolor, secondarycolor, pearlescentcolor, wheelcolor, mods)
  34.  
  35. local mods = mods
  36. local primarycolor = primarycolor
  37. local secondarycolor = secondarycolor
  38. local pearlescentcolor = pearlescentcolor
  39. local wheelcolor = wheelcolor
  40. local carid = string.sub(plate,7)
  41. print(carid)
  42. if primarycolor then
  43. q_update = sql:prepare("update vrp_user_vehicles set vehicle_colorprimary ='".. primarycolor .."' where car_id='".. carid .."'")
  44. q_update:execute()
  45. end
  46. if secondarycolor then
  47. q_update = sql:prepare("update vrp_user_vehicles set vehicle_colorsecondary ='".. secondarycolor .."' where car_id='".. carid .."'")
  48. q_update:execute()
  49. end
  50. if pearlescentcolor then
  51. q_update = sql:prepare("update vrp_user_vehicles set vehicle_pearlescentcolor ='".. pearlescentcolor .."' where car_id='".. carid .."'")
  52. q_update:execute()
  53. end
  54. if wheelcolor then
  55. q_update = sql:prepare("update vrp_user_vehicles set vehicle_wheelcolor ='".. wheelcolor .."' where car_id='".. carid .."'")
  56. q_update:execute()
  57. end
  58.  
  59. for i,t in pairs(mods) do
  60. print('Attempting to update mods')
  61. if t.mod ~= nil then
  62. print("Mod#: "..i.." Value: " .. t.mod)
  63. local q_update = sql:prepare("update vrp_user_vehicles set mod"..i.." = '"..t.mod.."' where car_id='"..carid.."'")
  64. q_update:execute()
  65. end
  66. end
  67. end)
  68.  
  69. -- Payment Events
  70. RegisterServerEvent('receivePaymentInfo')
  71. AddEventHandler('receivePaymentInfo', function(modPrice)
  72. local user_id = vRP.getUserId({source}, function(user_id) return user_id end)
  73. local wallet = vRP.getMoney({user_id})
  74. local nWallet = wallet - modPrice
  75. local paidAmount = vRP.tryPayment({user_id, modPrice})
  76. local blockPurchase = false
  77.  
  78. print("Player ID :" .. user_id .. " | Price : " .. modPrice .. " | Wallet : " .. wallet .. " | New Wallet : " .. nWallet) -- DEBUG message for jink
  79.  
  80. if paidAmount then
  81. vRP.tryPayment({user_id, modPrice})
  82. vRPclient.notify(user_id,{"Thanks for your purchase!"})
  83. print("Debited" .. modPrice)
  84. elseif not paidAmount then
  85. local blockPurchase = not blockPurchase
  86. vvRPclient.notify(user_id,{"Unsuccessful purchase!"})
  87. TriggerClientEvent('blockPurchase', blockPurchase)
  88. print("Payment not successful")
  89. end
  90.  
  91. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement