Advertisement
TheDenVxUA

Untitled

Apr 20th, 2020
485
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.54 KB | None | 0 0
  1. --[[CreateConVar( "dv_spawnamount", "10", FCVAR_ARCHIVE, "How much DV to spawn?" )
  2. CreateConVar( "dv_spawnrestrictcat", "", FCVAR_ARCHIVE, "Write here name of category you want to spawn vehicles" )
  3. CreateConVar( "dv_whitelistVehicle", "trueno crsk_chevrolet_caprice_1993 chev_tahoe_lw merc_sprinter_boxtruck_lw", FCVAR_ARCHIVE, "Write here classes of cars to spawn.Example: 'dk_vehicle1 dv_vehicle2 vehicle3 veh4 kek lol'")
  4. CreateConVar( "dv_colors", '[ {"r":127.0,"g":111.0,"b":63.0,"a":255.0}, {"r":109,"g":109.0,"b":109.0,"a":255.0}, {"r":0,"g":0.0,"b":0.0,"a":255.0}, {"r":255,"g":0.0,"b":0.0,"a":255.0}, {"r":255,"g":191.0,"b":0.0,"a":255.0}, {"r":200,"g":200.0,"b":200.0,"a":255.0}, {"r":191,"g":255.0,"b":127.0,"a":255.0}, {"r":127,"g":95.0,"b":0.0,"a":255.0}, {"r":72,"g":72.0,"b":72.0,"a":255.0} ]', FCVAR_ARCHIVE, "Write here name of category you want to spawn vehicles" )
  5. ]]
  6.  
  7. CreateConVar( "dv_spawnamount", "10", FCVAR_ARCHIVE, "How much DV to spawn?" )
  8.  
  9. local SpawnTableInfo = {
  10.     Colors = {
  11.     Color(255, 255, 255, 255),
  12.     --[[Color(255, 223, 127, 255),
  13.     Color(99, 0, 0, 255),
  14.     Color(64, 64, 64, 255),
  15.     Color(69, 94, 138, 255),
  16.     Color(90, 90, 90, 255),
  17.     Color(127, 111, 63, 255),
  18.     Color(109, 109, 109, 255),
  19.     Color(0, 0, 0, 255),
  20.     Color(0, 0, 0, 255),
  21.     Color(127, 0, 0, 255),
  22.     Color(255, 191, 0, 255),
  23.     Color(72, 72, 72, 255),
  24.     Color(72, 72, 72, 255),
  25.     Color(127, 95, 0, 255),
  26.     Color(200, 200, 200, 255)]]
  27.     }, -- {Color(127,0,0), Color(0,255)},
  28.     WhiteList = {
  29.     ["forney_consumer_aspire"] = true,
  30.     ["forney_consumer_explorer"] = true,
  31.     ["forney_consumer_explorereb"] = true,
  32.     ["forney_consumer_sunfire"] = true,
  33.     ["forney_consumer_voyager"] = true,
  34.     ["forney_consumer_maxima"] = true,
  35.     ["forney_consumer_sierra"] = true,
  36.     ["forney_consumer_canopy"] = true,
  37.     --["priustdm"] = true,
  38.     --["sm_fordmond17"] = true,
  39.     --["chev_impala_09"] = true,
  40.     --["fusionroy"] = true,
  41.     --["transittdm"] = true,
  42.     --["gmc_savana_lw"] = true,
  43.     --["gmc_yukon_lw"] = true,
  44.     --["crsk_chevrolet_caprice_1993"] = true,
  45.     --["speed3tdm"] = true,
  46.     --["chargersrt8tdm"] = true,
  47.     --["priustdm"] = true,
  48.     --["sublegrs90tdm"] = true,
  49.     --["bmw_x5_48i_lw"] = true,
  50.     --["m3e92tdm"] = true,
  51.     --["trueno"] = true
  52.     }, -- {"dk_vehicle", "dk_vehicle3", "blabla"}
  53.  
  54. }
  55.  
  56.  
  57.  
  58. local DVSTable = {}
  59. local dvd = DecentVehicleDestination
  60. local function SpawnDVS()
  61.     local wps = dvd.Waypoints
  62.     if not wps or table.Count(wps) <= 5 then return end
  63.     local amount = GetConVar("dv_spawnamount"):GetInt()
  64.     if amount == 0 then return end
  65.     if table.Count(wps) <= amount then
  66.         amount = math.floor(amount/2)
  67.         error("Too much vehicles to spawn!")
  68.     end
  69.  
  70.     local allowed = {}
  71.     local vehicles = list.Get("Vehicles")
  72.     print("Checking for allowed vehicles...")
  73.     for k, v in pairs(vehicles) do
  74.         if v.Category == "Chairs" or k == "Pod" or k == "Airboat" then print("Skipped boat and seats") continue end
  75.         if not SpawnTableInfo.WhiteList[k] then print("Skipped "..k.." because of whitelist") continue end
  76.         print("Adding", k)
  77.         table.insert(allowed, k)
  78.     end
  79.  
  80.     if #allowed == 0 then
  81.         print("Can't spawn vehicle for DV because there no allowed vehicles")
  82.         print("Check next lines, maybe you wrote something wrong?:")
  83.         print("Vehicle whitelist:", table.concat(SpawnTableInfo.WhiteList, ", "))
  84.         print("END")
  85.         return
  86.     end
  87.  
  88.     for i=1, amount do
  89.         local rand = math.random(1, table.Count(wps))
  90.         while DVSTable[rand] do
  91.             rand = math.random(1, table.Count(wps))
  92.         end
  93.         local waypoint = wps[rand]
  94.  
  95.         local class = allowed[math.random(1, #allowed)]
  96.         local lst = vehicles[class]
  97.  
  98.         local car = ents.Create("prop_vehicle_jeep")
  99.         car:SetModel(lst.Model)
  100.         car:SetBodyGroups = {
  101.     { 0, 0 }, -- Body
  102.     { 1, 1 }, -- Wheels
  103.     { 2, 1 }, -- clamped1
  104.     { 3, 0 }, -- clamped2
  105.     { 4, 0 }, -- clamped3
  106.     { 5, 0 }, -- clamped4
  107.     { 6, 0 }, -- clamped5
  108. }
  109.         car:SetSkin( math.random( 0, car:SkinCount() ) )
  110.         car:SetPos(waypoint.Target+Vector(0,0,50))
  111.         car:SetAngles(Angle(0,0,0))
  112.         car:SetKeyValue("vehiclescript",lst.KeyValues.vehiclescript)
  113.         car:SetVehicleClass( class )
  114.         car:SetColor(HSVToColor( math.random(0,360), 1, 1 ))
  115.         car:Spawn()
  116.         car:Activate()
  117. if table.Count(SpawnTableInfo.Colors) > 0 then
  118.             MsgC(SpawnTableInfo.Colors[math.random(1, table.Count(SpawnTableInfo.Colors))], "[DecentVehicle Spawner] ", color_white, "Detected colors\n")
  119.             car:SetColor(SpawnTableInfo.Colors[math.random(1, table.Count(SpawnTableInfo.Colors))])
  120.         end
  121.  
  122.         local dv = ents.Create("npc_decentvehicle")
  123.         dv:SetPos(waypoint.Target+Vector(0,0,50))
  124.         dv:Spawn()
  125.  
  126.         DVSTable[rand] = car
  127.  
  128.         print("[DecentVehicle Spawner] Created", class)
  129.     end
  130. end
  131.  
  132. local PlayerJoined
  133. hook.Add("PlayerInitialSpawn", "SpawnDecentVehicles", function()
  134.     if PlayerJoined then return end
  135.     SpawnDVS()
  136.     PlayerJoined = true
  137. end)
  138.  
  139. concommand.Add("dv_respawnvehicles", function()
  140.     for k, ent in pairs(DVSTable) do
  141.         if not IsValid(ent) then continue end
  142.         ent:Remove()
  143.     end
  144.     SpawnDVS()
  145. end)
  146.  
  147. --[[hook.Add( "Decent Vehicle: Drive", "Idle reduction", function( self )
  148. self.v:VC_setHealth(self.v:VC_getHealthMax())
  149. end )]]
  150.  
  151. hook.Add("Decent Vehicle: Drive", "Blablablabl", function(self)
  152. if not self.v.VC_getHealth or not self.v.VC_getHealthMax or not self.v.VC_repairFull_Admin then return end
  153. if self.v:VC_getHealth() <= self.v:VC_getHealthMax() then
  154. self.v:VC_repairFull_Admin()
  155. end
  156. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement