CapsAdmin

Untitled

Mar 28th, 2011
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.94 KB | None | 0 0
  1. easylua.Start(Ply"oh") -- this is just a helper thing so you have vars like "me" in the script which is yourself
  2.  
  3. local SWEP = {Primary = {}, Secondary = {}}
  4. SWEP.ClassName = "toybox_owner_gun"
  5. SWEP.Base = "weapon_base"
  6. do --random toybox swep
  7. SWEP.ViewModelFlip = false
  8. SWEP.Category = "ownage";
  9. SWEP.Author = "SOD:Reaper";
  10. SWEP.Contact = "";
  11. SWEP.Purpose = "";
  12. SWEP.Instructions = "";
  13. SWEP.PrintName = "Owner_pwnage_Gun";
  14. SWEP.Slot = 1;
  15. SWEP.SlotPos = 1;
  16. SWEP.DrawCrosshair = true;
  17. SWEP.DrawAmmo = true;
  18. SWEP.ViewModel = "models/weapons/v_irifle.mdl";
  19. SWEP.WorldModel = "models/weapons/w_physcannon.mdl";
  20. SWEP.ViewModelFOV = 70;
  21. SWEP.ReloadSound = "weapons/smg1/smg1_reload.wav";
  22. SWEP.HoldType = "ar2";
  23. SWEP.Spawnable = true;
  24. SWEP.AdminSpawnable = true;
  25. SWEP.Weight = 10;
  26. SWEP.AutoSwitchTo = false;
  27. SWEP.AutoSwitchFrom = true;
  28. SWEP.FiresUnderwater = true;
  29.  
  30. SWEP.Primary.Zap = false;
  31. SWEP.Primary.ZapRadius = 15000;
  32. SWEP.Primary.ZapDamage = 3000000000;
  33. SWEP.Primary.RPG = false
  34. SWEP.Primary.RPGType = "bazooka_round"
  35. SWEP.Primary.Sound = "weapons/physcannon/superphys_launch1.wav"
  36. SWEP.Primary.Tracer = 1;
  37. SWEP.Primary.Automatic = true;
  38. SWEP.Primary.Force = 1000000000;
  39. SWEP.Primary.FireFromHip = true;
  40. SWEP.Primary.Weld = false;
  41. SWEP.Primary.Ammo = "ar2";
  42. SWEP.Primary.ExplosionShot = false;
  43. SWEP.Primary.BulletShot = true;
  44. SWEP.Primary.ModelShot = false;
  45. SWEP.Primary.BreakAll = false;
  46. SWEP.Primary.Ignite = false;
  47. SWEP.Primary.ClipSize = 100;
  48. SWEP.Primary.DefaultClip = 100;
  49. SWEP.Primary.Recoil = 0;
  50. SWEP.Primary.Damage = 1000000;
  51. SWEP.Primary.NumberofShots = 10;
  52. SWEP.Primary.Spread = 0.1;
  53. SWEP.Primary.Delay = 0.0001;
  54. SWEP.Primary.Model = "models/props_c17/FurnitureChair001a.mdl";
  55. SWEP.Primary.ExplosionSound = "weapon_AWP.Single";
  56. SWEP.Primary.ExplosionSoundDistance = 4000;
  57. SWEP.Primary.ExplosionSize = 1750;
  58. SWEP.Primary.TakeAmmo = 0;
  59.  
  60. SWEP.Secondary.RPG = false
  61. SWEP.Secondary.RPGType = "bazooka_round"
  62. SWEP.Secondary.Sound = "weapons/mortar/mortar_fire1.wav"
  63. SWEP.Secondary.Tracer = 1;
  64. SWEP.Secondary.Force = 100;
  65. SWEP.Secondary.Automatic = false;
  66. SWEP.Secondary.FireFromHip = true;
  67. SWEP.Secondary.Weld = false;
  68. SWEP.Secondary.ExplosionShot = true;
  69. SWEP.Secondary.BulletShot = false;
  70. SWEP.Secondary.ModelShot = false;
  71. SWEP.Secondary.BreakAll = true;
  72. SWEP.Secondary.Zap = false;
  73. SWEP.Secondary.ZapRadius = 1500;
  74. SWEP.Secondary.ZapDamage = 30000;
  75. SWEP.Secondary.Ignite = true;
  76. SWEP.Secondary.Recoil = 0;
  77. SWEP.Secondary.Spread = 0.1;
  78. SWEP.Secondary.Delay = 0.01;
  79. SWEP.Secondary.Automatic = true;
  80. SWEP.Secondary.Sound = "weapons/mortar/mortar_fire1.wav";
  81. SWEP.Secondary.TakeAmmo = 0;
  82. SWEP.Secondary.Model = "models/props_c17/FurnitureChair001a.mdl";
  83. SWEP.Secondary.ExplosionSound = "weapon_AWP.Single";
  84. SWEP.Secondary.ExplosionSoundDistance = 400;
  85. SWEP.Secondary.ExplosionSize = 175;
  86.  
  87. function SWEP:Initialize()
  88.     util.PrecacheSound(self.Primary.Sound);
  89.     util.PrecacheSound(self.Secondary.Sound);
  90.     if ( SERVER ) then
  91.        self:SetWeaponHoldType( self.HoldType );
  92.    end
  93. end
  94.  
  95. function SWEP:PrimaryAttack()
  96.    if ( !self:CanPrimaryAttack() ) then return end
  97.  
  98. //Default stuff, normally used in any condition.
  99.    local tr = self.Owner:GetEyeTrace();
  100.    self.Weapon:EmitSound ( self.Primary.Sound );
  101.    self:ShootEffects();
  102.    self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay );
  103.    self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay );   self:TakePrimaryAmmo(self.Primary.TakeAmmo);
  104.    local rnda = -self.Primary.Recoil;
  105.    local rndb = self.Primary.Recoil * math.random(-1, 1);
  106.    self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) );
  107.  
  108. //The attack mode, can vary from the user settings
  109.     if ( self.Primary.ModelShot ) then
  110.     if (!SERVER) then return end;
  111.     local ent = ents.Create ("prop_physics");
  112.     ent:SetModel ( self.Primary.Model );
  113.     if ( self.Primary.FireFromHip ) then
  114.         ent:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 32));
  115.     else
  116.         ent:SetPos (tr.HitPos + self.Owner:GetAimVector() * -16);
  117.     end
  118.     ent:SetAngles (self.Owner:EyeAngles());
  119.     ent:Spawn();
  120.     local phys = ent:GetPhysicsObject();
  121.     local shot_length = tr.HitPos:Length();
  122.     if ( self.Primary.Weld ) then
  123.         local weld = constraint.Weld( tr.Entity, ent, tr.PhysicsBone, 0, 0 );
  124.     end
  125.     phys:ApplyForceCenter (self.Owner:GetAimVector():GetNormalized() * math.pow (shot_length, 3));
  126.     cleanup.Add (self.Owner, "props", ent);
  127.     undo.Create ("Thrown model");
  128.     undo.AddEntity (ent);
  129.     undo.SetPlayer (self.Owner);
  130.     undo.Finish();
  131. end    if ( self.Primary.BulletShot ) then
  132.         local bullet = {};
  133.         bullet.Num = self.Primary.NumberofShots;
  134.         bullet.Src = self.Owner:GetShootPos();
  135.         bullet.Dir = self.Owner:GetAimVector();
  136.         bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0);
  137.         bullet.Tracer = self.Primary.Tracer;
  138.         bullet.Force = self.Primary.Force;
  139.         bullet.Damage = self.Primary.Damage;
  140.         bullet.AmmoType = self.Primary.Ammo;
  141.         self.Owner:FireBullets( bullet );
  142.     end
  143.    if ( self.Primary.ExplosionShot ) then
  144.        local explode = ents.Create( "env_explosion" );
  145.        explode:SetPos( tr.HitPos );
  146.        explode:SetOwner( self.Owner );
  147.        explode:Spawn();
  148.        explode:SetKeyValue( "iMagnitude", self.Primary.ExplosionSize );
  149.        explode:Fire( "Explode", 0, 0 );
  150.        explode:EmitSound( self.Primary.ExplosionSound, self.Primary.ExplosionSoundDistance, self.Primary.ExplosionSoundDistance );
  151.     end
  152.     if ( self.Primary.BreakAll ) then
  153.         if( tr.Entity:IsValid() and tr.Entity:GetClass() == "prop_physics" ) then
  154.             constraint.RemoveAll( tr.Entity );
  155.             local physobject = tr.Entity:GetPhysicsObject();
  156.             physobject:EnableMotion( true );
  157.             physobject:SetVelocity( self.Owner:GetAimVector() * 2 );
  158.         end
  159.     end
  160. if ( self.Primary.Zap ) then
  161.    local vaporize = ents.Create ( "point_hurt" )
  162.    vaporize:SetKeyValue ( "DamageRadius", self.Primary.ZapRadius )
  163.    vaporize:SetKeyValue ( "Damage" , self.Primary.ZapDamage )
  164.    vaporize:SetKeyValue ( "DamageDelay", 0 )
  165.    vaporize:SetKeyValue ( "DamageType" ,"67108864" )
  166.    vaporize:SetPos ( tr.HitPos )
  167.    vaporize:Fire ( "TurnOn" , "", 0 )
  168.    vaporize:Fire ( "TurnOff" , "", 0.5 )
  169. end
  170. if ( self.Primary.RPG ) then
  171.     local shotpos = self.Owner:GetShootPos()
  172.     shotpos = shotpos + self.Owner:GetForward() * 0
  173.     shotpos = shotpos + self.Owner:GetRight() * 10
  174.     shotpos = shotpos + self.Owner:GetUp() * -6
  175.     local rocket = ents.Create("hl2_rocket")
  176.     if (ValidEntity(rocket)) then
  177.         rocket:SetPos(shotpos)
  178.         rocket:SetOwner(self.Owner)
  179.      rocket:Spawn()
  180.     rocket.Owner = self.Owner
  181. local TF2Rocket = ents.Create("prop_dynamic")
  182.     if (ValidEntity(TF2Rocket)) then
  183.     TF2Rocket:SetPos(shotpos)
  184.     TF2Rocket:SetModel( "models/weapons/w_missile.mdl" )
  185.     TF2Rocket:Spawn()
  186.    TF2Rocket:SetParent(rocket)
  187. end
  188.  
  189.     local b = ents.Create( "info_target" )
  190.     if (ValidEntity(b)) then
  191.     b:SetPos( self.Owner:GetEyeTrace( ).HitPos + Vector(0,0,0))
  192.     b:Spawn( )
  193.     rocket:PointAtEntity( b )
  194.     b:Remove( )
  195. end
  196. end
  197. end
  198.     if ( self.Primary.Ignite ) then
  199.         if (!tr.Entity) then return false end
  200.         if (!tr.Entity:IsValid() ) then return false end
  201.         if (tr.Entity:IsPlayer()) then return false end
  202.         if (tr.Entity:IsWorld()) then return false end
  203.         if ( CLIENT ) then return true end
  204.         local Time = math.random(20);
  205.         tr.Entity:Extinguish();
  206.         tr.Entity:Ignite( Time, 0 );
  207.     end
  208.  
  209. end
  210.  
  211. function SWEP:SecondaryAttack()
  212.    if ( !self:CanPrimaryAttack() ) then return end
  213.  
  214. //Default stuff, normally used in any condition.
  215.    local tr = self.Owner:GetEyeTrace();
  216.    self.Weapon:EmitSound ( self.Secondary.Sound );
  217.    self:ShootEffects();
  218.    self.Weapon:SetNextPrimaryFire( CurTime() + self.Secondary.Delay );
  219.    self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay );
  220.    self:TakePrimaryAmmo(self.Secondary.TakeAmmo);
  221.    local rnda = -self.Secondary.Recoil;
  222.    local rndb = self.Secondary.Recoil * math.random(-1, 1);
  223.    self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) );
  224.  
  225. //The attack mode, can vary from the user settings
  226. if ( self.Secondary.ModelShot ) then
  227.     if (!SERVER) then return end
  228.     local ent = ents.Create ("prop_physics");
  229.     ent:SetModel ( self.Secondary.Model );
  230.     if ( self.Secondary.FireFromHip ) then
  231.         ent:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 32));
  232.     else
  233.         ent:SetPos (tr.HitPos + self.Owner:GetAimVector() * -16);
  234.     end
  235.     ent:SetAngles (self.Owner:EyeAngles());
  236.     ent:Spawn();
  237.     local phys = ent:GetPhysicsObject();
  238.     local shot_length = tr.HitPos:Length();
  239.     if ( self.Secondary.Weld ) then
  240.         local weld = constraint.Weld( tr.Entity, ent, tr.PhysicsBone, 0, 0 );
  241.     end
  242.     phys:ApplyForceCenter (self.Owner:GetAimVector():GetNormalized() * math.pow (shot_length, 3));
  243.     cleanup.Add (self.Owner, "props", ent);
  244.     undo.Create ("Thrown model");
  245.     undo.AddEntity (ent);
  246.     undo.SetPlayer (self.Owner);
  247.     undo.Finish();
  248. end     if (self.Secondary.BulletShot ) then
  249.    local bullet = {};
  250.        bullet.Num = self.Secondary.NumberofShots;
  251.        bullet.Src = self.Owner:GetShootPos();
  252.        bullet.Dir = self.Owner:GetAimVector();
  253.        bullet.Spread = Vector( self.Secondary.Spread * 0.1 , self.Secondary.Spread * 0.1, 0);
  254.        bullet.Tracer = self.Secondary.Tracer;
  255.        bullet.Force = self.Secondary.Force;
  256.        bullet.Damage = self.Secondary.Damage;
  257.        bullet.AmmoType = self.Primary.Ammo;
  258.    self.Owner:FireBullets( bullet );
  259. end
  260. if ( self.Secondary.Zap ) then
  261.    local vaporize = ents.Create ( "point_hurt" )
  262.    vaporize:SetKeyValue ( "DamageRadius", self.Secondary.ZapRadius )
  263.    vaporize:SetKeyValue ( "Damage" , self.Secondary.ZapDamage )
  264.    vaporize:SetKeyValue ( "DamageDelay", 0 )
  265.    vaporize:SetKeyValue ( "DamageType" ,"67108864" )
  266.    vaporize:SetPos ( tr.HitPos )
  267.    vaporize:Fire ( "TurnOn" , "", 0 )
  268.    vaporize:Fire ( "TurnOff" , "", 0.5 )
  269. end
  270. if ( self.Secondary.ExplosionShot ) then
  271.    local explode = ents.Create( "env_explosion" );
  272.    explode:SetPos( tr.HitPos );
  273.    explode:SetOwner( self.Owner );
  274.    explode:Spawn();
  275.    explode:SetKeyValue( "iMagnitude", self.Secondary.ExplosionSize );
  276.    explode:Fire( "Explode", 0, 0 );
  277.    explode:EmitSound( self.Secondary.ExplosionSound, self.Secondary.ExplosionSoundDistance, self.Secondary.ExplosionSoundDistance );
  278. end
  279.    if ( self.Secondary.BreakAll ) then
  280.        if( tr.Entity:IsValid() and tr.Entity:GetClass() == "prop_physics" ) then
  281.            constraint.RemoveAll( tr.Entity );
  282.            local physobject = tr.Entity:GetPhysicsObject();
  283.            physobject:EnableMotion( true );
  284.            physobject:SetVelocity( self.Owner:GetAimVector() * 2 );
  285.        end
  286.    end
  287.     if ( self.Secondary.RPG ) then
  288.     local shotpos = self.Owner:GetShootPos()
  289.     shotpos = shotpos + self.Owner:GetForward() * 0
  290.     shotpos = shotpos + self.Owner:GetRight() * 10
  291.     shotpos = shotpos + self.Owner:GetUp() * -6
  292.     local rocket = ents.Create("hl2_rocket")
  293.     if (ValidEntity(rocket)) then
  294.         rocket:SetPos(shotpos)
  295.         rocket:SetOwner(self.Owner)
  296.      rocket:Spawn()
  297.     rocket.Owner = self.Owner
  298. local TF2Rocket = ents.Create("prop_dynamic")
  299.     if (ValidEntity(TF2Rocket)) then
  300.     TF2Rocket:SetPos(shotpos)
  301.     TF2Rocket:SetModel( "models/weapons/w_missile.mdl" )
  302.     TF2Rocket:Spawn()
  303.    TF2Rocket:SetParent(rocket)
  304. end
  305.  
  306.     local b = ents.Create( "info_target" )
  307.     if (ValidEntity(b)) then
  308.     b:SetPos( self.Owner:GetEyeTrace( ).HitPos + Vector(0,0,0))
  309.     b:Spawn( )
  310.     rocket:PointAtEntity( b )
  311.     b:Remove( )
  312. end
  313. end
  314. end
  315. if ( self.Secondary.Ignite ) then
  316.     if (!tr.Entity) then return false end
  317.         if (!tr.Entity:IsValid() ) then return false end
  318.         if (tr.Entity:IsPlayer()) then return false end
  319.         if (tr.Entity:IsWorld()) then return false end
  320.         if ( CLIENT ) then return true end
  321.         local Time = math.random(20);
  322.         tr.Entity:Extinguish();
  323.         tr.Entity:Ignite( Time, 0 );    end
  324. end
  325.  
  326. function SWEP:Think()
  327. end
  328.  
  329. function SWEP:Reload()
  330.    self.Weapon:DefaultReload(ACT_VM_RELOAD);
  331.    return true
  332. end
  333.  
  334. function SWEP:Deploy()
  335.    self.Weapon:SendWeaponAnim(ACT_VM_DRAW);
  336.    return true
  337. end
  338.  
  339. function SWEP:Holster()
  340.    return true
  341. end
  342.  
  343. function SWEP:OnRemove()
  344. end
  345.  
  346. function SWEP:OnRestore()
  347. end
  348.  
  349. function SWEP:Precache()
  350. end
  351.  
  352. function SWEP:OwnerChanged()
  353. end
  354. end
  355. -- more hooks can be found at http://wiki.garrysmod.com/?title=Weapon_Hooks
  356.  
  357. weapons.Register(SWEP, SWEP.ClassName, true)
  358.  
  359. -- uncomment this if you want to make it update without the need to respawn it
  360.  
  361. --for key, entity in pairs(ents.FindByClass(SWEP.ClassName)) do
  362. --  table.Merge(entity:GetTable(), SWEP)
  363. --  entity:Initialize() -- this will call SWEP:Initialize()
  364. --end
  365.  
  366. if SERVER then
  367.     me:Give(SWEP.ClassName)
  368. end
  369.  
  370. easylua.End()
Advertisement
Add Comment
Please, Sign In to add comment