You're searching for the attachment by name on the player. When it's in thirdperson, you should probably be looking for the attachment on their weapon model.
Your loop is crashing because you're not checking that you get a valid client back before calling functions on the pointer. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Russ Canfield Sent: Sunday, March 01, 2009 12:39 PM To: Discussion of Half-Life Programming Subject: [hlcoders] Particles and Muzzle Position on EP1 I am trying to figure out how to fix my particles so that when they emit they show up at the end of the weapon's barrel. Code: CBasePlayer *pPlayer = ToBasePlayer( GetOwner() ); Vector vGunPos; Vector vForward, vRight, vUp; QAngle ClientEyeAngles; ClientEyeAngles = pPlayer->EyeAngles(); AngleVectors( ClientEyeAngles, &vForward, &vRight, &vUp ); m_nBarrelAttachment = pPlayer->LookupAttachment( "muzzle" ); GetAttachment( m_nBarrelAttachment, vGunPos, ClientEyeAngles ); if (pPlayer->IsDucked()) vGunPos -= (vUp * 10.0f); else vGunPos += (vUp * 7.5f); vGunPos +=(vForward * 28.0f); vGunPos += (vRight * 8.0f); CEffectData data; data.m_flScale = 1.0f; data.m_vOrigin = vGunPos; data.m_vAngles = ClientEyeAngles; data.m_nAttachmentIndex = m_nBarrelAttachment; DispatchEffect( "MyEffect", data ); This is fine for the client, but when another user fires their weapon the particles spawn at their feet. I have yet to find a solution, would anyone know why? I am using EP1 engine and the part about checking to see if they are ducked is to compensate for that...since the code doesnt act 100% right... Anyone know what I am doing wrong or not doing at all? If I try to loop like so: Code: for ( int i = 1; i <= gpGlobals->maxClients; ++i ) { CHL2MP_Player *pClient = (CHL2MP_Player*) UTIL_PlayerByIndex( i ); m_nBarrelAttachment = pClient->LookupAttachment( "muzzle" ); GetAttachment( m_nBarrelAttachment, vGunPos, ClientEyeAngles ); } it just crashes when I fire. Anyone ? _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders

