Raised This Month: $ Target: $400
 0% 

[TF2] Killstreaks in killicons HUD


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Plaffy46
Junior Member
Join Date: Mar 2014
Old 09-29-2014 , 07:34   [TF2] Killstreaks in killicons HUD
Reply With Quote #1

So, I was wondering how we can add/edit/delete the killstreak value of the current weapon shown in killicons.
I tried messing up with killstreak_wep and killstreak_total things of the "player_death" event but this wouldn't do anything on killstreaked weapons (using tf2attributes).
I have been on a server where killstreaks numbers are shown after 5 kills, so I guess this is possible to edit them.

Can someone tell me what functions and events are fitted for this, please? (code example more than welcome!)

Last edited by Plaffy46; 09-29-2014 at 08:18.
Plaffy46 is offline
sheo
SourceMod Donor
Join Date: Jul 2013
Location: Russia, Moscow
Old 09-30-2014 , 02:02   Re: [TF2] Killstreaks in killicons HUD
Reply With Quote #2

Here is my version of plugin that enables killstreak count for everyone, you can take it as a snippet
Code:
#include <sourcemod>
#include <natives_and_forwards>

new iKillStreakCount[MAXPLAYERS + 1];


public Plugin:myinfo =
{
	name = "Killstreak for everyone",
	version = SOURCEMOD_VERSION,
	author = "Private"
}

public OnPluginStart()
{
	HookEvent("player_death", Event_PlayerDeath);
	HookEvent("player_spawn", Event_PlayerSpawn);
}

public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
	new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
	new killed = GetClientOfUserId(GetEventInt(event, "userid"));
	if (attacker != killed && NAF_IsClientReallyInGame(killed) && NAF_IsClientReallyInGame(attacker))
	{
		if (!(GetEventInt(event, "death_flags") & 32))
		{
			SetEntProp(killed, Prop_Send, "m_iKillStreak", 0);
		}
		new nowks = GetEntProp(attacker, Prop_Send, "m_iKillStreak");
		if (iKillStreakCount[attacker] == nowks)
		{
			SetEntProp(attacker, Prop_Send, "m_iKillStreak", nowks + 1);
			iKillStreakCount[attacker] = nowks + 1;
		}
		else if (iKillStreakCount[attacker] < nowks)
		{
			iKillStreakCount[attacker] = nowks;
		}
		else
		{
			iKillStreakCount[attacker] = 0;
		}
	}
}

public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if (IsClientInGame(client) && !IsFakeClient(client))
	{
		SetEntProp(client, Prop_Send, "m_iKillStreak", 0);
		iKillStreakCount[client] = 0;
	}
}
__________________

Last edited by sheo; 09-30-2014 at 02:03.
sheo is offline
Plaffy46
Junior Member
Join Date: Mar 2014
Old 09-30-2014 , 05:06   Re: [TF2] Killstreaks in killicons HUD
Reply With Quote #3

Ah, I was missing.the death flags thingy. Thank you!
Plaffy46 is offline
sheo
SourceMod Donor
Join Date: Jul 2013
Location: Russia, Moscow
Old 09-30-2014 , 06:19   Re: [TF2] Killstreaks in killicons HUD
Reply With Quote #4

Death flags are needed to determine whether the certain death was fake (spy`s DeadRinger) or not.
__________________

Last edited by sheo; 09-30-2014 at 06:19.
sheo is offline
Plaffy46
Junior Member
Join Date: Mar 2014
Old 09-30-2014 , 07:06   Re: [TF2] Killstreaks in killicons HUD
Reply With Quote #5

Ouch, sorry, I just literally had 15 seconds to read your code. So, yeah, this doesn't exactly answer my problem, playing with m_iKillstreak actually gives killstreaks, but what I want exactly is having the ability to edit the killstreak killicon value/presence (very probably related to "player_death" event) without having to enable/disable actual killstreaks on player/weapon.
For example, activating the killstreaks on a player as soon as he spawn, so he will keep track of his own killstreak (not the killicon one, but the counter which is constantly shown in the HUD), and simply not showing the counter in killicons, so you can distinguish his weapon from a genuine killstreak one, see what i mean?

Well, i'll guess i find another way then... Thanks for trying to help anyways!

Last edited by Plaffy46; 09-30-2014 at 07:06.
Plaffy46 is offline
rswallen
SourceMod Donor
Join Date: Jun 2013
Location: 127.0.0.1
Old 09-30-2014 , 14:39   Re: [TF2] Killstreaks in killicons HUD
Reply With Quote #6

Quote:
Originally Posted by Plaffy46 View Post
I tried messing up with killstreak_wep and killstreak_total things of the "player_death" event but this wouldn't do anything on killstreaked weapons (using tf2attributes).
I think your problem is due to typos - the relevant key you need to edit is kill_streak_wep (note the extra _ )

PHP Code:
#include <sourcemod>

#pragma semicolon 1

public OnPluginStart()
{
    
HookEvent("player_death"EventHook_PlayerDeathEventHookMode_Pre);
    return;
}

public 
Action:EventHook_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    
SetEventInt(event"kill_streak_wep"GetRandomInt(120));
    
    return 
Plugin_Continue;

__________________
rswallen is offline
Plaffy46
Junior Member
Join Date: Mar 2014
Old 10-01-2014 , 17:56   Re: [TF2] Killstreaks in killicons HUD
Reply With Quote #7

Yep, I used it with the correct typos, i actually took it from the Tf2 events wiki (forgot underscores on my post only) your code is basically the same as mine. Does it work for you? Maybe I actually have something conflicting which prevents it from working, there are a few crap plugins in my sm folder... gonna try that again tomorrow.
Thanks anyways!
Plaffy46 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 05:10.


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