CLEO Help How detect when bullet's going to head?

CLEO related
Status
Not open for further replies.

sza23

Active member
Joined
Apr 5, 2013
Messages
44
Reaction score
2
:arrow: How detect when bullet's going to head? (cleo)

Thanks answers!
 

0pc0d3R

Active member
Joined
Feb 11, 2016
Messages
96
Reaction score
2
Location
Ukraine
You can use my plugin source based on SF API of SAMPFUNCS v5.3.3 or just rewrite it on asi framework etc.
But it`s worked for all peds in stream so you need find a way to detect ped what you need. In different of incoming rpc bodypart reading this way better only with one thing - you can get any in-game gta bodypart (0-28), from rpc only (3-9)
Code:
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>
#include "SAMPFUNCS_API.h"
#include "game_api\game_api.h"
SAMPFUNCS *SF = new SAMPFUNCS();
#define HOOKPOS_CEventDamage__AffectsPed 0x4B35A0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool ProcessDamageEvent(CEventDamageSAInterface* xevent, CPedSAInterface* affectsPed)
{
    if (xevent)
    {
        CPools *pPools = GAME->GetPools();
        CPed * pPed = pPools->GetPed((DWORD *)affectsPed);
        CEntity * pInflictor = NULL;
        if (pPed == PEDSELF)
        {
            CEventDamage* pEvent = GAME->GetEventList()->GetEventDamage(xevent);
            if ((pEvent->GetWeaponUsed() >= 22 && pEvent->GetWeaponUsed() <= 34))
            {
                SF->getSAMP()->getChat()->AddChatMessage( D3DCOLOR_XRGB(51, 204, 255),
                "Event!!!!! BodyPart: %d", pEvent->GetPedPieceType());
                pEvent->SetDamageReason(EDamageReason::OTHER);
                ProcessWarning = false;
            }
            pEvent->Destroy();
        }
    }
    return true;
}
CPedSAInterface* affectsPed = 0;
CEventDamageSAInterface* event = 0;
void _declspec(naked) HOOK_CEventDamage__AffectsPed()
{
    _asm
    {
        push    esi
        mov     esi, [esp + 8]
        mov     affectsPed, esi
        mov     event, ecx
        pop     esi
        pushad
    }
 
    if (ProcessDamageEvent(event, affectsPed))
    {
        _asm
        {
            popad
            sub     esp, 0xC  
            push    esi
            mov     esi, ecx
            mov     ecx, HOOKPOS_CEventDamage__AffectsPed
            add     ecx, 6
            jmp     ecx
        }
    }
    else
    {
        _asm
        {
            popad
            xor eax, eax
            retn 4
        }
    }
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void __stdcall mainloop( void )
{
    static bool init = false;
    if (!init)
    {
        if (GAME == nullptr) return;
        if (GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME) return;
        if(!SF->getSAMP()->IsInitialized()) return;
         SF->getGame()->createHook((void*)HOOKPOS_CEventDamage__AffectsPed, HOOK_CEventDamage__AffectsPed, DETOUR_TYPE_JMP, 6);
        init = true;
    }
}
bool WINAPI DllMain( HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved )
{
    switch ( dwReasonForCall )
    {
    case DLL_PROCESS_ATTACH:    
        SF->initPlugin( mainloop, hModule );
        break;
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}
 
Status
Not open for further replies.
Top