Weapons bodygroups system

All right so i am trying to make a system for changing bodygroups on my custom weapons pack, basically i have bodygroups setup like this
$bodygroup Magazine
{
studio “magazine.smd”
blank
}
$bodygroup Aimpoint
{
studio “aimpoint.smd”
blank
}

$bodygroup Supressor
{
studio “supressor.smd”
blank
}

Then how would i also make it so when it has a certain bodygroup the sound to the gun is different?

Also how would i make it for example when a gun reaches 0 ammo (in clip) it sets a bodygroup example where it removes a magazine. Then when it has been reloaded the magazine bodygroup is there again.

Use the

SWEP:PrimaryAttack function, and check the bodygroup using

Entity:GetBodygroup, then play the appropriate sound, then just check if the ammo is 0 and use

Entity:SetBodygroup to change the bodygroup to the appropriate one

[editline]26th April 2016[/editline]

The get and set bodygroup functions are a bit weird to start off with (since you’d expect them to ask for the bodygroup name as a string rather than an integer), but you should figure out how they work after experimenting with them for a while

Yeah i kinda know how they work, just not really in sweps, like how do you set the bodygroups directly in swep file?
Like
SWEP:SetBodygroup(1,1) dont think will work?

Instead of SWEP, you can just use ‘self’, but only in a SWEP function like PrimaryAttack - that’d work

[editline]26th April 2016[/editline]

Actually, you probably have to change the viewmodel and worldmodel bodygroups of the SWEP as well

Yeah how would i do that? Cause i make both world and view model bodygroups, and doing
self.SetBodygroup(1,1) wouldnt do it for both would it? Not sure though, currently not home to experiment.

I think you could do something like

Weapon:GetWeaponViewModel or

Weapon:GetWeaponWorldModel and then do SetBodygroup to both of them

[editline]26th April 2016[/editline]

:snip: I’m stupid

That would return models/weapons/m4a1/a_m4a1.mdl etc? Would that work?
Like
Weapon:GetWeaponWorldModel():SetBodygroup(1,1)
How has FA:S 2 done it? If you know.
Got another question and i wont make a new thread for it, is there a way to scale playermodels? Such as make it your scale of playermodel is 0.25 when starting and when you have played for 1 hour it increases by 0.01
So basically after having played for 75 hours its at 1

[editline]26th April 2016[/editline]

wever thats when you shoot ?
WOuldnt make sence really to make it so when you spawn gun it has no bodygroups, however you shoot it adds 2 bodygroups?
Ahh, looks like that could work, ho

Damn, you’re right… I thought it’d return an entity, scratch my last post… I think you’d have to use

Player:GetViewModel instead

Ok. Ill try when im home,