View Single Post
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