View Single Post
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 03-11-2017 , 02:14   Re: [TUT] Registering hams on bots.
Reply With Quote #10

You should hook PvAllocEntPrivateData call from gamedll, check the passed entity for bot and register ham on it. But you can't hook it with amxx, so then you should hook GetInfoKeyBuffer, it is first engine function called after PvAllocEntPrivateData on bot creating.

That is my old code for this:
PHP Code:
#include <amxmodx>
#include <fakemeta>

new g_iFakeClientByGameDll;

new 
g_fwdCreateFakeClient_Post;
new 
g_fwdGetInfoKeyBuffer;

public 
plugin_init() {
    
g_fwdCreateFakeClient_Post register_forward(FM_CreateFakeClient"CreateFakeClient_Post"true);
    
g_fwdGetInfoKeyBuffer register_forward(FM_GetInfoKeyBuffer"GetInfoKeyBuffer");
}

public 
CreateFakeClient_Post() {
    new 
iEntity get_orig_retval();
    
    if (!
pev_valid(iEntity)) {
        return;
    }
    
    
g_iFakeClientByGameDll iEntity;
}

public 
GetInfoKeyBuffer(const iEntity) {
    if (!
g_iFakeClientByGameDll) {
        return;
    }
    
    
g_iFakeClientByGameDll 0;
    
    
unregister_forward(FM_CreateFakeClientg_fwdCreateFakeClient_Posttrue);
    
unregister_forward(FM_GetInfoKeyBufferg_fwdGetInfoKeyBuffer);
    
    new 
iRet;
    new 
fwd CreateMultiForward("CSBot_Init"ET_IGNOREFP_CELL);
    
ExecuteForward(fwdiRetiEntity);
    
DestroyForward(fwd);

__________________

Last edited by PRoSToTeM@; 03-14-2017 at 21:05.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@