AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hooking bots hurt (https://forums.alliedmods.net/showthread.php?t=105030)

Jhob94 02-27-2024 18:09

Re: Hooking bots hurt
 
Quote:

Originally Posted by WATCH_D0GS UNITED (Post 2818713)
Not and will not, because you are trying to register ham for bots in a forward which is not called for bots, lol.

This thread is from 2009.
On your quote he is not registering ham, he is registering a forward with fakemeta.

WATCH_D0GS UNITED 02-27-2024 18:33

Re: Hooking bots hurt
 
Quote:

Originally Posted by Jhob94 (Post 2818714)
This thread is from 2009.
On your quote he is not registering ham, he is registering a forward with fakemeta.

It is a unsolved thread from 2009, what cares the day it was published, it could be 00/00/0000.

And We are talking about this:

Quote:

Originally Posted by ConnorMcLeod (Post 949451)
Then, you would have to set 3 values for gBotsRegistered :

0 = not registered
1 = registering soon
2 = registered

Advantage is that you don't use any task + it's immediatly registered.

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.1"

new g_iFhUpdateClientDatag_iFirstBotId

public plugin_init()
{
    
register_plugin("TakeDamage"VERSION"ConnorMcLeod")

    new 
szModName[6]
    
get_modname(szModNamecharsmax(szModName))
    if( !
equal(szModName"czero") || cvar_exists("pb_version") )
    {
        
g_iFhUpdateClientData = -1
    
}

    
RegisterHam(Ham_TakeDamage"player""Player_TakeDamage")
}

public 
client_putinserverid )
{
    if( !
g_iFhUpdateClientData && is_user_bot(id) )
    {
        
g_iFirstBotId id
        g_iFhUpdateClientData 
register_forward(FM_UpdateClientData"UpdateClientData")
    }
    
}

public 
UpdateClientData(id)
{
    if( 
id == g_iFirstBotId )
    {
        
unregister_forward(FM_UpdateClientDatag_iFhUpdateClientData)
        
RegisterHamFromEntity(Ham_TakeDamageid"Player_TakeDamage")
    }
}

public 
Player_TakeDamageid iInflictor iAttackerFloat:flDamage iDamageType )
{




PHP Code:

public UpdateClientData(id)
{
    if( 
id == g_iFirstBotId )
    {
        
unregister_forward(FM_UpdateClientDatag_iFhUpdateClientData)
        
RegisterHamFromEntity(Ham_TakeDamageid"Player_TakeDamage")
    }



Jhob94 02-28-2024 04:04

Re: Hooking bots hurt
 
Back in 2009 threads didn’t have solved/unsolved feature.

I can’t be 100% sure because i never used bots in my life but that’s how you register takedamage from an entity (taking damage from a npc for example). So it probably also works with bots.

WATCH_D0GS UNITED 02-28-2024 07:26

Re: Hooking bots hurt
 
Quote:

Originally Posted by Jhob94 (Post 2818727)
Back in 2009 threads didn’t have solved/unsolved feature.

I can’t be 100% sure because i never used bots in my life but that’s how you register takedamage from an entity (taking damage from a npc for example). So it probably also works with bots.

That's the way you register ham from entity, but he tried to make this in a function which is not called for bots.

This means the 'id' he is passing is always from a human player. You need to register ham for bots with a bot id for it to work.

-

Jhob94 02-28-2024 11:39

Re: Hooking bots hurt
 
Since he uses bot id he is not passing a real player id. The only thing that could happen would be the code not work if updateclientdata ignores bots.

Code:

void UpdateClientData(const struct edict_s *ent, int sendweapons, struct clientdata_s *cd)
{
        g_cd_hook = cd;
        FM_ENG_HANDLE(FM_UpdateClientData, (Engine[FM_UpdateClientData].at(i), (cell)ENTINDEX(ent), (cell)sendweapons, (cell)cd));
        RETURN_META(mswi(lastFmRes));
}

void UpdateClientData_post(const struct edict_s *ent, int sendweapons, struct clientdata_s *cd)
{
        g_cd_hook = cd;
        FM_ENG_HANDLE_POST(FM_UpdateClientData, (EnginePost[FM_UpdateClientData].at(i), (cell)ENTINDEX(ent), (cell)sendweapons, (cell)cd));
        RETURN_META(MRES_IGNORED);
}

I am on mobile phone so i couldn’t search much about it. From what i found it should work with bots.
I don’t have the opportunity to test it today, maybe you can.

WATCH_D0GS UNITED 02-28-2024 13:46

Re: Hooking bots hurt
 
Quote:

Originally Posted by Jhob94 (Post 2818743)
Since he uses bot id he is not passing a real player id. The only thing that could happen would be the code not work if updateclientdata ignores bots.

As We have tried to say since the beginning, FM_UpdateClientData is not called for bots, which means his code below will always return false.

PHP Code:

 if( id == g_iFirstBotId 


Jhob94 02-28-2024 15:11

Re: Hooking bots hurt
 
Well if it doesn’t it ain’t a problem. Just register ham from entity on bot connection. Problem solved.

But are you sure it is not called for bots?

WATCH_D0GS UNITED 02-28-2024 21:32

Re: Hooking bots hurt
 
Quote:

Originally Posted by Jhob94 (Post 2818752)
But are you sure it is not called for bots?

If you are expecting a bot to have framerate.


All times are GMT -4. The time now is 02:02.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.