View Single Post
Author Message
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-03-2017 , 12:18   [CSS/CSGO] Fire C4 death Event - SM plugin
Reply With Quote #1


net_showevent 2 output



This plugin example trigger death events which happen when players die in C4 exlosion.
-Above in "spoiler" you see net_showevents 2 output when these events happen. (After "bomb_exploded")
- This should help on other plugins which normally follow player_death event. But can also bring more trouble, ex. team killing.
- You not necessary need this

PHP Code:
#include <sdkhooks>

public void OnPluginStart()
{
    
HookEventEx("bomb_exploded"bomb_exploded);

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

public 
void OnClientPutInServer(int client)
{
    if(!
IsClientSourceTV(client) && !IsClientReplay(client))
        
SDKHookEx(clientSDKHook_OnTakeDamagePostOnTakeDamagePost);
}

ArrayList List_C4_Death;

public 
void bomb_exploded(Event event, const char[] namebool dontBroadcast)
{
    if(
List_C4_Death != INVALID_HANDLE)
    {
        for(
int x 0List_C4_Death.Lengthx++)
        {
            
Event event_death CreateEvent("player_death"true);

            if (
event_death == INVALID_HANDLE)
            {
                return;
            }

            
event_death.SetInt("userid"List_C4_Death.Get(x));
            
event_death.SetInt("attacker"event.GetInt("userid"));
            
event_death.SetString("weapon""c4");
            
event_death.SetBool("noreplay"true);
            
event_death.Fire();
        }
        
delete List_C4_Death;
    }
}

public 
void OnTakeDamagePost(int victimint attackerint inflictorfloat damageint damagetype)
{
    
// Don't pass alive players
    
if(IsPlayerAlive(victim)) return;


    if(
attacker MaxClients)
    {
        
// Entity

        
char buffer[30];
        if(
GetEntityClassname(attackerbuffersizeof(buffer)) && StrEqual(buffer"planted_c4"false))
        {
            if(
List_C4_Death == INVALID_HANDLE)
            {
                
List_C4_Death = new ArrayList(30);
            }

            
List_C4_Death.Push(GetClientUserId(victim));
        }
    }

Attached Thumbnails
Click image for larger version

Name:	csgocss.png
Views:	624
Size:	89.5 KB
ID:	165307  
__________________
Do not Private Message @me

Last edited by Bacardi; 09-05-2017 at 08:21.
Bacardi is offline