Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- items.StartItem("yeah", "weapon_base", "base_anim") -- Not sure how I should do this (if it's a neat way)
- ITEM.WorldModel = "models/weapons/w_pistol.mdl"
- ITEM.ViewModel = "models/weapons/v_pistol.mdl"
- function ITEM:Initialize()
- self.DermaMenuOptions = {} -- Don't really need this, it's just for constant reloading (I'm runstringing this shared) so the menu doesn't stack
- if CLIENT then
- self:AddSimpleOption("Explode", "Explode") -- First argument is the label in the menu, second is the function name
- 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("Spawn Random", "MakeEnt", table.Random({"npc_manhack", "npc_rollermine"})) -- You can do anything here, but I want to spam PrimaryAttack for fun.
- return x,y;
- end
- menu:AddPanel(slider)
- end)
- self:AddSimpleOption("Fire Primary", "PrimaryAttack", "OH YES")
- self:AddSimpleOption("Fire Secondary", "SecondaryAttack")
- else
- self:AllowOption("Explode", "Explode")
- self:AllowOption("Fire Secondary", "SecondaryAttack")
- self:AllowOption("Fire Primary", "PrimaryAttack")
- self:AllowOption("Spawn Random", "MakeEnt")
- if not self:IsWeapon() then
- self:SetModel( self.WorldModel )
- self:PhysicsInit( SOLID_VPHYSICS )
- self:SetMoveType( MOVETYPE_VPHYSICS )
- self:SetSolid( SOLID_VPHYSICS )
- self:PhysWake()
- end
- end
- end
- local sound = Sound( "Metal.SawbladeStick" )
- 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
- function ITEM:MakeEnt(class)
- self.Owner:MuzzleFlash()
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
- local tr = self:GetTrace() -- This returns GetEyeTrace if it's held, and a custom trace if it's not held
- local ent = ents.Create( class )
- ent:SetPos( tr.HitPos )
- ent:SetAngles( tr.HitNormal:Angle() )
- ent:Spawn()
- ent:SetCollisionGroup(COLLISION_GROUP_WEAPON)
- timer.Simple(1, function() ent:Remove() end)
- end
- function ITEM:PrimaryAttack(ohyes)
- print(ohyes)
- 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
- function ITEM:Touch(ply)
- if not ply:IsPlayer() then return end
- self:SendUserMessage("touch", ply)
- end
- function ITEM:OnTakeDamage(info)
- info:SetDamageForce(info:GetDamageForce()*1000)
- self:TakePhysicsDamage(info)
- end
- else
- function ITEM:PrimaryAttack()
- self:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
- self.Owner:MuzzleFlash()
- self.Owner:SetAnimation( PLAYER_ATTACK1 )
- end
- ITEM.SecondaryAttack = ITEM.PrimaryAttack
- function ITEM:ReceiveUserMessage(key, value)
- if key == "text" then self.text = value end
- if key == "touch" then chat.AddText(HSVToColor(math.random(360), 1,1), "CAUSE EVERYTIME WE TOUCH "..value:Nick().." GETS THIS FEELING") end
- 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
- items.EndItem()
- if SERVER then
- items.EasyCreate("yeah", nero.GetPlayer("caps"), true)
- end
Add Comment
Please, Sign In to add comment