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

Team Killing Bonus


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Snafu
Junior Member
Join Date: Oct 2008
Old 10-07-2008 , 15:15   Team Killing Bonus
Reply With Quote #1

So, I've looked through a couple pieces of source code for TK revenge scripts in hopes to find a way to modify the lost of a point, and add a point for TKs. Of course my search was unsuccessful.

So, I'm here to ask, is this even possible? I've spent hours going through the sourcemod functions, and found nothing. I'm hoping I overlooked something. Thanks in advance.
Snafu is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 10-07-2008 , 15:37   Re: Team Killing Bonus
Reply With Quote #2

Quote:
Originally Posted by Snafu View Post
So, I've looked through a couple pieces of source code for TK revenge scripts in hopes to find a way to modify the lost of a point, and add a point for TKs. Of course my search was unsuccessful.

So, I'm here to ask, is this even possible? I've spent hours going through the sourcemod functions, and found nothing. I'm hoping I overlooked something. Thanks in advance.
Erm.....do i get that right? You want to add a kill to the scores of
a teamkiller?
FeuerSturm is offline
Snafu
Junior Member
Join Date: Oct 2008
Old 10-07-2008 , 17:33   Re: Team Killing Bonus
Reply With Quote #3

Yes, that is correct.
Snafu is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 10-08-2008 , 01:00   Re: Team Killing Bonus
Reply With Quote #4

Quote:
Originally Posted by Snafu View Post
Yes, that is correct.
PHP Code:
SetEntProp(clientProp_Data"m_iFrags"GetClientFrags(client)+1
I don't know why someone would bonus a teamkiller, anyways,
the above code should work
FeuerSturm is offline
Snafu
Junior Member
Join Date: Oct 2008
Old 10-08-2008 , 13:36   Re: Team Killing Bonus
Reply With Quote #5

Awesome, thanks! Yeah, it's an odd request, but there is a point to it all.
Snafu is offline
Snafu
Junior Member
Join Date: Oct 2008
Old 10-08-2008 , 15:35   Re: Team Killing Bonus
Reply With Quote #6

Sorry for my ignorance, but something isn't working, and I can't see what I'm overlooking. Here's what I have so far.

Code:
#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "0.1"


public OnPluginLoad()
{
    HookEvent("player_death",Event_PlayerDeath);
}

public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new clientID = GetEventInt(event,"userid");
    new client = GetClientOfUserId(clientID);
    SetEntProp(client, Prop_Data, "m_iFrags", GetClientFrags(client)+1);
}
It compiles without errors, and is show in the sm plugin list. Also, zero errors from the console.

Thanks in advance.
Snafu is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 10-08-2008 , 15:39   Re: Team Killing Bonus
Reply With Quote #7

Quote:
Originally Posted by Snafu View Post
Sorry for my ignorance, but something isn't working, and I can't see what I'm overlooking. Here's what I have so far.

Code:
#include <sourcemod>
#include <sdktools>
 
#define PLUGIN_VERSION "0.1"
 
 
public OnPluginLoad()
{
    HookEvent("player_death",Event_PlayerDeath);
}
 
public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new clientID = GetEventInt(event,"userid");
    new client = GetClientOfUserId(clientID);
    SetEntProp(client, Prop_Data, "m_iFrags", GetClientFrags(client)+1);
}
It compiles without errors, and is show in the sm plugin list. Also, zero errors from the console.

Thanks in advance.
It has to be
PHP Code:
OnPluginStart() 
and not "OnPluginLoad()",
that's why the hook isn't working.

Furthermore that would add a Kill to every player that dies.
FeuerSturm is offline
Snafu
Junior Member
Join Date: Oct 2008
Old 10-08-2008 , 16:50   Re: Team Killing Bonus
Reply With Quote #8

Thanks again! I thought I had it, but now every time someone kills another team-mate, it crashes the server. Here's what I have (Probably a stupid mistake on my part, and debug doesn't mention anything obvious):

Code:
#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "0.2"


public OnPluginStart()
{
    HookEvent("player_death",Event_PlayerKill);
}

public Action:Event_PlayerKill(Handle:event, const String:name[], bool:dontBroadcast)
{
    new clientID = GetEventInt(event,"attacker");
    new client = GetClientOfUserId(clientID);
    SetEntProp(client, Prop_Data, "m_iFrags", GetClientFrags(client)+1);
}
Snafu is offline
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 10-08-2008 , 17:32   Re: Team Killing Bonus
Reply With Quote #9

I would do it like that, so you can be sure that you only add a kill
if it really was a teamkill:

PHP Code:
public OnPluginStart()
{
    
HookEventEx("player_death"Event_PlayerKillEventHookMode_Post)
}
public 
Action:Event_PlayerKill(Handle:event, const String:name[], bool:dontBroadcast)
{
 
// Get Client "Attacker"
 
new attackerid GetClientOfUserId(GetEventInt(event"attacker"))
 
 
// Get Client "Victim"
 
new victimid GetClientOfUserId(GetEventInt(event"userid"))
 
 
// Get Attacker's Team
 
new attackerteam GetClientTeam(attackerid)
 
 
// Get Victim's Team
 
new victimteam GetClientTeam(victimid)
 
 
// If they're both on same Team -> TeamKill
 
if(attackerteam == victimteam)
 {
  
// Add a Kill to Attacker's Scores
  
SetEntProp(attackeridProp_Data"m_iFrags"GetClientFrags(attackerid)+1)
 }
 return 
Plugin_Continue

Try that out and let me know if your server still crashes
FeuerSturm is offline
Snafu
Junior Member
Join Date: Oct 2008
Old 10-08-2008 , 17:48   Re: Team Killing Bonus
Reply With Quote #10

Yeah, exact same thing. As soon as someone tries to tk, the server segfaults. Checked the core file, and of course, nothing but:

Code:
(gdb) core-file srcds_i486.core
Core was generated by `srcds_i486'.
Program terminated with signal 11, Segmentation fault.
#0  0x2acc4757 in ?? ()
I'll probably try it on another server, and see if it does the same, but doesn't really make sense why it would crash. Maybe the game, who knows. Thanks again for all your help and effort.
Snafu 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 15:55.


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