AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [STOCK] Custom kill message icons (https://forums.alliedmods.net/showthread.php?t=330116)

zipcore 01-21-2021 04:50

[STOCK] Custom kill message icons
 
2 Attachment(s)
It's been a long time since my last contribution to this forum section or at all :3
So what do I have here to share with you today?
It's an example code of something I've used in many ways for different private plugins already.



The snipped shows you how to use custom icons inside the killfeed. The attached example plugin adds an icon for deaths caused by fall damage, but you can use it for many other things too.

PHP Code:

stock Action FakeDeathEvent(Event oldEventchar[] weapon)
{
    
oldEvent.BroadcastDisabled true;
    
    
Event event_fake CreateEvent("player_death"true);
    
    
char sWeapon[64];
    
Format(sWeaponsizeof sWeapon"weapon_%s"weapon); // trys to use materials/panorama/images/icons/equipment/<WEAPONNAME>.svg
    
event_fake.SetString("weapon"sWeapon);
    
    
event_fake.SetInt("userid"oldEvent.GetInt("userid"));
    
event_fake.SetInt("attacker"oldEvent.GetInt("attacker"));
    
    
event_fake.SetInt("assister"oldEvent.GetInt("assister"));
    
event_fake.SetBool("assistedflash"oldEvent.GetBool("assistedflash"));
    
event_fake.SetBool("headshot"oldEvent.GetBool("headshot"));
    
event_fake.SetBool("dominated"oldEvent.GetBool("dominated"));
    
event_fake.SetBool("revenge"oldEvent.GetBool("revenge"));
    
event_fake.SetBool("wipe"oldEvent.GetBool("wipe"));
    
event_fake.SetBool("penetrated"oldEvent.GetBool("penetrated"));
    
event_fake.SetBool("noreplay"oldEvent.GetBool("noreplay"));
    
event_fake.SetBool("noscope"oldEvent.GetBool("noscope"));
    
event_fake.SetBool("thrusmoke"oldEvent.GetBool("thrusmoke"));
    
event_fake.SetBool("attackerblind"oldEvent.GetBool("attackerblind"));
    
    for(
int i 1<= MaxClientsi++) if(IsClientInGame(i) && !IsFakeClient(i))
    {
        
event_fake.FireToClient(i);
    }
    
    
event_fake.Cancel();
    
    return 
Plugin_Changed;


If you plan to use this for your own servers, please choose unique filenames which include a shortcut of your communityname as a prefix or something, thanks.


.

The Killer NL 01-21-2021 05:23

Re: [STOCK] Custom kill message icons
 
Dope!

kratoss1812 01-21-2021 05:41

Re: [STOCK] Custom kill message icons
 
thanks for sharing <3

Ilusion9 01-21-2021 05:48

Re: [STOCK] Custom kill message icons
 
PHP Code:


HookEvent
("player_death"Event_PlayerDeath_PreEventHookMode_Pre);

public 
void Event_PlayerDeath_Pre(Event event, const char[] namebool dontBroadcast
{
    if (
event.GetInt("attacker"))
    {
        
// kills made by traps
        
char weapon[256];
        
event.GetString("weapon"weaponsizeof(weapon));
        
        if (
StrEqual(weapon"point_hurt"true) || StrEqual(weapon"worldspawn"true))
        {
            
event.SetString("weapon""breachcharge_projectile");
        }
    }


You can do this, it's cleaner than how you do.
For that icon to work, the setting should be: event.SetString("weapon", "fall");

zipcore 01-21-2021 08:15

Re: [STOCK] Custom kill message icons
 
You're right, at the time I used this code I was also limiting who receives the killfeed. Totally forgot to clean that out as I've stripped the code to make this public. I will rework th snipped and example code later. Thanks for letting me know.

PC Gamer 02-17-2021 14:47

Re: [STOCK] Custom kill message icons
 
Adding this from a 'Be the Wizard Merasmus' plugin by Starman4xz, Mitch, Plipoika, FlaminSarge:
PHP Code:

public void OnPluginStart() 

    
HookEvent("player_death"Event_DeathPreEventHookMode_Pre);
}

public 
Action Event_DeathPre(Handle event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"attacker"));
    
char weapon[20];
    
GetEventString(event"weapon"weaponsizeof(weapon));
    if(
g_bIsWizard[client])
    {
        if(
StrEqual(weapon"club"false))
        {
            
SetEventString(event"weapon""merasmus_decap");
            
SetEventString(event"weapon_logclassname""merasmus_decap");
        }
        else if(
StrEqual(weapon"flamethrower"false))
        {
            
SetEventString(event"weapon""merasmus_zap");
            
SetEventString(event"weapon_logclassname""merasmus_zap");
        }
        else if(
StrEqual(weapon"env_explosion"false))
        {
            
SetEventString(event"weapon""merasmus_grenade");
            
SetEventString(event"weapon_logclassname""merasmus_grenade");
        }
    }


And adding this from a 'Be the Monoculus' plugin by Leonardo:
PHP Code:

public OnPluginStart()
{
    
HookEvent"player_death"OnPlayerDeathEventHookMode_Pre );
}

public 
Action:OnPlayerDeathHandle:hEvent, const String:strEventName[], bool:bDontBroadcast )
{
    new 
iClient GetClientOfUserIdGetEventInthEvent"userid" ) );
    if( !
IsValidClient(iClient) )
    return 
Plugin_Continue;
    
    if( 
bEyeStatus[iClient] )
    {
        
DontBeTheMonoculusiClient );
        return 
Plugin_Continue;
    }
    
    new 
iKiller GetClientOfUserIdGetEventInthEvent"attacker" ) );
    if( !
IsValidClient(iKiller) || !bEyeStatus[iKiller] )
    return 
Plugin_Continue;
    
    
SetEventStringhEvent"weapon""eyeball_rocket" );
    
SetEventInthEvent"weaponid");
    
SetEventStringhEvent"weapon_logclassname""eyeball_rocket" );
    
SetEventInthEvent"customkill"TF_CUSTOM_EYEBALL_ROCKET );
    
    
//    SetEntityHealth( iKiller, GetClientHealth(iKiller) + iEyeHPP );
    
return Plugin_Continue;




All times are GMT -4. The time now is 09:01.

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