All pastes #576362 Raw Edit

blaat

public lua v1 · immutable
·published 2007-06-19 13:30 UTC
rendered paste body
--=========================================----====Made by Killer HAHA (aka Robbis_1)====----=========================================---- [[ MACHINEGUN EDITABLE VARIABLES ]] --MG_Accuracy = 10 -- The higher number, the more accrate.MG_RoF = 0.05 -- Rate of Fire.MG_Cooldown = 0.04 -- The cooldown rate.MG_Damage = 4 -- Damage/shot.MG_Overheat = 90 -- When # shots reached this, the MG will get overheated.MG_MaxAmount = 4 -- Max amount of MGs allowed / player.MG_ShowGUI = true -- Set this to false to hide the overheat bar.MG_Model = "models/weapons/w_smg_p90.mdl" -- The model the MGs uses.-- END ---- [[ ROCKET LAUNCHER EDITABLE VARIABLES ]] --Rocket_Spread = 10 -- The lower number, the more accurate.Rocket_Cooldown = 3 -- Cooldown between shotsRocket_Damage = 90 -- The damage (duh).Rocket_MaxAmount = 2 -- Max amount of RLs allowed / player.Rocket_ShowGUI = true -- Set this to false to hide the cooldown bar.Rocket_Model = "models/weapons/w_rocket_launcher.mdl" -- The model the RLs uses.-- END --CrashFix = true -- Set this to  true  if you are having problems with crashes. Will remove the decals.--=========================================----=============MACHINEGUN==============----=========================================---- Do NOT edit under this line unless you know what you are doing --MGTable = {}for i = 1, _MaxPlayers() doMGTable[i] = {}MGTable[i].Toggle = falseMGTable[i].NrMGs = 0MGTable[i].Cooldown = 0MGTable[i].RoF = _CurTime() + MG_RoFMGTable[i].CooldownTime = _CurTime() + MG_CooldownMGTable[i].MachineGuns = {}end-- Machine Gun --function MakeMachineGun(userid)   if MGTable[userid].NrMGs >= MG_MaxAmount then return _PrintMessage(userid, 1, "You have reached the limit!") end   _TraceLine(_PlayerGetShootPos(userid), _PlayerGetShootAng(userid), 100, userid)      MG = _EntCreate("prop_physics")   _EntPrecacheModel(MG_Model)   _EntSetModel(MG, MG_Model)   _EntSetPos(MG, _TraceEndPos())   _EntSetAng(MG, _PlayerGetShootAng(userid))      _EntSpawn(MG)      table.insert(MGTable[userid].MachineGuns, MG)   MGTable[userid].NrMGs = MGTable[userid].NrMGs + 1endCONCOMMAND("mg_spawn", MakeMachineGun)function FireMG(userid)   for k,v in MGTable[userid].MachineGuns do      local SpreadAngle = vecNormalize(vecAdd(_EntGetAng(v),vector3(math.random()/MG_Accuracy,math.random()/MG_Accuracy,math.random()/MG_Accuracy)))      _TraceLine(_EntGetPos(v), SpreadAngle, 4000, v)            _EffectInit()      _EffectSetOrigin( _TraceEndPos() )      _EffectSetStart( _EntGetPos(v) )      _EffectSetScale( 5000 )      _EffectSetMagnitude( 3000 )      _EffectDispatch( "Tracer" )            if not CrashFix then         _MakeDecal(math.random(2,4))      end      --_EntEmitSound(v, "weapons/sg550/sg550-1.wav") -- The old sound      _EntEmitSound(v, "weapons/p90/p90-1.wav")            if _TraceHitNonWorld() then      _TraceAttack(_TraceGetEnt(), userid, userid, MG_Damage)      end   endend-- Toggle All MGs--function ToggleMGs(userid)   if MGTable[userid].Toggle then   MGTable[userid].Toggle = false   else   MGTable[userid].Toggle = true   endendCONCOMMAND("mg_fire", ToggleMGs)-- Main Think Function --function MachineGunThink()--_PrintMessage(1, 4, "Overheat: " .. MGTable[1].Cooldown) -- Debug msg for player 1   for i = 1, _MaxPlayers() do   if not _PlayerInfo(i, "connected") then return end         if MGTable[i].Toggle then -- Is it activated?         if (MGTable[i].Cooldown < MG_Overheat) then -- Is it overheated?            if MGTable[i].RoF < _CurTime() then -- Make sure it got a RoF            FireMG(i) -- Fire!            MGTable[i].Cooldown = MGTable[i].Cooldown + 1 -- Lets count the bullets               if MG_ShowGUI then               UpdateOverheatBar(i)               end            MGTable[i].RoF = _CurTime() + MG_RoF            end         else            if MG_ShowGUI then            UpdateOverheatBar(i)            end         end      else -- Cooldown...         if MGTable[i].CooldownTime < _CurTime() then            if (MGTable[i].Cooldown > 0) then -- Make sure we go to 0 and not lower.            MGTable[i].Cooldown = MGTable[i].Cooldown - 1               if MG_ShowGUI then               UpdateOverheatBar(i)               end            end         MGTable[i].CooldownTime = _CurTime() + MG_Cooldown         end      end   endendAddThinkFunction(MachineGunThink)function UpdateOverheatBar(userid)   local N = MGTable[userid].Cooldown   N = ((N / 1000) * 2)   _GModRect_Start("gmod/white")   _GModRect_SetPos(0.02, 0.8, 0.19, 0.05)   _GModRect_SetColor(0,0,0,128)   _GModRect_SetTime(3, 0, 0)   _GModRect_SetDelay(0)   _GModRect_Send(userid, 8456)      _GModRect_Start("gmod/white")   _GModRect_SetPos(0.025, 0.805, N, 0.04)   _GModRect_SetColor(255,0,0,128)   _GModRect_SetTime(3, 0, 0)   _GModRect_SetDelay(0)   _GModRect_Send(userid, 8457)      _GModText_Start("Default")   _GModText_SetPos(0.06, 0.815)   _GModText_SetColor( 255, 255, 255, 200 )   _GModText_SetTime( 3, 0, 0 )   _GModText_SetText( "Machineguns")   _GModText_SetDelay( 0 )   _GModText_Send(userid, 8458 )end--=========================================----===========ROCKET LAUNCHER===========----=========================================---- Do NOT edit under this line unless you know what you are doing --RocketTable = {}for i = 1, _MaxPlayers() doRocketTable[i] = {}RocketTable[i].Rockets = {}RocketTable[i].NrRLs = 0RocketTable[i].HaveRL = falseRocketTable[i].Cooldown = _CurTime() + Rocket_Cooldownendfunction MakeRocketLauncher(userid)   if RocketTable[userid].NrRLs >= Rocket_MaxAmount then return _PrintMessage(userid, 1, "You have reached the limit!") end   _TraceLine(_PlayerGetShootPos(userid), _PlayerGetShootAng(userid), 100, userid)      RL = _EntCreate("prop_physics")   _EntPrecacheModel(Rocket_Model)   _EntSetModel(RL, Rocket_Model)   _EntSetPos(RL, _TraceEndPos())      _EntSpawn(RL)      table.insert(RocketTable[userid].Rockets, RL)   RocketTable[userid].NrRLs = RocketTable[userid].NrRLs + 1endCONCOMMAND("rl_spawn", MakeRocketLauncher)function FireRocket(userid)   if RocketTable[userid].NrRLs <= 0 then return end   --if not _EntExists(RocketTable[userid].Rocket) then RocketTable[userid].Rocket = nil end   if RocketTable[userid].Cooldown > _CurTime() then return end      for k,v in RocketTable[userid].Rockets do      Rocket = _EntCreate("rpg_missile")            local force = 100 --Force really means velocity here, a simple mistake.      --local barrelLength = 110      local barrelLength = 50      --Only edit the above vars unless you know what you're doing            local maxinaccuracy = math.tan(math.rad(Rocket_Spread / 2)) * force      vecInitSpread = vector3(math.random(1.5 * -1, 1.5), math.random(1.5 * -1, 1.5), math.random(1.5 * -1, 1.5))         inaccuracy_x = math.random(maxinaccuracy * -1, maxinaccuracy)      inaccuracy_y = math.random(maxinaccuracy * -1, maxinaccuracy)      inaccuracy_z = math.random(maxinaccuracy * -1, maxinaccuracy)      vecInaccuracy = vector3(inaccuracy_x, inaccuracy_y, inaccuracy_z)         _EntSetOwner(Rocket, userid);      _EntSetKeyValue(Rocket, "damage", tostring(Rocket_Damage));      _EntEmitSound(v, "npc/env_headcrabcanister/incoming.wav")               _EntSetPos(Rocket, vecAdd(vecAdd(_EntGetPos(v), vecMul(vector3(barrelLength,barrelLength,barrelLength),_EntGetAng(v))), vecInitSpread));      --Above line keeps the projectile from spawning inside the prop      _EntSetAng(Rocket, _EntGetAng(v))      _EntSetVelocity(Rocket, vecAdd(vecMul(_EntGetAng(v), vector3(force, force, force)), vecInaccuracy));            _EntSpawn(Rocket);      _EntSetKeyValue( Rocket, "health", "1000"); -- Dont let the explode eachother.      RocketTable[userid].Cooldown = _CurTime() + 0   endendCONCOMMAND("rl_fire", FireRocket)function RocketThink() -- We only need this for the cooldown bar.. lol   if not Rocket_ShowGUI then return end   for i = 1, _MaxPlayers() do   if not _PlayerInfo(i, "connected") then return end   if RocketTable[i].NrRLs <= 0 then return end -- Make sure he has a RL before showing the bar   ShowCooldown(i)   endendAddThinkFunction(RocketThink)function ShowCooldown(userid)   local R = RocketTable[userid].Cooldown   R = 0.18-(((R - _CurTime()) / 18))   if R >= 0.18 then R = 0.18 end   _GModRect_Start("gmod/white")   _GModRect_SetPos(0.8, 0.8, 0.19, 0.05)   _GModRect_SetColor(0,0,0,128)   _GModRect_SetTime(3, 0, 0)   _GModRect_SetDelay(0)   _GModRect_Send(userid, 7456)      _GModRect_Start("gmod/white");   _GModRect_SetPos(0.805, 0.805, R, 0.04)   _GModRect_SetColor(0,0,255,128)   _GModRect_SetTime(3, 0, 0)   _GModRect_SetDelay(0)   _GModRect_Send(userid, 7457)      _GModText_Start("Default")   _GModText_SetPos(0.82, 0.815)   _GModText_SetColor( 255, 255, 255, 200 )   _GModText_SetTime( 3, 0, 0 )   -- Percentual math by Grumbely --   if math.floor((((1-(RocketTable[userid].Cooldown-_CurTime()))/Rocket_Cooldown)*100) +70) > 100 then   _GModText_SetText( "Rocket Launchers: 100%")-- Don't let it go above 100%   elseif math.floor((((1-(RocketTable[userid].Cooldown-_CurTime()))/Rocket_Cooldown)*100) +70) < 0 then   _GModText_SetText( "Rocket Launchers: 0%")   else   local Maths = (((1-(RocketTable[userid].Cooldown-_CurTime()))/Rocket_Cooldown)*100) +70   _GModText_SetText( "Rocket Launchers: " .. math.floor(Maths) .. "%")   end   -- Percentual math end --   _GModText_SetDelay( 0 )   _GModText_Send(userid, 7458 )endfunction OnRemoval(userid, entity)   for i = 1, _MaxPlayers() do   if not _PlayerInfo(i, "connected") then return end         for k,v in MGTable[i].MachineGuns do         if entity == v then         MGTable[i].NrMGs = MGTable[i].NrMGs - 1         table.remove(MGTable[i].MachineGuns, k)         end      end            for k,v in RocketTable[i].Rockets do         if entity == v then         RocketTable[i].NrRLs = RocketTable[i].NrRLs - 1         table.remove(RocketTable[i].Rockets, k)         end      end   endendHookEvent("onPlayerRemove", OnRemoval)