Raised This Month: $128 Target: $400
 32% 

[STOCK] Custom kill message icons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 01-21-2021 , 05:50   [STOCK] Custom kill message icons
Reply With Quote #1

It's been a long time since my last contribution to this forum section or at all
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.


.
Attached Files
File Type: sp Get Plugin or Get Source (killfeed_falldamage_icon.sp - 46 views - 3.0 KB)
File Type: zip materials.zip (2.7 KB, 39 views)
__________________
zipcore is offline
The Killer NL
AlliedModders Donor
Join Date: Aug 2018
Location: The Netherlands
Old 01-21-2021 , 06:23   Re: [STOCK] Custom kill message icons
Reply With Quote #2

Dope!
__________________

The Killer NL is offline
kratoss1812
Senior Member
Join Date: May 2018
Location: Romānia
Old 01-21-2021 , 06:41   Re: [STOCK] Custom kill message icons
Reply With Quote #3

thanks for sharing <3
__________________
kratoss1812 is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 01-21-2021 , 06:48   Re: [STOCK] Custom kill message icons
Reply With Quote #4

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");
__________________
Ilusion9 is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 01-21-2021 , 09:15   Re: [STOCK] Custom kill message icons
Reply With Quote #5

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.
__________________
zipcore is offline
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 02-17-2021 , 15:47   Re: [STOCK] Custom kill message icons
Reply With Quote #6

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;

PC Gamer 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 08:39.


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