hupax.blogg.se

How to change the skin of a weapon in gmod
How to change the skin of a weapon in gmod





how to change the skin of a weapon in gmod

Now that this is the last use of the aimvector vector we created, - we can directly modify it instead of creating another copy aimvec: Mul( 100 )Īimvec: Add( VectorRand( -10, 10 ) ) - Add a random vector with elements [-10, 10) phys: ApplyForceCenter( aimvec ) You can play with this value here - to adjust how fast we throw it. If ( not phys: IsValid() ) then ent: Remove() return end - Now we apply the force - so the chair actually throws instead - of just falling to the ground. If it isn't then we'll remove the entity. Whenever we get a physics object - we need to test to make sure its valid before using it. Set the angles to the player'e eye angles. Local pos = aimvec * 16 - This creates a new vector object pos: Add( owner: EyePos() ) - This translates the local aimvector to world coordinates - Set the position to the player's eye position plus 16 units forward. This is the same as owner:EyePos() + (self:GetOwner():GetAimVector() * 16) - but the vector methods prevent duplicitous objects from being created - which is faster and more memory efficient - AimVector is not directly modified as it is used again later in the function local aimvec = owner: GetAimVector() Always make sure that created entities are actually created! if ( not ent: IsValid() ) then return end - Set the entity's model to the passed in model ent: SetModel( model_file ) ( if we didn't they would feel a ping delay during multiplayer ) if ( CLIENT ) then return end - Create a prop_physics entity local ent = ents. We play the sound above on the client due to prediction. If we're the client then this is as much as we want to do. Make sure the weapon is being held before trying to throw a chair if ( not owner: IsValid() ) then return end - Play the shoot sound we precached earlier! self: EmitSound( self.ShootSound ) When you call this the player will fire a chair! function SWEP: ThrowChair( model_file ) Self: ThrowChair( "models/props_c17/FurnitureChair001a.mdl" )Įnd - A custom function we added. Though the secondary fire isn't automatic - players shouldn't be able to fire too fast self: SetNextSecondaryFire( CurTime() + 0.1 ) Call 'ThrowChair' on self with this model self: ThrowChair( "models/props/cs_office/Chair_office.mdl" )Įnd - Called when the rightmouse button is pressed function SWEP: SecondaryAttack() self: SetNextPrimaryFire( CurTime() + 0.5 ) Here we set it to shoot every 0.5 seconds.

how to change the skin of a weapon in gmod how to change the skin of a weapon in gmod

This function call below defines - the rate of fire.

how to change the skin of a weapon in gmod

Called when the left mouse button is pressed function SWEP: PrimaryAttack()







How to change the skin of a weapon in gmod