Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. local connection = exports['mta_connection']:getConnection()
  2.  
  3. function buyVehicle(player, modellID, r, g, b, money, jelenVeh)
  4. if isElement(player) then
  5. if (tonumber(player:getData("char:money") or 0) >= tonumber(money)) then
  6. local myCars = 0
  7. for _, value in ipairs(getElementsByType("vehicle")) do
  8. if value:getData("veh:owner") == player:getData("acc:id") then
  9. myCars = myCars+1
  10. end
  11. end
  12.  
  13. if tonumber(myCars) < tonumber(player:getData("char:vehSlot")) then
  14. x,y,z = 2256.7829589844, -1116.6042480469, 48.75
  15. local carshopPos = {
  16. {2135.1296386719, -1146.6275634766, 24.613170623779},
  17. {2135.3054199219, -1138.3544921875, 25.508316040039},
  18. {2135.8127441406, -1129.4816894531, 25.634937286377},
  19. {2120.1853027344, -1126.1196289063, 25.40358543396},
  20. {2119.8137207031, -1135.6446533203, 25.232713699341},
  21. {2118.9714355469, -1147.2834472656, 24.354309082031},
  22. {2117.9084472656, -1156.5870361328, 24.24542427063},
  23. }
  24.  
  25. local randed = math.random(1, #carshopPos)
  26. local pos = toJSON({carshopPos[randed][1], carshopPos[randed][2], carshopPos[randed][3], 0 ,0})
  27.  
  28. local insterT = dbQuery(connection, "INSERT INTO vehicle SET pos=?,model=?,owner=?,color=?, fuel=?",
  29. pos,modellID,getElementData(player,"acc:id"),toJSON({r, g, b, 0, 0, 0}), 10)
  30.  
  31. local QueryEredmeny, _, Beszurid = dbPoll(insterT, -1)
  32. if QueryEredmeny then
  33. exports["mta_vehicle"]:addVehicle(getElementData(player,"acc:id"), modellID, carshopPos[randed][1], carshopPos[randed][2], carshopPos[randed][3], Beszurid, r, g, b)
  34. triggerClientEvent(player,"returnVasarlas",player,Beszurid)
  35. dbExec(connection,"UPDATE characters SET money = ? WHERE id = ?", player:getData("char:money")-money, getElementData(player,"acc:id"))
  36. player:setData("char:money",player:getData("char:money")-money)
  37. exports.mta_item:giveItem(player, 34, Beszurid, 1,0)
  38. end
  39. else
  40. outputChatBox("#7cc576[ExternalGaming - Carshop] #ffffffNincs elég #F7CA18'Slotod'#ffffff a vásárláshoz.",player,255,255,255,true)
  41. end
  42. else
  43. outputChatBox("#7cc576[ExternalGaming - Carshop] #ffffffNincs elég #87D37C'Kézpénzed'#ffffff a vásárláshoz.",player,255,255,255,true)
  44. end
  45. end
  46. end
  47. addEvent("buyVehicleSever", true)
  48. addEventHandler("buyVehicleSever", root, buyVehicle)
  49.  
  50. function buyVehiclePP(player, modellID, r, g, b, money, jelenVeh)
  51. if isElement(player) then
  52. if (tonumber(player:getData("char:pp")) >= tonumber(money)) then
  53. local myCars = 0
  54. for _, value in ipairs(getElementsByType("vehicle")) do
  55. if value:getData("veh:owner") == player:getData("acc:id") then
  56. myCars = myCars+1
  57. end
  58. end
  59.  
  60. if tonumber(myCars) < tonumber(player:getData("char:vehSlot")) then
  61. x,y,z = 2255.8427734375, -1125.1579589844, 48.75
  62. --player:setData("char:pp",player:getData("char:pp") - money)
  63. local pos = toJSON({x,y,z, 0 ,0})
  64.  
  65. local insterT = dbQuery(connection, "INSERT INTO vehicle SET pos=?,model=?,owner=?,color=?, fuel=?",
  66. pos,modellID,getElementData(player,"acc:id"),toJSON({r, g, b, 0, 0, 0}), 10)
  67.  
  68. local QueryEredmeny, _, Beszurid = dbPoll(insterT, -1)
  69. if QueryEredmeny then
  70. exports["mta_vehicle"]:addVehicle(getElementData(player,"acc:id"), modellID, x, y, z, Beszurid, r, g, b)
  71. triggerClientEvent(player,"returnVasarlas",player,Beszurid)
  72. dbExec(connection,"UPDATE characters SET premiumpont = ? WHERE id = ?", player:getData("char:pp")-money, getElementData(player,"acc:id"))
  73. player:setData("char:pp",player:getData("char:pp") - money)
  74. exports.mta_item:giveItem(player, 34, Beszurid, 1,0)
  75. end
  76. else
  77. outputChatBox("#7cc576[ExternalGaming - Carshop] #ffffffNincs elég #F7CA18'Slotod'#ffffff a vásárláshoz.",player,255,255,255,true)
  78. end
  79. else
  80. outputChatBox("#7cc576[ExternalGaming - Carshop] #ffffffNincs elég #19B5FE'PrémiumPontot'#ffffff a vásárláshoz.",player,255,255,255,true)
  81. end
  82. end
  83. end
  84. addEvent("buyVehiclePPSever", true)
  85. addEventHandler("buyVehiclePPSever", root, buyVehiclePP)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement