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

[CS:GO]How to notify a Bot player the state of C4 when he respawn?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fujimaru_Astolfo
Junior Member
Join Date: Jan 2020
Old 01-20-2020 , 10:59   [CS:GO]How to notify a Bot player the state of C4 when he respawn?
Reply With Quote #1

Hi Everyone,I Have a problem.
In CSGO or CS:S,When BOT died after C4 was installed.
There are always bots don't get notified thus doing nothing in the spawn zone.

Could anyone point me out how to do it?
Any help or suggestion are much appreciated!

English isn’t my first language, so please excuse any mistakes.

PHP Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <cstrike>

float c4_position[3];
bool bomb_set_up;
Handle update_bomb null;

public 
void OnPluginStart(){
    
HookEvent("round_start"round_start_event);
    
HookEvent("player_spawn"player_spawn_event);
    
HookEvent("bomb_planted"c4_bome_planted);

    
//CSGameState::UpdatePlantedBomb
    //https://github.com/VSES/SourceEngine2007/blob/master/se2007/game/server/cstrike/bot/cs_gamestate.cpp
    
StartPrepSDKCall(SDKCall_Raw);
    
PrepSDKCall_SetVirtual(22484);
    
PrepSDKCall_SetSignature(SDKLibrary_Server,"\x55\x89\xE5\x56\x53\x83\xEC\x10\x8B\x75\x0C\xA1\x2A\x2A\x2A\x2A"16);
    
//Linux Offsets and Signature
    
    
PrepSDKCall_AddParameter(SDKType_VectorSDKPass_Pointer);
    
update_bomb EndPrepSDKCall();

    if (
update_bomb == null){
        
SetFailState("Unable to find the signature!");
        
PrintToServer("no signature");
    }
}

public 
void round_start_event(Handle eventchar[] namebool dontBroadcast){
    
bomb_set_up false;
}

public 
void player_spawn_event(Handle eventchar[] namebool dontBroadcast){
    
int userid GetClientOfUserId(GetEventInt(event,"userid"));
    
    if (
bomb_set_up == true && IsClientInGame(userid) && IsPlayerAlive(userid) && GetClientTeam(userid) == 3){
        
SDKCall(update_bombc4_position);
        
//PrintToChatAll("");
    
}
}

public 
void c4_bome_planted(Handle eventchar[] namebool dontBroadcast){
    
bomb_set_up true;
    
int ent=-1;
    
ent FindEntityByClassname(ent"planted_c4");
    
GetEntPropVector(entProp_Send"m_vecOrigin"c4_position);

PHP Code:
L 01/20/2020 23:23:11: [SMException reportedExpected 3th parameterfound none
L 01
/20/2020 23:23:11: [SMBlamingc4_say_pos.smx
L 01
/20/2020 23:23:11: [SMCall stack trace:
L 01/20/2020 23:23:11: [SM]   [0SDKCall
L 01
/20/2020 23:23:11: [SM]   [1Line 39c4_say_pos.sp::player_spawn_event 
Thanks!

Last edited by Fujimaru_Astolfo; 02-02-2020 at 10:10.
Fujimaru_Astolfo is offline
backwards
AlliedModders Donor
Join Date: Feb 2014
Location: USA
Old 01-20-2020 , 20:09   Re: [CS:GO]How to notify a Bot player the state of C4 when he respawn?
Reply With Quote #2

After looking here: https://github.com/VSES/SourceEngine...state.cpp#L125

Something like this should work and wont require signatures.

PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>

bool bomb_set_up;
int site;

public 
void OnPluginStart()
{
    
HookEvent("round_start"round_start_event);
    
HookEvent("player_spawn"player_spawn_event);
    
HookEvent("bomb_planted"c4_bomb_planted);
}

public 
void round_start_event(Handle eventchar[] namebool dontBroadcast)
{
    
bomb_set_up false;
}

public 
void player_spawn_event(Handle eventchar[] namebool dontBroadcast)
{
    
int userid GetClientOfUserId(GetEventInt(event,"userid"));
    
    if (
bomb_set_up && IsClientInGame(userid) && IsPlayerAlive(userid) && GetClientTeam(userid) == 3)
    {
        
int ent = -1;
        
ent FindEntityByClassname(ent"planted_c4");

        if(
ent != -1)
        {
            
float c4_position[3];
            
GetEntPropVector(entProp_Send"m_vecOrigin"c4_position);
            
            
int target = -1;
            
            for(
int i 1;MaxClients+1;i++)
            {
                if(
IsClientConnected(i) && IsClientInGame(i) && GetClientTeam(i) == && IsPlayerAlive(i))
                {
                    
target i;
                    break;
                }
            }
            
            if(
target != -1)
            {
                
float player_position[3];
                
GetEntPropVector(targetProp_Send"m_vecOrigin"player_position);
                
                
TeleportEntity(targetc4_positionNULL_VECTORNULL_VECTOR);
                
Event BombPlanted CreateEvent("bomb_planted");
                if(
BombPlanted != null)
                {
                    
SetEventInt(BombPlanted"userid"target);
                    
SetEventInt(BombPlanted"site"site);
                    
FireEvent(BombPlantedtrue);
                }
                
                
TeleportEntity(targetplayer_positionNULL_VECTORNULL_VECTOR);
            }
        }
    }
}

public 
void c4_bomb_planted(Handle eventchar[] namebool dontBroadcast)
{
    if(!
bomb_set_up)
    {
        
site GetEventInt(event,"site");
        
bomb_set_up true;
    }

__________________
I highly recommend joining the SourceMod Discord Server for real time support.
backwards is offline
Fujimaru_Astolfo
Junior Member
Join Date: Jan 2020
Old 01-21-2020 , 09:17   Re: [CS:GO]How to notify a Bot player the state of C4 when he respawn?
Reply With Quote #3

Thank you for the solution, it can achieve the function I want.

But I found a problem,it will trigger the bomb_planted event with player_spawn,
which caused the bomb_planted related events in all plugins to be triggered accidentally,
causing unexpected problems.

Is there any other solution?

Last edited by Fujimaru_Astolfo; 01-21-2020 at 09:18.
Fujimaru_Astolfo is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 01-24-2020 , 06:29   Re: [CS:GO]How to notify a Bot player the state of C4 when he respawn?
Reply With Quote #4

Try and see if it's working:
PHP Code:
GameRules_SetProp("m_bBombPlanted"true); 
__________________
Ilusion9 is offline
Fujimaru_Astolfo
Junior Member
Join Date: Jan 2020
Old 01-24-2020 , 10:29   Re: [CS:GO]How to notify a Bot player the state of C4 when he respawn?
Reply With Quote #5

Quote:
Originally Posted by Ilusion9 View Post
Try and see if it's working:
PHP Code:
GameRules_SetProp("m_bBombPlanted"true); 
Thank you for the solution, I tried it, but unfortunately it didn't work.
After the bomb is installed,respawned CT BOT will still be dazed.
I have tried setting the parameter to false but still no difference.

I also found that if the parameter is true in the next round,
the Terrorist's BOT seems to think that C4 has been installed,
even though he is carrying C4,He will not install C4 at site A or site B.

Maybe this may help me stop Bot from installing bombs for plugin testing.
Fujimaru_Astolfo is offline
Vit_amin
Senior Member
Join Date: Dec 2015
Location: Russian Federation
Old 01-25-2020 , 08:04   Re: [CS:GO]How to notify a Bot player the state of C4 when he respawn?
Reply With Quote #6

Try check AI Scripts (for example)
Vit_amin is offline
Reply


Thread Tools
Display Modes

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 07:55.


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