Change Default Viewmodel positions and angles for a weapon? (SWEP)

Hello Developers and tinkerers of facepunch; first post here.

I am relatively new to lua, but I know my way around basic code. I was wondering if aside from

SWEP.IronSightsPos = Vector
SWEP.IronSightsAng = Vector
SWEP.SightsPos = Vector
SWEP.SightsAng = Vector
SWEP.RunSightsPos = Vector
SWEP.RunSightsAng = Vector

Is there anyway for you to adjust the default positions and angles of a swep when you’re not sprinting or ironsighting? Thank you in advance.

And also another question, what exactly is the difference bettween SWEP.IronSights and SWEP.Sights?

This is specific to the SWEP base you are using, what SWEP pack are you running?

My sweps are based off of bob’s gun base (M9K)

Go to the M9K base code, and in

function SWEP:GetViewModelPosition()

put this in:

pos = pos + ang:Right() * insertrightorleftpositionhere + ang:Up() * insertupordownpositionhere

Note that you’ll have to tinker with the ironsights position after doing this, when you change the viewmodel position you’ll have some trouble with the ironsights position, I learned that the hard way

Thanks! Would you mind providing me with a sample of how you used this?

He just did.

It may be because i am a beginner at lua, but every time I enter it I get index errors on pos, ang and right which is why I asked for a sample

You need to enter numbers, like so:

pos = pos + ang:Right() * -1 + ang:Up() * -2

What I entered:

function SWEP:GetViewModelPosition()
          pos = pos + ang:Right() * 2 + ang:Up() * 4

What I also tried entering:

function SWEP:GetViewModelPosition("m9k_r21")
          pos = pos + ang:Right() * 2 + ang:Up() * 4

(Keep in mind, m9k_r21 is the name of my swep)

but anyway, not only does it not change the view-models but I get global index errors on “pos”, “ang” and “right”.

function SWEP:GetViewModelPosition(pos, ang)
pos = pos + ang:Right() * 2 + ang:Up() * 4
return pos, ang

In my SWEP code, return pos, ang wasn’t needed considering that return pos, ang was already in the code. Well, who knows, he might or might not need it in this case

Seeing as it wasn’t already in his, I would say he needs it. Although a better question is, seeing as this modifies the angle instead of creating a new one, do we need to return it at all?

How do I adjust the ironsights afterwards? Thanks so much, it worked, but it seems that the gun is now in a stationary position for ironsights and runsights

[editline]12th May 2015[/editline]

How did you end up fixing the ironsights afterwards?

I didn’t use M9K for my sweps. I can give you the base code I use for my weapons via paste bin if you want.

sure, that would be great thanks.