Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- items.StartWeapon("guntest")
- ITEM.Base = "weapon_base"
- function ITEM:Initialize()
- self.DermaMenuOptions = {} -- Don't really need this, it's just for constant reloading so the menu doesn't stack
- if SERVER then
- self:AllowOption("Explode", "Explode")
- self:AllowOption("Fire Secondary", "SecondaryAttack")
- self:AllowOption("Fire Primary", "PrimaryAttack")
- else
- self:AddSimpleOption("Explode", "Explode") -- First argument is the label in the menu, second is the function name
- self:AddSpacer()
- self:AddCustomOption(function(menu) -- This one's for adding custom vgui elements to the menu
- local slider = vgui.Create("DSlider");
- slider:SetTrapInside(true);
- slider:SetImage("vgui/slider");
- slider:SetLockY(0.5);
- slider:SetSize(100,13);
- slider:SetSlideX(1);
- Derma_Hook(slider,"Paint","Paint","NumSlider");
- slider.TranslateValues=function(p,x,y)
- self:CallOption("Fire Primary", "PrimaryAttack")
- return x,y;
- end
- menu:AddPanel(slider)
- end)
- self:AddSimpleOption("Fire Primary", "PrimaryAttack")
- self:AddSimpleOption("Fire Secondary", "SecondaryAttack")
- end
- end
- local sound = Sound( "Metal.SawbladeStick" )
- function ITEM:MakeEnt(class)
- local tr = self:GetTrace()
- self:EmitSound( sound )
- local ent = ents.Create( class )
- ent:SetPos( tr.HitPos )
- ent:SetAngles( tr.HitNormal:Angle() )
- ent:Spawn()
- timer.Simple(1, function() ent:Remove() end)
- end
- if SERVER then
- function ITEM.HOOK:PlayerSay(player, text) -- I know there's a clientside chat hook. I'm only doing this to show UserMessages
- self:SendUserMessage("text", player:Nick() .. ": " .. text)
- end
- else
- function ITEM:ReceiveUserMessage(key, value)
- self[key] = value
- end
- function ITEM.HOOK:HUDPaint()
- if not self.text then return end
- local position = self:GetPos():ToScreen()
- draw.DrawText(self.text, "Default", position.x, position.y, color_white, TEXT_ALIGN_LEFT)
- end
- end
- function ITEM:PrimaryAttack()
- self:MakeEnt("npc_manhack")
- end
- function ITEM:SecondaryAttack()
- self:MakeEnt("npc_rollermine")
- end
- function ITEM:Explode()
- local data = EffectData()
- data:SetOrigin(self:GetPos())
- util.Effect("explosion", data)
- self:Remove()
- end
- items.EndWeapon()
Add Comment
Please, Sign In to add comment