Advertisement
TheDenVxUA

Untitled

Apr 20th, 2020
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.96 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, 223, 127, 255),
  12.     Color(99, 0, 0, 255),
  13.     Color(64, 64, 64, 255),
  14.     Color(69, 94, 138, 255),
  15.     Color(90, 90, 90, 255),
  16.     Color(127, 111, 63, 255),
  17.     Color(109, 109, 109, 255),
  18.     Color(0, 0, 0, 255),
  19.     Color(0, 0, 0, 255),
  20.     Color(127, 0, 0, 255),
  21.     Color(255, 191, 0, 255),
  22.     Color(72, 72, 72, 255),
  23.     Color(72, 72, 72, 255),
  24.     Color(127, 95, 0, 255),
  25.     Color(200, 200, 200, 255)
  26.     }, -- {Color(127,0,0), Color(0,255)},
  27.     WhiteList = {
  28.     ["priustdm"] = true,
  29.     ["sm_fordmond17"] = true,
  30.     ["chev_impala_09"] = true,
  31.     ["fusionroy"] = true,
  32.     --["transittdm"] = true,
  33.     --["gmc_savana_lw"] = true,
  34.     --["gmc_yukon_lw"] = true,
  35.     --["crsk_chevrolet_caprice_1993"] = true,
  36.     --["speed3tdm"] = true,
  37.     --["chargersrt8tdm"] = true,
  38.     --["priustdm"] = true,
  39.     --["sublegrs90tdm"] = true,
  40.     --["bmw_x5_48i_lw"] = true,
  41.     --["m3e92tdm"] = true,
  42.     --["trueno"] = true
  43.     }, -- {"dk_vehicle", "dk_vehicle3", "blabla"}
  44.  
  45. }
  46.  
  47.  
  48.  
  49. local DVSTable = {}
  50. local dvd = DecentVehicleDestination
  51. local function SpawnDVS()
  52.     local wps = dvd.Waypoints
  53.     if not wps or table.Count(wps) <= 5 then return end
  54.     local amount = GetConVar("dv_spawnamount"):GetInt()
  55.     if amount == 0 then return end
  56.     if table.Count(wps) <= amount then
  57.         amount = math.floor(amount/2)
  58.         error("Too much vehicles to spawn!")
  59.     end
  60.  
  61.     local allowed = {}
  62.     local vehicles = list.Get("Vehicles")
  63.     print("Checking for allowed vehicles...")
  64.     for k, v in pairs(vehicles) do
  65.         if v.Category == "Chairs" or k == "Pod" or k == "Airboat" then print("Skipped boat and seats") continue end
  66.         if not SpawnTableInfo.WhiteList[k] then print("Skipped "..k.." because of whitelist") continue end
  67.         print("Adding", k)
  68.         table.insert(allowed, k)
  69.     end
  70.  
  71.     if #allowed == 0 then
  72.         print("Can't spawn vehicle for DV because there no allowed vehicles")
  73.         print("Check next lines, maybe you wrote something wrong?:")
  74.         print("Vehicle whitelist:", table.concat(SpawnTableInfo.WhiteList, ", "))
  75.         print("END")
  76.         return
  77.     end
  78.  
  79.     for i=1, amount do
  80.         local rand = math.random(1, table.Count(wps))
  81.         while DVSTable[rand] do
  82.             rand = math.random(1, table.Count(wps))
  83.         end
  84.         local waypoint = wps[rand]
  85.  
  86.         local class = allowed[math.random(1, #allowed)]
  87.         local lst = vehicles[class]
  88.  
  89.         local car = ents.Create("prop_vehicle_jeep")
  90.         car:SetModel(lst.Model)
  91.         car:SetPos(waypoint.Target+Vector(0,0,50))
  92.         car:SetAngles(Angle(0,0,0))
  93.         car:SetKeyValue("vehiclescript",lst.KeyValues.vehiclescript)
  94.         car:SetVehicleClass( class )
  95.         car:SetColor(HSVToColor( math.random(0,360), 1, 1 ))
  96.         car:Spawn()
  97.         car:Activate()
  98. if table.Count(SpawnTableInfo.Colors) > 0 then
  99.             MsgC(SpawnTableInfo.Colors[math.random(1, table.Count(SpawnTableInfo.Colors))], "[DecentVehicle Spawner] ", color_white, "Detected colors\n")
  100.             car:SetColor(SpawnTableInfo.Colors[math.random(1, table.Count(SpawnTableInfo.Colors))])
  101.         end
  102.  
  103.         local dv = ents.Create("npc_decentvehicle")
  104.         dv:SetPos(waypoint.Target+Vector(0,0,50))
  105.         dv:Spawn()
  106.  
  107.         DVSTable[rand] = car
  108.  
  109.         print("[DecentVehicle Spawner] Created", class)
  110.     end
  111. end
  112.  
  113. local PlayerJoined
  114. hook.Add("PlayerInitialSpawn", "SpawnDecentVehicles", function()
  115.     if PlayerJoined then return end
  116.     SpawnDVS()
  117.     PlayerJoined = true
  118. end)
  119.  
  120. concommand.Add("dv_respawnvehicles", function()
  121.     for k, ent in pairs(DVSTable) do
  122.         if not IsValid(ent) then continue end
  123.         ent:Remove()
  124.     end
  125.     SpawnDVS()
  126. end)
  127.  
  128. --[[hook.Add( "Decent Vehicle: Drive", "Idle reduction", function( self )
  129. self.v:VC_setHealth(self.v:VC_getHealthMax())
  130. end )]]
  131.  
  132. hook.Add("Decent Vehicle: Drive", "Blablablabl", function(self)
  133. if not self.v.VC_getHealth or not self.v.VC_getHealthMax or not self.v.VC_repairFull_Admin then return end
  134. if self.v:VC_getHealth() <= self.v:VC_getHealthMax() then
  135. self.v:VC_repairFull_Admin()
  136. end
  137. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement