Raised This Month: $51 Target: $400
 12% 

Solved Show only my kills/deaths


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hadesownage
AlliedModders Donor
Join Date: Jun 2013
Location: Romania, Iași
Old 11-09-2016 , 12:51   Show only my kills/deaths
Reply With Quote #1

Hello! I have an deathmatch server and Kills feed is too long (to much kills) and i want to show only my kills/deaths.
I tired like that, but is hiding all kills.

PHP Code:
#pragma semicolon 1

// ====[ INCLUDES ]============================================================
#include <sourcemod>

// ====[ DEFINES ]=============================================================
#define    PLUGIN_VERSION            "1.3"


public Plugin:myinfo =
{
    
name "Hide Kill Feed",
    
author "ReFlexPoison",
    
description "Disables advertisements of bot deaths and/or kills in the kill feed",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net/showthread.php?p=1684156"
}

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



public 
Action:OnPlayerDeath(Handle:hEvent, const String:strName[], bool:bBroadcast)
{
    
        new 
iVictim GetClientOfUserId(GetEventInt(hEvent"userid"));
        new 
iAttacker GetClientOfUserId(GetEventInt(hEvent"attacker"));
        
        if(
IsValidClient(iVictim) && IsValidClient(iAttacker) ) {
        
                for (new 
1<= MaxClientsi++)
                {
                    if ( !
IsValidClient ) || IsFakeClient) || iVictim == || iAttacker == )
                        continue;
                        
                    
SetEventBroadcast(hEventtrue);
                        
                }
            
                
        }

        return 
Plugin_Continue;
}

stock IsValidClient client ) {

    if ( !( 
<= client <= MaxClients ) || !IsClientInGame client ) )
        return 
false;

    return 
true;

Thank you!

Last edited by hadesownage; 11-09-2016 at 19:43. Reason: Solved.
hadesownage is offline
Send a message via Yahoo to hadesownage Send a message via Skype™ to hadesownage
Mitchell
~lick~
Join Date: Mar 2010
Old 11-09-2016 , 13:15   Re: Show only my kills/deaths
Reply With Quote #2

I don't think you can create events specifically for certain clients and send them it. meaning that you can't fake a death message, all you can do is block it.

Last edited by Mitchell; 11-09-2016 at 13:30.
Mitchell is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 11-09-2016 , 13:21   Re: Show only my kills/deaths
Reply With Quote #3

Quote:
Originally Posted by hadesownage View Post
Hello! I have an deathmatch server and Kills feed is too long (to much kills) and i want to show only my kills/deaths.
I tired like that, but is hiding all kills.

PHP Code:
#pragma semicolon 1

// ====[ INCLUDES ]============================================================
#include <sourcemod>

// ====[ DEFINES ]=============================================================
#define    PLUGIN_VERSION            "1.3"


public Plugin:myinfo =
{
    
name "Hide Kill Feed",
    
author "ReFlexPoison",
    
description "Disables advertisements of bot deaths and/or kills in the kill feed",
    
version PLUGIN_VERSION,
    
url "http://forums.alliedmods.net/showthread.php?p=1684156"
}

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



public 
Action:OnPlayerDeath(Handle:hEvent, const String:strName[], bool:bBroadcast)
{
    
        new 
iVictim GetClientOfUserId(GetEventInt(hEvent"userid"));
        new 
iAttacker GetClientOfUserId(GetEventInt(hEvent"attacker"));
        
        if(
IsValidClient(iVictim) && IsValidClient(iAttacker) ) {
        
                for (new 
1<= MaxClientsi++)
                {
                    if ( !
IsValidClient ) || IsFakeClient) || iVictim == || iAttacker == )
                        continue;
                        
                    
SetEventBroadcast(hEventtrue);
                        
                }
            
                
        }

        return 
Plugin_Continue;
}

stock IsValidClient client ) {

    if ( !( 
<= client <= MaxClients ) || !IsClientInGame client ) )
        return 
false;

    return 
true;

Thank you!
+1 Mitchell si salut hades ! (Sunt SniperHero)
Si uite-te aici :
https://wiki.alliedmods.net/Events_(SourceMod_Scripting)

Last edited by cristian20042; 11-09-2016 at 13:31.
cristian20042 is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 11-09-2016 , 13:44   Re: Show only my kills/deaths
Reply With Quote #4

Quote:
Originally Posted by Mitchell View Post
I don't think you can create events specifically for certain clients and send them it. meaning that you can't fake a death message, all you can do is block it.
You may be right.

If OP wants to test it, I think this is what he wants.
Set your steamid (STEAM_1:0:00000) with sm_hidekillfeed_id
Spoiler

Last edited by Maxximou5; 11-09-2016 at 17:00. Reason: Update with fix
Maxximou5 is offline
hadesownage
AlliedModders Donor
Join Date: Jun 2013
Location: Romania, Iași
Old 11-09-2016 , 15:14   Re: Show only my kills/deaths
Reply With Quote #5

@Maxximou5 Is not working. I put my steamid and nothing appears.
hadesownage is offline
Send a message via Yahoo to hadesownage Send a message via Skype™ to hadesownage
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 11-09-2016 , 17:02   Re: Show only my kills/deaths
Reply With Quote #6

Quote:
Originally Posted by hadesownage View Post
@Maxximou5 Is not working. I put my steamid and nothing appears.
My bad, I made a very silly mistake. I just tested it and it does actually work for me testing against bots.
It's set so you will only see that person's (steamid) kills and deaths. If you don't want deaths to be shown you can edit out the StrEqual(steamIDv, g_sHide_ID)
Maxximou5 is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 11-09-2016 , 17:11   Re: Show only my kills/deaths
Reply With Quote #7

Quote:
Originally Posted by Mitchell View Post
I don't think you can create events specifically for certain clients and send them it. meaning that you can't fake a death message, all you can do is block it.
You can.

To answer the op, just move your code to new syntax(or you won't be able to do my soluce), set dont broadcast on true, copy the event over a new one, and fire it to the desired client using FireToClient func.
__________________

Last edited by Benoist3012; 11-09-2016 at 17:11.
Benoist3012 is offline
R3TROATTACK
Member
Join Date: Feb 2013
Old 11-09-2016 , 17:19   Re: Show only my kills/deaths
Reply With Quote #8

Well Benoist gave you the answer before I could, but here is some code that should do what you want

PHP Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "R3TROATTACK"
#define PLUGIN_VERSION "1.00"

#include <sourcemod>

#pragma newdecls required

public Plugin myinfo 
{
    
name "Death Broadcast",
    
author PLUGIN_AUTHOR,
    
description "Displays kill feed to only the victim and attacker",
    
version PLUGIN_VERSION,
    
url "http://steamcommunity.com/id/R3TROATTACK/"
};

public 
void OnPluginStart()
{    
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Pre);
}

public 
void Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int victim GetClientOfUserId(event.GetInt("userid"));
    
int attacker GetClientOfUserId(event.GetInt("attacker"));
    
char sWeapon[128];
    
event.GetString("weapon"sWeapon128);
    
bool headshot event.GetBool("headshot");
    
    
CreateDeathEvent(victimattackersWeaponheadshot);
    
    
SetEventBroadcast(eventtrue);
}

public 
void CreateDeathEvent(int victimint attackerchar[] sWeaponbool headshot)
{
    
Event event CreateEvent("player_death");
    
event.SetInt("userid"victim);
    
event.SetInt("attacker"attacker);
    
event.SetString("weapon"sWeapon);
    
event.SetBool("headshot"headshot);
    
    if(
IsValidClient(victim))
        
event.FireToClient(victim);
    if(
IsValidClient(attacker) && victim != attacker)
        
event.FireToClient(attacker);
}

stock bool IsValidClient(int client)
{
    if(
client <= || client MaxClients)
        return 
false;
        
    if(!
IsClientInGame(client) || !IsClientConnected(client) || IsFakeClient(client))
        return 
false;
        
    return 
true;


Last edited by R3TROATTACK; 11-09-2016 at 17:20.
R3TROATTACK is offline
hadesownage
AlliedModders Donor
Join Date: Jun 2013
Location: Romania, Iași
Old 11-09-2016 , 19:16   Re: Show only my kills/deaths
Reply With Quote #9

It works how I said, but is a problem. Names doesn't shows.



Same on death/kill.

Solution:

PHP Code:
event.SetInt("userid"GetClientUserId(victim));
event.SetInt("attacker"GetClientUserId(attacker)); 

Last edited by hadesownage; 11-09-2016 at 19:43.
hadesownage is offline
Send a message via Yahoo to hadesownage Send a message via Skype™ to hadesownage
Mitchell
~lick~
Join Date: Mar 2010
Old 11-10-2016 , 07:52   Re: Show only my kills/deaths
Reply With Quote #10

I had no idea the Event had FireToClient, pretty neat.
PHP Code:

#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "R3TROATTACK"
#define PLUGIN_VERSION "1.00"

#include <sourcemod>

#pragma newdecls required

public Plugin myinfo 
{
    
name "Death Broadcast",
    
author PLUGIN_AUTHOR,
    
description "Displays kill feed to only the victim and attacker",
    
version PLUGIN_VERSION,
    
url "http://steamcommunity.com/id/R3TROATTACK/"
};

public 
void OnPluginStart()
{    
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Pre);
}

public 
void Event_PlayerDeath(Event event, const char[] namebool dontBroadcast)
{
    
int victim GetClientOfUserId(event.GetInt("userid"));
    
int attacker GetClientOfUserId(event.GetInt("attacker"));
    
char sWeapon[128];
    
event.GetString("weapon"sWeapon128);
    
bool headshot event.GetBool("headshot");
    
    
CreateDeathEvent(victimattackersWeaponheadshot);
    
    
SetEventBroadcast(eventtrue);
}

public 
void CreateDeathEvent(int victimint attackerchar[] sWeaponbool headshot)
{
    
Event event CreateEvent("player_death");
    
event.SetInt("userid"victim);
    
event.SetInt("attacker"attacker);
    
event.SetString("weapon"sWeapon);
    
event.SetBool("headshot"headshot);
    
    if(
IsValidClient(victim))
        
event.FireToClient(GetClientUserId(victim));
    if(
IsValidClient(attacker) && victim != attacker)
        
event.FireToClient(GetClientUserId(attacker));
}

stock bool IsValidClient(int client)
{
    if(
client <= || client MaxClients)
        return 
false;
        
    if(!
IsClientInGame(client) || !IsClientConnected(client) || IsFakeClient(client))
        return 
false;
        
    return 
true;

You need to convert the attacker and client to UserId's again when you send the event.
Mitchell is offline
Reply



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 07:04.


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