Kill Sounds [By smallC]

Posts 13 of 3 · Page 1 of 1
Kill Sounds [By smallC]
First, get player score:

Code:
namespace fb
{
    class ClientPlayerScoreManager
    {
    public:
        PAD(0x4); //virtual pad
        eastl::list<fb::ClientPlayerScore *,eastl_arena_allocator> m_playerScores;  

        ClientPlayerScore* getScoreByPlayer(ClientPlayer* pPlayer)
        {
            typedef ClientPlayerScore* (__thiscall* tgetScoreByPlayer)(ClientPlayerScoreManager*, ClientPlayer*);
            tgetScoreByPlayer m_getScoreByPlayer = (tgetScoreByPlayer)(0x00FE1600); 
            return m_getScoreByPlayer(this,pPlayer);
        }

        static ClientPlayerScoreManager* Singleton(void)
        {
            return *(ClientPlayerScoreManager**)((*(DWORD*)0x02380B58) + 0x40); //Ptr for ClientPlayerScoreManager at 0x40 in GameContext
        }
    };


    struct PlayerScore
    {        
        __int32 m_rank;
        __int32 m_kills;
        __int32 m_deaths;
        __int32 m_score;
        __int32 m_globalScoreOrginal;       
        __int32 m_globalScoreUpdated;
        __int32 m_veteran;
        float m_time;
    };

    class ClientPlayerScore
    {
    public:
        char pad[0x148];
        PlayerScore m_score;
    };

};

directly include wav sound into project as ressource:
Code:
BOOL sndPlayResource(int ID)
{
    BOOL bRtn;
    LPVOID lpRes;
    HANDLE hResInfo, hRes;
    // Find the WAVE resource.
    hResInfo = FindResource(hMod, MAKEINTRESOURCE(ID), "WAVE");
    if (hResInfo == NULL)
    {    
        return FALSE;
    }
    // Load the WAVE resource.
    hRes = LoadResource(hMod, (HRSRC)hResInfo);
    if (hRes == NULL)
    {        
        return FALSE;
    }    

    // Lock the WAVE resource and play it.
    lpRes = LockResource(hRes);
    if (lpRes != NULL) 
    {
        bRtn = sndPlaySound((LPCSTR)lpRes, SND_MEMORY | SND_ASYNC |
            SND_NODEFAULT);
        UnlockResource(hRes);
    }
    else
    {
        return false;
    }
}
and then:
Code:
    fb::ClientPlayerScoreManager* pCPSM = fb::ClientPlayerScoreManager::Singleton();
    if (IsValid(pCPSM))
    {
        fb::ClientPlayerScore* pCPS = pCPSM->getScoreByPlayer(pLocalPlayer);
        if (IsValid(pCPS))
        {            
            static int m_streak = 0;
            static int m_deaths = pCPS->m_score.m_deaths;
            static int m_kills = pCPS->m_score.m_kills;

            if (pCPS->m_score.m_kills > m_kills)
            {
                m_kills = pCPS->m_score.m_kills;
                ++m_streak;

                switch (m_streak)
                {
                case 1:
                    //NOSOUND
                    break;
                case 2:
                    sndPlayResource(IDR_WAVE1); //double kill                
                    break;
                case 3:
                    sndPlayResource(IDR_WAVE7); //triple kill
                    break;
                case 4:
                    sndPlayResource(IDR_WAVE6); //multi kill
                    break;
                case 5:
                    sndPlayResource(IDR_WAVE8); //ultra kill
                    break;
                case 6:
                    sndPlayResource(IDR_WAVE5); //monster kill
                    break;
                case 7:
                    sndPlayResource(IDR_WAVE4);  //killing spree
                    break;
                case 8:
                    sndPlayResource(IDR_WAVE10); //wicked sick
                    break;
                case 9:
                    sndPlayResource(IDR_WAVE3); //holy shit
                    break;
                case 10:
                    sndPlayResource(IDR_WAVE9); //unstoppable
                    break;                
                default:
                    sndPlayResource(IDR_WAVE2);  //godlike        
                    break;
                }
            }

            if (pCPS->m_score.m_deaths > m_deaths)
            {
                m_deaths = pCPS->m_score.m_deaths;
                m_streak = 0;
            }
        }
    }
Credits to smallC
Will test this out later when i get home. Thx in advance
can you tell me how or when to use/put this codes please
Posts 13 of 3 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?