AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [CSS/CSGO] Fire C4 death Event - SM plugin (https://forums.alliedmods.net/showthread.php?t=300933)

Bacardi 09-03-2017 12:18

[CSS/CSGO] Fire C4 death Event - SM plugin
 
1 Attachment(s)

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 :D

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));
        }
    }



ReymonARG 09-07-2017 23:25

Re: [CSS/CSGO] Fire C4 death Event - SM plugin
 
thanks this is a good method to get player that death by c4. I was using only takedamage, but you add bomb_explode, so thanks!!


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

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