Advertisement
Guest User

Loadout E2 for scrubs (By Decline)

a guest
Sep 15th, 2018
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.95 KB | None | 0 0
  1. @name Loadout (Pleb)
  2. @persist Preset:string CW:array M9K:array IsAlive MyBox:entity NeedToSpawnBox
  3. if(first()) {
  4.     runOnLast(1)
  5.     runOnWeaponSwitch(1)
  6.     Preset = "cw" #Takes "cw" or "m9k"
  7.     #Example weapon array below
  8.     #M9K = array("weapon_medkit","m9k_acr","m9k_ak47","m9k_g36","m9k_aw50")
  9.     CW = array("Put","your","weapons","here")
  10.     M9K = array("Put","your","weapons","here")
  11.    
  12.     #Who needs entSpawn anyway?
  13.     function void initBox() {
  14.         concmd("gm_spawnsent cw_ammo_crate_regular")
  15.         findByClass("cw_ammo_crate_regular")
  16.         MyBox = findClosest(owner():aimPos())
  17.         NeedToSpawnBox = 0
  18.     }
  19.     function void findBoxes() {
  20.         findByClass("cw_ammo_crate_regular")
  21.         local Boxes = findToArray()
  22.         if(Boxes:count() > 0) {
  23.             MyBox = Boxes[1,entity]
  24.             NeedToSpawnBox = 0
  25.         }
  26.         else {
  27.             NeedToSpawnBox = 1
  28.         }
  29.     }
  30. }
  31. IsAlive = owner():isAlive()
  32.  
  33. # I love this next piece. <3
  34.  
  35. #Timer to find cw ammo crates
  36. timer("findbox",10000)
  37. if(clk("findbox") | first() & Preset:lower() == "cw") {
  38.     findBoxes()
  39. }
  40.  
  41. #If it can't find a crate, we want to spawn a crate
  42. # when the conditions are right for the owner
  43. if(NeedToSpawnBox & Preset:lower() == "cw") {
  44.    if(owner():vel():length() <= 5) {
  45.        local Dist = owner():pos():distance(owner():aimPos())
  46.        if(Dist > 25 & Dist < 1500) {
  47.            initBox()
  48.        }
  49.    }
  50. }
  51. #If it can find your box, then it'll make thse invisible so nobody messes with your box,
  52. # and it doesn't get in anyones way
  53. #I also don't want to make someone elses box invisible because I'm nice.
  54. if(MyBox:isValid() & MyBox:owner() == owner()) {
  55.    if(MyBox:getAlpha() != 0) {
  56.        MyBox:setAlpha(0)
  57.        noCollideAll(MyBox,1)
  58.    }
  59. }
  60.  
  61.  
  62.  
  63. #Giving weapons on spawn here
  64. if($IsAlive == 1) {
  65.    if(Preset:lower() == "cw") {
  66.        local Str = ""
  67.        for(I=1,CW:count()) {
  68.            Str = Str+"gm_giveswep "+CW[I,string]+";"
  69.        }
  70.        concmd(Str)
  71.    }
  72.    elseif(Preset:lower() == "m9k") {
  73.        local Str = ""
  74.        for(I=1,M9K:count()) {
  75.            Str = Str+"gm_giveswep "+M9K[I,string]+";"
  76.        }
  77.        concmd(Str)
  78.    }
  79. }
  80. #This part isn't supposed to be legible, I feel bad if you're trying to read this.
  81. #Getting more cw ammo automatically
  82. if(Preset:lower() == "cw") {
  83.    local CurWep = owner():weapon():type():explode("_")
  84.    if(CurWep[1,string] ==  "cw") {
  85.        if(owner():weapon():primaryAmmoType() == ".338 Lapua") {
  86.            if(owner():ammoCount(owner():weapon():primaryAmmoType()) < 30) {
  87.                MyBox:use()
  88.            }
  89.        }
  90.        else {
  91.            if(owner():ammoCount(owner():weapon():primaryAmmoType()) < 150) {
  92.                MyBox:use()
  93.            }
  94.        }  
  95.    }
  96. }
  97. timer("gimmeammo",1000)
  98.  
  99. #hit me up if you want me to make this legible.
  100. #Getting more m9k ammo automatically
  101. if(Preset:lower() == "m9k") {
  102.    local CurWep = owner():weapon():type():explode("_")
  103.    if(CurWep[1,string] == "m9k") {
  104.        if(clk("gimmeammo")) {
  105.            if(owner():ammoCount(owner():weapon():primaryAmmoType()) < 200 & owner():weapon():primaryAmmoType() != "SniperPenetratedRound") {
  106.                local AmmoType = owner():weapon():primaryAmmoType()
  107.                if(AmmoType == "AR2")  {
  108.                        concmd("gm_spawnsent m9k_ammo_ar2")
  109.                        findByClass("m9k_ammo_ar2")
  110.                        local Box = findClosest(owner():aimPos())
  111.                        Box:use()
  112.                }
  113.            }
  114.            elseif(owner():ammoCount(owner():weapon():primaryAmmoType()) <= 50 & owner():weapon():primaryAmmoType() == "SniperPenetratedRound") {
  115.                concmd("gm_spawnsent m9k_ammo_sniper_rounds")
  116.                findByClass("m9k_ammo_sniper_rounds")
  117.                local Box = findClosest(owner():aimPos())
  118.                Box:use()
  119.            }
  120.        }
  121.    }
  122. }
  123.  
  124. interval(300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement