Raised This Month: $51 Target: $400
 12% 

Solved [CS:GO]Prevent bot drop bomb by human player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ViceTommy
Junior Member
Join Date: Oct 2022
Old 11-05-2022 , 04:16   [CS:GO]Prevent bot drop bomb by human player
Reply With Quote #1

Hello everyone.
CSGO has the ability to take bombs from bots and I am trying to ban them but it is not working.
Below is a script I wrote, but you can still take them by hooking and return Plugin_Handled.

Is there any other solution?

PHP Code:
public void OnClientPutInServer(int client){
    
SDKHook(client,SDKHook_Use,sdkhook_use_test);
}

public 
Action sdkhook_use_test(int look_client,int client){
    return 
Plugin_Handled;

For those of you who don't understand what I'm trying to say, take a look at this image.
https://imgur.com/a/Y9PiUiI

Last edited by ViceTommy; 02-11-2023 at 13:45.
ViceTommy is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-05-2022 , 18:29   Re: [CS:GO]Preventing Bots from Taking Bombs
Reply With Quote #2

Topic title is misleading.

[CS:GO]Prevent bot drop bomb by human player

*edit
This not work, C4 get deleted. Need add check, will bot die on OnTakeDamage function.
PHP Code:
#include <sdkhooks>

public void OnPluginStart()
{
    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i)) OnClientPutInServer(i);
    }
}

public 
void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_WeaponDropWeaponDrop);
}

public 
Action WeaponDrop(int clientint weapon)
{
    
PrintToServer("WeaponDrop");

    if(
IsFakeClient(client) && IsPlayerAlive(client) && HasEntProp(weaponProp_Send"m_fArmedTime"))
        return 
Plugin_Handled;

    return 
Plugin_Continue;

*edit
of course there could be better way than this.
__________________
Do not Private Message @me

Last edited by Bacardi; 11-05-2022 at 21:56.
Bacardi is offline
ViceTommy
Junior Member
Join Date: Oct 2022
Old 11-06-2022 , 03:23   Re: [CS:GO]Preventing Bots from Taking Bombs
Reply With Quote #3

Thanks for your reply.
I have confirmed that the script you wrote is working properly. I will take care of the glitch where it doesn't drop after death myself.
But for some reason, if I try to take a bomb from a bot, the bomb does not fall, but if the bot is trying to place it at the bomb point, it does not place it as if it got lost.
If the player does not take the bomb from the bot it will place it normally, but if he tries to take it, it will not place it.


https://www.youtube.com/watch?v=_XV4K4-E8IQ

Last edited by ViceTommy; 11-06-2022 at 03:27.
ViceTommy is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-06-2022 , 18:14   Re: [CS:GO]Preventing Bots from Taking Bombs
Reply With Quote #4

hehehe.
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-07-2022 , 11:57   Re: [CS:GO]Preventing Bots from Taking Bombs
Reply With Quote #5

sry second post.

Player is executing this function every cmd rate, which is very spammy.
What also handle buymenu, switch weapon by "use" and switch weapon to c4 when bomb target area.
Code:
void CBasePlayer::PlayerUse ( void )
Function check, is player pressed or holded "use" key, then take a action.

This function use native(?) called
Code:
	CBaseEntity *pUseEntity = FindUseEntity();
...which find entity by using TraceRay.

I don't know way to block this, because it works some how by address and offset I guess ?


So here is, again, bad example.
When player press "use" key and PlayerUse is called, you can block it.
- I tried add RayTrace thingie but today I can't get it work right. Would be better use TR_TraceHullFilter for lager area.

Someone could fix that part.


It is now fixed.

Try this.

PHP Code:

#include <dhooks>



DynamicHook dPlayerUse;

public 
void OnPluginStart()
{
// Windows offset 462, Linux is... 463 or 461 ? 
    
dPlayerUse DHookCreate(463HookType_EntityReturnType_VoidThisPointer_CBaseEntityPlayerUse);

    for(
int i 1<= MaxClientsi++)
    {
        if(
IsClientInGame(i)) OnClientPutInServer(i);
    }
}



public 
void OnClientPutInServer(int client)
{
    
DHookEntity(dPlayerUsefalseclient);
}

public 
MRESReturn PlayerUse(int pThis)
{
    static 
timestamps[MAXPLAYERS];

    if(!
IsFakeClient(pThis) && GetClientButtons(pThis) & IN_USE && IsPlayerAlive(pThis))
    {
        
int playerc4 PlayerC4();

        
// no c4 carrier or player is human
        
if(playerc4 || !IsFakeClient(playerc4))
        {
            return 
MRES_Ignored;
        }

        
// cooldown
        
int time GetTime();

        if(
timestamps[pThis] > time)
            return 
MRES_Supercede;



        
float pos[3], pos2[3], angle[3];
        
GetClientEyePosition(pThispos);
        
GetClientEyeAngles(pThisangle);

        
// End position, where player aim + distance 210.0 unit
        
GetAngleVectors(anglepos2NULL_VECTORNULL_VECTOR);
        
ScaleVector(pos2210.0);
        
AddVectors(pos2pospos2);

        
float mins[3] = {-5.0, -5.0, -5.0};
        
float maxs[3] = {5.05.05.0};

        
TR_TraceHullFilter(pospos2minsmaxsCONTENTS_HITBOXfilterpThis);

        
int hit TR_GetEntityIndex(null);
        if(
hit == playerc4)
        {
            
timestamps[pThis] = time 2;
            
PrintToChat(pThis" [SM]\x03You can't drop bomb from bots");
            return 
MRES_Supercede;
        }
    }

    return 
MRES_Ignored;
}

public 
bool filter(int entityint contentsMaskany data)
{
    if(
entity && entity <= MaxClients && entity != data && entity == PlayerC4())
        return 
true;

    return 
false;
}

int PlayerC4()
{
    
int entity FindEntityByClassname(-1"cs_player_manager");
    
    if(
entity != -&& HasEntProp(entityProp_Send"m_iPlayerC4"))
    {
        return 
GetEntProp(entityProp_Send"m_iPlayerC4");
    }

    return -
1;

__________________
Do not Private Message @me

Last edited by Bacardi; 11-08-2022 at 08:33. Reason: fix
Bacardi is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-08-2022 , 02:54   Re: [CS:GO]Preventing Bots from Taking Bombs
Reply With Quote #6

sry thir post.

updated, fixed.
__________________
Do not Private Message @me
Bacardi is offline
ViceTommy
Junior Member
Join Date: Oct 2022
Old 11-12-2022 , 08:34   Re: [CS:GO]Preventing Bots from Taking Bombs
Reply With Quote #7

Sorry for the delay in getting back to you.
I quickly tested the code and the results are great.
It is working normally with no flaws.
Thank you so much.
By the way, my server is Liunx and it is working normally after changing the offset to 464.
ViceTommy is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-12-2022 , 09:40   Re: [CS:GO]Preventing Bots from Taking Bombs
Reply With Quote #8

Good, I had mixed offset, posted version at least worked on Windows
__________________
Do not Private Message @me
Bacardi is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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