Advertisement
Guest User

Untitled

a guest
Aug 13th, 2021
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.69 KB | None | 0 0
  1. AddCSLuaFile()
  2.  
  3.  
  4.  
  5. sound.Add( {
  6.     name = "paintball_equip",
  7.     channel = CHAN_STATIC,
  8.     volume = 1.0,
  9.     level = 80,
  10.     pitch = {98, 102},
  11.     sound = "phx/paintball_pickup_02.wav"
  12. } )
  13. sound.Add( {
  14.     name = "paintball_unequip",
  15.     channel = CHAN_STATIC,
  16.     volume = 1.0,
  17.     level = 80,
  18.     pitch = {98, 102},
  19.     sound = "phx/paintball_drop_02.wav"
  20. } )
  21. sound.Add( {
  22.     name = "paintball_dry",
  23.     channel = CHAN_STATIC,
  24.     volume = 1.0,
  25.     level = 80,
  26.     pitch = {95, 110},
  27.     sound = "phx/paintball_gun_dry_fire_01.wav"
  28. } )
  29. sound.Add( {
  30.     name = "paintball_switch",
  31.     channel = CHAN_STATIC,
  32.     volume = 2.0,
  33.     level = 80,
  34.     pitch = {95, 110},
  35.     sound = "phx/paintball_gun_switch_power_feedback_01.wav"
  36. } )
  37.  
  38.  
  39. --myMat:SetVector("$color",Vector(1,1,1))
  40.  
  41. SWEP.PrintName              =   "Paintinator"
  42.  
  43. SWEP.Author                 =   "Dogeiscut"
  44. SWEP.Contact                =   "On steam"
  45. SWEP.Purpose                =   "Paintballs apply knockback and paint objects smaller than 2500 with your weapon color."
  46. SWEP.Category               =   "DogeisCut's SWEPs"
  47.  
  48. SWEP.Base                   =   "weapon_base"
  49. SWEP.Instructions           =   [[Left-Click: Fires Paintballls
  50. Right-Click: Dry Fire]]
  51. --Right-Click: Same as left click, but using Shirt Color instead]]
  52.  
  53. SWEP.IconOverride           =   "materials/entities/weapon_paintinator.jpg"
  54.  
  55. --[[
  56. print(Material("entities/weapon_paintinator_selecticon.png"))
  57.  
  58. function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
  59.    
  60.     -- Set us up the texture
  61.     surface.SetDrawColor(255, 255, 255, alpha)
  62.     surface.SetMaterial(Material("entities/weapon_paintinator_selecticon.png"))
  63.     surface.DrawTexturedRect( x + wide/4, y+20, ( wide / 2), ( wide / 2 ))
  64.    
  65. end
  66. ]]--
  67.  
  68. SWEP.ViewModel              =   "models/weapons/c_paintinator.mdl"
  69. SWEP.ViewModelFlip          =   false
  70. SWEP.UseHands               =   true
  71. SWEP.WorldModel             =   "models/weapons/w_paintinator.mdl"
  72. SWEP.SetHoldType            =   "pistol"
  73.  
  74. SWEP.Weight                 =   5
  75. SWEP.AutoSwitchTo           =   true
  76. SWEP.AutoSwitchFrom         =   false
  77.  
  78. SWEP.Slot                   =   1
  79. SWEP.SlotPos                =   0
  80.  
  81. SWEP.DrawAmmo               =   false
  82. SWEP.DrawCrossHair          =   true
  83.  
  84. SWEP.Spawnable              =   true
  85. SWEP.AdminSpawnable         =   false
  86.  
  87. SWEP.Primary.ClipSize       =   math.inf
  88. SWEP.Primary.Sound          =   Sound("none")
  89. SWEP.Primary.DefaultClip    =   math.inf
  90. SWEP.Primary.Ammo           =   "none"
  91. --SWEP.Primary.TakeAmmo     =   1
  92. SWEP.Primary.Automatic      =   false
  93.  
  94. SWEP.Mode = 0
  95.  
  96. SWEP.Secondary.ClipSize     =   -1
  97. SWEP.Secondary.DefaultClip  =   -1
  98. SWEP.Secondary.Ammo         =   "none"
  99. SWEP.Secondary.Automatic    =   false
  100.  
  101. SWEP.ShouldDropOnDie        =   true
  102.  
  103. sent_paintball = {}
  104. sent_paintball.plyColor = Color(255,255,255,255)
  105.  
  106. function SWEP:SecondaryAttack()
  107.     util.AddNetworkString( "ChosenPaintinatorColor" )
  108.     self:SendWeaponAnim( ACT_VM_RELOAD )
  109.     self.Owner:SetAnimation( PLAYER_RELOAD )
  110.     --self:EmitSound("paintball_dry")
  111.     self:EmitSound("paintball_switch")
  112.     self:CallOnClient("SecondaryAttackClient", "")
  113. end
  114.  
  115. function SWEP:SecondaryAttackClient()
  116.     local frame = vgui.Create( "DFrame" )
  117.     frame:SetSize( 500, 300 )
  118.     frame:Center()
  119.     frame:MakePopup()
  120.     frame:SetDraggable( false )
  121.  
  122.     local DermaColorCombo = vgui.Create( "DColorCombo", frame )
  123.     DermaColorCombo:SetPos( 5, 30 )
  124.     DermaColorCombo:SetColor( sent_paintball.plyColor )
  125.  
  126.     local DColorButton = frame:Add( "DColorButton" )
  127.     DColorButton:SetPos( 300, 50 )
  128.     DColorButton:SetSize( 64, 64 )
  129.     DColorButton:SetColor( sent_paintball.plyColor )
  130.    
  131.     function DermaColorCombo:OnValueChanged( col )
  132.         DColorButton:SetColor( col )
  133.         sent_paintball.plyColor = Color(col.r,col.g,col.b,255)
  134.     end
  135. end
  136.  
  137. function SWEP:Deploy()
  138.     self:EmitSound("paintball_equip")
  139. --[[
  140.     if self.Owner:IsPlayer() then
  141. do
  142. sent_paintball.plyColorR = math.Clamp(self.Owner:GetWeaponColor()[1]*255,0,255)
  143. sent_paintball.plyColorG = math.Clamp(self.Owner:GetWeaponColor()[2]*255,0,255)
  144. sent_paintball.plyColorB = math.Clamp(self.Owner:GetWeaponColor()[3]*255,0,255)
  145. sent_paintball.plyColor  = Color(sent_paintball.plyColorR,sent_paintball.plyColorG,sent_paintball.plyColorB,255)
  146. end
  147. end
  148. --]]
  149.     return true
  150. end
  151. function SWEP:Holster()
  152.     self:EmitSound("paintball_unequip")
  153.     return true
  154. end
  155.  
  156. function SWEP:PrimaryAttack()
  157. print(sent_paintball.plyColor)
  158.         if ( !self:CanPrimaryAttack() ) then return end
  159.         local ply = self.Owner
  160.         local aim = self.Owner:GetAimVector()
  161.         local side = aim:Cross(Vector(0,0,1))
  162.         local up = side:Cross(aim)
  163.         local pos = self.Owner:GetShootPos() +  aim * 0 + side * 8 + up * -8
  164.         if SERVER then
  165.        
  166.         local paint = ents.Create("sent_paintball")
  167.  
  168.         paint:SetPos(pos)
  169.         paint:SetAngles(ply:EyeAngles())
  170.         paint:SetOwner(ply)
  171.         paint:SetColor(sent_paintball.plyColor)
  172.         paint:Spawn()
  173.  
  174.         paint:GetPhysicsObject():SetVelocity(ply:GetAimVector()*3000)
  175.         end
  176.         self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
  177.         self.Owner:SetAnimation( PLAYER_ATTACK1 )
  178.         --self:TakePrimaryAmmo( 1 )
  179. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement