Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.50 KB | None | 0 0
  1. -- CONFIG IS BELOW THIS --
  2. ----------------------------------------------------------------------
  3.  
  4. local function AddVehicle(name, price, class, customcheck, cl_scale, base, tags)
  5. if type(name) == "string" then
  6.  
  7. local veh = list.Get("Vehicles")[class]
  8. if veh == nil then
  9. table.insert(CAR_DISPLAY_CONFIG.FailedVehicles, {
  10. ["name"] = name,
  11. ["price"] = price,
  12. ["class"] = class,
  13. ["tags"] = tags,
  14. ["base"] = base,
  15. ["trace"] = debug.traceback()
  16. })
  17. return
  18. end
  19.  
  20. local index = table.insert(CAR_DISPLAY_CONFIG.Vehicles, {
  21. ["name"] = name,
  22. ["price"] = price,
  23. ["model"] = veh.Model,
  24. ["script"] = veh.KeyValues.vehiclescript,
  25. ["class"] = class,
  26. ["basetype"] = base || "prop_vehicle_jeep",
  27. ["cl_scale"] = cl_scale || .9,
  28. ["customcheck"] = customcheck || function() return true end,
  29. ["allowed_bodygroups"] = {},
  30. ["allowed_colors"] = {},
  31. ["tags"] = tags
  32. })
  33. CAR_DISPLAY_CONFIG.Vehicles[index]["index"] = index
  34.  
  35. elseif type(name) == "table" then
  36.  
  37. local tbl = name
  38. local veh = list.Get("Vehicles")[tbl.class]
  39. tbl.customcheck = tbl.customcheck || function() return true end
  40. if veh == nil then
  41. table.insert(CAR_DISPLAY_CONFIG.FailedVehicles, {
  42. ["name"] = name,
  43. ["price"] = price,
  44. ["class"] = class,
  45. ["tags"] = tags,
  46. ["base"] = base,
  47. ["trace"] = debug.traceback()
  48. })
  49. return
  50. end
  51. local index = table.insert(CAR_DISPLAY_CONFIG.Vehicles, {
  52. ["name"] = tbl.name,
  53. ["price"] = tbl.price,
  54. ["model"] = veh.Model,
  55. ["script"] = veh.KeyValues.vehiclescript,
  56. ["class"] = tbl.class,
  57. ["basetype"] = tbl.base || "prop_vehicle_jeep",
  58. ["cl_scale"] = tbl.cl_scale || .9,
  59. ["customfailmessage"] = tbl.customfailmessage || "You cannot purchase this vehicle!",
  60. ["customcheck"] = function(ply) return tbl.customcheck(ply), tbl.customfailmessage end,
  61. ["tags"] = tbl.tags,
  62. ["allowed_bodygroups"] = tbl.allowed_bodygroups || {},
  63. ["allowed_colors"] = tbl.allowed_colors || {}
  64. })
  65. CAR_DISPLAY_CONFIG.Vehicles[index]["index"] = index
  66.  
  67. end
  68. end
  69.  
  70. ----------------------------------------------------------------------
  71.  
  72. -- Add your custom vehicles below as follows:
  73. -- <Display Name> : This shows up on all the screens when players are browsing cars
  74. -- <Price> : The price the player pays for the car
  75. -- <Vehicle Class> : Unique Identifier for the car, this is normally found in the vehicle script. If not you can just make it up HOWEVER READ THE BRACKETS (MAKE SURE THEIR UNIQUE THOUGH! ALSO THIS IS USED TO FIND THE SPAWNICON WITHOUT ITLL BE PURPLE AND BLACK SQUARES)
  76. -- <Custom Check> <Optional> : Custom wrote function that checks if the player is allowed to spawn the car in, returns two arguments <true/false> <message to display> true to allow the spawn, false to not allow the spawn. Message to show if the spawn was not allowed
  77. -- <Model Scale> <Optional> : Size of the model being displayed on the car pad
  78. -- <Base Entity> <Optional> : Entity used when creating the vehicle, this defaults to "prop_vehicle_jeep" (Afaik most vehicles use this) if yours uses a different set it here
  79. -- <Tags> <Optionals> : Tag the cars and it can be used to filter vehicles in game, cars of the same tag can be displayed together e.g. {"Muscle Car", "Sports", "Government"}
  80. -- <Allowed Bodygroups> <Optional> : Allowed Bodygroups that can be customised on the car
  81. -- <Allowed Colours> <Optional> : Allowed Colours that can be applied to the car
  82. -- Examples below
  83.  
  84. --[[
  85. AddVehicle({
  86. name = "Jeep - HL2",
  87. price = 150000,
  88. class = "Jeep",
  89. customfailmessage = "You are not a donator!",
  90. customcheck = function(ply) return table.HasValue(ply:GetUserGroup(), {"VIP", "Donator"}),
  91. cl_scale = .2,
  92. base = "prop_vehicle_jeep",
  93. tags = {"Sports"},
  94. allowed_bodygroups = {
  95. ["wing"] = true
  96. },
  97. allowed_colors = {
  98. ["Emerald"] = true,
  99. ["Dark Blue"] = true,
  100. ["Wetasphalt"] = true,
  101. }
  102. })
  103. ]]--
  104. ----------------------------------------------------------------------
  105. function CarDisplay_LoadConfig()
  106.  
  107. -- Example Vehicles, all default to gmod :)
  108. --[[
  109. Generated using: DarkRP | Vehicle Generator
  110. https://csite.io/tools/gmod-darkrp-vehicle
  111. --]]
  112. DarkRP.createVehicle({
  113. name = "Audi R8",
  114. model = "audir8tdm",
  115. price = 850000,
  116. label = "Audi R8",
  117. category = "sport"
  118. })
  119. -- USE THIS FOR TESTING ALL YOUR SERVERS CARS (May not function on some servers)
  120. --[[for k,v in pairs(list.Get("Vehicles")) do
  121. AddVehicle(v.Name, 1000, k, function() return true end, 1, v.Class)
  122. end--]]
  123. end
  124. ------------------------------------------------------------------------
  125.  
  126. CAR_DISPLAY_CONFIG.SellPercent = .2 -- Percent of the cars value that should be given back to the player when they sell it.
  127. CAR_DISPLAY_CONFIG.BuyPercent = .1 -- Percent of the cars original value should be charged when they want to change the colour or bodygroups
  128. CAR_DISPLAY_CONFIG.MaxSpawnedVehicles = 2 -- The max allowed vehicles a player is allowed out at any one time.
  129.  
  130. ------------------------------------------------------------------------
  131.  
  132. CAR_DISPLAY_CONFIG.CarColors = { // Default Car Colours
  133. ["Red"] = Color(255,0,0),
  134. ["White"] = Color(255,255,255),
  135. ["Blue"] = Color(0,0,255),
  136. ["Green"] = Color(0,255,0),
  137. ["Grey"] = Color(120,120,120),
  138. ["Black-Grey"] = Color(32,32,32),
  139. ["Black"] = Color(0,0,0),
  140. ["Yellow"] = Color(241,196,15),
  141. ["Light Blue"] = Color(52, 152, 219),
  142. ["Midnight Blue"] = Color(44, 62, 80),
  143. ["Azure"] = Color(240,255,255),
  144. ["Pink"] = Color(255,122,142),
  145. ["Cyan"] = Color(0,255,255),
  146. ["Dark Blue"] = Color(0,0,139),
  147. ["Forest Green"] = Color(34,139,34),
  148. ["Turquoise"] = Color(26,188,156),
  149. ["Emerald"] = Color(46,204,113),
  150. ["Jade Sea"] = Color(22,160,133),
  151. ["Nephritis"] = Color(39,174,96),
  152. ["Peter River"] = Color(52,152,219),
  153. ["Belizehole"] = Color(41,128,185),
  154. ["Amethyst"] = Color(155,89,182),
  155. ["Wisteria"] = Color(142,68,173),
  156. ["Wetasphalt"] = Color(52,73,94),
  157. ["Sunflower"] = Color(241,196,15),
  158. ["Carrot"] = Color(230,126,34),
  159. ["Orange"] = Color(243,156,18),
  160. ["Pumpkin"] = Color(211,84,0),
  161. ["Alizarin"] = Color(231,76,60),
  162. ["Pomegrnate"] = Color(192,57,43),
  163. ["Silver"] = Color(189,195,199),
  164. ["Asbestos"] = Color(127,140,141),
  165. ["Concrete"] = Color(149,165,166),
  166. ["Crimson"] = Color(189,8,28),
  167. ["Scarlet"] = Color(255,36,0),
  168. ["Gold"] = Color(255,215,0),
  169. ["Bronze"] = Color(205,127,50)
  170. }
  171.  
  172. ---------------------------------------------------------------------
  173. if SERVER then
  174. AddCSLuaFile("lib/sh_language.lua")
  175. include("lib/sh_language.lua")
  176. else
  177. include("lib/sh_language.lua")
  178. end
  179.  
  180. CAR_DISPLAY_CONFIG.Language = "EN" --built in languages (EN = English, FR = French, RU = Russian) Need some more translations to do a few more phrases for
  181. -- If you're interested in hepling out send me a message on SF or Steam, thanks
  182.  
  183.  
  184. ---------------------------------------------------------------------------
  185.  
  186. --------------------------------------------------------------------------
  187. --[[
  188. - How do I make the entities stay on server restart?
  189.  
  190. My addon does not feature its own save feature, instead we use this feature which is prebuilt into Sandbox which DarkRP uses as a base.
  191. You position all of your entities in game and once positioned correctly. Open the context menu (Hold C),
  192. right click on the entity you want to keep and click "Make Persistent". This will make the "world" he owner of the entity now
  193. and will respawn next server restart.
  194. --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement