Python1320

Untitled

Jul 20th, 2010
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.79 KB | None | 0 0
  1. items.StartItem("yeah", "weapon_base", "base_anim") -- Not sure how I should do this (if it's a neat way)
  2.    
  3.     ITEM.WorldModel = "models/weapons/w_pistol.mdl"
  4.     ITEM.ViewModel = "models/weapons/v_pistol.mdl"
  5.    
  6.     function ITEM:Initialize()
  7.         self.DermaMenuOptions = {} -- Don't really need this, it's just for constant reloading (I'm runstringing this shared) so the menu doesn't stack
  8.        
  9.         if CLIENT then
  10.             self:AddSimpleOption("Explode", "Explode") -- First argument is the label in the menu, second is the function name             
  11.             self:AddCustomOption(function(menu) -- This one's for adding custom vgui elements to the menu
  12.                 local slider = vgui.Create("DSlider");
  13.                 slider:SetTrapInside(true);
  14.                 slider:SetImage("vgui/slider");
  15.                 slider:SetLockY(0.5);
  16.                 slider:SetSize(100,13);
  17.                 slider:SetSlideX(1);
  18.                 Derma_Hook(slider,"Paint","Paint","NumSlider");
  19.                 slider.TranslateValues=function(p,x,y)
  20.                     self:CallOption("Spawn Random", "MakeEnt", table.Random({"npc_manhack", "npc_rollermine"})) -- You can do anything here, but I want to spam PrimaryAttack for fun.
  21.                     return x,y;
  22.                 end
  23.                 menu:AddPanel(slider)
  24.             end)
  25.            
  26.             self:AddSimpleOption("Fire Primary", "PrimaryAttack", "OH YES")
  27.             self:AddSimpleOption("Fire Secondary", "SecondaryAttack")
  28.         else               
  29.             self:AllowOption("Explode", "Explode")
  30.             self:AllowOption("Fire Secondary", "SecondaryAttack")
  31.             self:AllowOption("Fire Primary", "PrimaryAttack")
  32.             self:AllowOption("Spawn Random", "MakeEnt")
  33.            
  34.             if not self:IsWeapon() then
  35.                 self:SetModel(  self.WorldModel )
  36.                 self:PhysicsInit( SOLID_VPHYSICS )
  37.                 self:SetMoveType( MOVETYPE_VPHYSICS )
  38.                 self:SetSolid( SOLID_VPHYSICS )
  39.                 self:PhysWake()
  40.             end
  41.         end
  42.        
  43.     end
  44.    
  45.     local sound = Sound( "Metal.SawbladeStick" )
  46.            
  47.     if SERVER then
  48.    
  49.         function ITEM.HOOK:PlayerSay(player, text) -- I know there's a clientside chat hook. I'm only doing this to show UserMessages
  50.             self:SendUserMessage("text", player:Nick() .. ": " .. text)
  51.         end
  52.        
  53.         function ITEM:MakeEnt(class)
  54.             self.Owner:MuzzleFlash()
  55.             self.Owner:SetAnimation( PLAYER_ATTACK1 )
  56.            
  57.             local tr = self:GetTrace() -- This returns GetEyeTrace if it's held, and a custom trace if it's not held
  58.          
  59.             local ent = ents.Create( class )
  60.             ent:SetPos( tr.HitPos )
  61.             ent:SetAngles( tr.HitNormal:Angle() )
  62.             ent:Spawn()
  63.             ent:SetCollisionGroup(COLLISION_GROUP_WEAPON)
  64.  
  65.             timer.Simple(1, function() ent:Remove() end)
  66.         end
  67.        
  68.         function ITEM:PrimaryAttack(ohyes)
  69.             print(ohyes)
  70.             self:MakeEnt("npc_manhack")
  71.         end
  72.          
  73.         function ITEM:SecondaryAttack()
  74.             self:MakeEnt("npc_rollermine")
  75.         end
  76.        
  77.         function ITEM:Explode()
  78.             local data = EffectData()
  79.             data:SetOrigin(self:GetPos())
  80.             util.Effect("explosion", data)
  81.             self:Remove()
  82.         end
  83.        
  84.         function ITEM:Touch(ply)
  85.             if not ply:IsPlayer() then return end
  86.             self:SendUserMessage("touch", ply)
  87.         end
  88.        
  89.         function ITEM:OnTakeDamage(info)
  90.             info:SetDamageForce(info:GetDamageForce()*1000)
  91.             self:TakePhysicsDamage(info)
  92.         end
  93.        
  94.     else
  95.        
  96.         function ITEM:PrimaryAttack()  
  97.             self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
  98.             self.Owner:MuzzleFlash()
  99.             self.Owner:SetAnimation( PLAYER_ATTACK1 )
  100.         end
  101.        
  102.         ITEM.SecondaryAttack = ITEM.PrimaryAttack
  103.  
  104.         function ITEM:ReceiveUserMessage(key, value)
  105.             if key == "text" then self.text = value end
  106.             if key == "touch" then chat.AddText(HSVToColor(math.random(360), 1,1), "CAUSE EVERYTIME WE TOUCH "..value:Nick().." GETS THIS FEELING") end
  107.         end
  108.        
  109.         function ITEM.HOOK:HUDPaint()
  110.             if not self.text then return end
  111.             local position = self:GetPos():ToScreen()
  112.             draw.DrawText(self.text, "Default", position.x, position.y, color_white, TEXT_ALIGN_LEFT)
  113.         end
  114.        
  115.     end
  116.    
  117. items.EndItem()
  118.  
  119. if SERVER then
  120.     items.EasyCreate("yeah", nero.GetPlayer("caps"), true)
  121. end
Add Comment
Please, Sign In to add comment