Raised This Month: $ Target: $400
 0% 

[REQ] TF2 Snipers Headshot Only


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
cybersquare420
Veteran Member
Join Date: Nov 2008
Old 03-20-2009 , 18:00   [REQ] TF2 Snipers Headshot Only
Reply With Quote #1

hello all, i run two TF2 100% crits servers and have noticed that since valve opened up the cross hairs to everyone the body shotting noob problem has exploded... i would like a plugin that limits the sniper rifle to head shots only (treat all bodyshots as misses)

i saw someone say u could do this by linking it to the crit function as thats how snipers crit... but all hits are crits on my server, so will need to watch the hitboxes or something else...

i think this will force a little skill back into the sniper class.

thank you in advance to anyone who can pull this off.. I will happily test any attempts on my servers or help in any other way that i can...

i can be reached easiest by joining my steam group "Toys in the Attic"

or at the clan website http://www.gametracker.com/clan/tia/


GAME ON!!!!
__________________

Last edited by cybersquare420; 03-21-2009 at 13:18.
cybersquare420 is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 03-20-2009 , 20:14   Re: [REQ] TF2 Snipers Headshot Only
Reply With Quote #2

Should be fairly easy to do. Just do some searching. Look at plugins like the headshot only plugin, saysounds,quakesounds that play sound files based on headshots.

I think this plugin is for css but, should be fairly easy to append to tf2. It supposedly blocks all damage except headshots in css.

Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#define VERSION "1.0.1"

public Plugin:myinfo =
{
    name = "Headshot Only",
    author = "XARiUS",
    description = "Plugin which prevents all damage but headshots.",
    version = "1.0.1",
    url = "http://www.the-otc.com/"
};

new String:language[4];
new String:languagecode[4];
new String:g_headsounds[256];
new String:headsounds[5][256];
new bool:g_enabled;
new bool:g_useambient;
new soundsfound;
new Handle:g_Cvarenabled = INVALID_HANDLE;
new Handle:g_Cvarheadsounds = INVALID_HANDLE;
new Handle:g_Cvaruseambient = INVALID_HANDLE;
new g_iHealth, g_Armor;

public OnPluginStart()
{
  LoadTranslations("headshotonly.phrases");
  GetLanguageInfo(GetServerLanguage(), languagecode, sizeof(languagecode), language, sizeof(language));
  CreateConVar("sm_headshotonly_version", VERSION, "Headshot Only", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  g_Cvarenabled = CreateConVar("sm_headshotonly_enabled", "1", "Enable this plugin. 0 = Disabled");
  g_Cvarheadsounds = CreateConVar("sm_headshotonly_sounds", "", "Sound files to indicate headshots. (Max: 5)  Leave blank for default sounds.");
  g_Cvaruseambient = CreateConVar("sm_headshotonly_useambient", "1", "Emit sounds from victim to all players.  0 = Emit sound from victim only to attacker.");

  HookEvent("player_hurt", EventPlayerHurt, EventHookMode_Pre);

  HookConVarChange(g_Cvarenabled, OnSettingChanged);
  HookConVarChange(g_Cvaruseambient, OnSettingChanged);
  AutoExecConfig(true, "headshotonly");

  g_iHealth = FindSendPropOffs("CCSPlayer", "m_iHealth");
  if (g_iHealth == -1)
  {
    SetFailState("[Headshot Only] Error - Unable to get offset for CSSPlayer::m_iHealth");
  }

  g_Armor = FindSendPropOffs("CCSPlayer", "m_ArmorValue");
  if (g_Armor == -1)
  {
    SetFailState("[Headshot Only] Error - Unable to get offset for CSSPlayer::m_ArmorValue");
  }
}

public OnConfigsExecuted()
{
  g_enabled = GetConVarBool(g_Cvarenabled);
  g_useambient = GetConVarBool(g_Cvaruseambient);

  GetConVarString(g_Cvarheadsounds, g_headsounds, sizeof(g_headsounds));
  if (!StrEqual(g_headsounds, "", false))
  {
    new String: buffer[256];
    soundsfound = ExplodeString(g_headsounds, ",", headsounds, 5, 64);
    if (soundsfound > 0)
    {
      for (new i = 0; i <= soundsfound -1; i++)
      {
        Format(buffer, PLATFORM_MAX_PATH, "headshotonly/%s", headsounds[i]);
        if (!PrecacheSound(buffer, true))
        {
          SetFailState("HeadShot Only: Could not pre-cache sound: %s", buffer);
        }
        else
        {
          Format(buffer, PLATFORM_MAX_PATH, "sound/headshotonly/%s", headsounds[i]);
          AddFileToDownloadsTable(buffer);
          buffer = "headshotonly/";
          StrCat(buffer, sizeof(buffer), headsounds[i]);
          headsounds[i] = buffer;
        }
      }
    }
    return;
  }
  soundsfound = 5;
  headsounds[0] = "physics/flesh/flesh_squishy_impact_hard1.wav";
  headsounds[1] = "physics/flesh/flesh_squishy_impact_hard2.wav";
  headsounds[2] = "physics/flesh/flesh_squishy_impact_hard3.wav";
  headsounds[3] = "physics/flesh/flesh_squishy_impact_hard4.wav";
  headsounds[4] = "physics/flesh/flesh_bloody_break.wav";
  PrecacheSound(headsounds[0], true);
  PrecacheSound(headsounds[1], true);
  PrecacheSound(headsounds[2], true);
  PrecacheSound(headsounds[3], true);
  PrecacheSound(headsounds[4], true);
}

public OnSettingChanged(Handle:convar, const String:oldValue[], const String:newValue[])
{
  if (convar == g_Cvarenabled)
  {
    if (newValue[0] == '1')
    {
            g_enabled = true;
            PrintHintTextToAll("%t", "Headshot enabled");
            EmitSoundToAll("player/bhit_helmet-1.wav");
    }
    else
    {
      g_enabled = false;
      PrintHintTextToAll("%t", "Headshot disabled");
      EmitSoundToAll("player/bhit_helmet-1.wav");
    }
  }
  if (convar == g_Cvaruseambient)
  {
    if (newValue[0] == '1')
    {
            g_useambient = true;
    }
    else
    {
      g_useambient = false;
    }
  }
}

public Action:EventPlayerHurt(Handle:event, const String:name[],bool:dontBroadcast)
{
  if (g_enabled)
  {
    new hitgroup = GetEventInt(event, "hitgroup");
    new victim = GetClientOfUserId(GetEventInt(event, "userid"));
    new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
    new dhealth = GetEventInt(event, "dmg_health");
    new darmor = GetEventInt(event, "dmg_armor");
    new health = GetEventInt(event, "health");
    new armor = GetEventInt(event, "armor");

    if (hitgroup == 1)
    {
      if (g_useambient)
      {
        new Float:vicpos[3];
        GetClientEyePosition(victim, vicpos);
        EmitAmbientSound(headsounds[GetRandomInt(0, soundsfound -1)], vicpos, victim, SNDLEVEL_GUNFIRE);
      }
      else
      {
        EmitSoundToClient(attacker, headsounds[GetRandomInt(0, soundsfound -1)], SOUND_FROM_PLAYER, SNDCHAN_AUTO, SNDLEVEL_RAIDSIREN);
      }
      return Plugin_Continue;
    }
    else if (attacker != victim && victim != 0 && attacker != 0)
    {
      if (dhealth > 0)
      {
        SetEntData(victim, g_iHealth, (health + dhealth), 4, true);
      }
      if (darmor > 0)
      {
        SetEntData(victim, g_Armor, (armor + darmor), 4, true);
      }
    }
  }
  return Plugin_Continue;
}
This is the headshot event for tf2 taken from saysounds.

Code:
if (GetGameType() == tf2)
    {
        new custom_kill = GetEventInt(event, "customkill");

        if (custom_kill == 1)
        {
            runSoundEvent(event,"kill","headshot");
            return Plugin_Continue;
        }
retsam is offline
cybersquare420
Veteran Member
Join Date: Nov 2008
Old 03-21-2009 , 07:39   Re: [REQ] TF2 Snipers Headshot Only
Reply With Quote #3

although i am fluent in OSPf, BGP, RIP, and most other enterprise routing protocols (I am a degree wielding network engineer), and very comfortable with the hardware and it's implementation,... i am worthless at coding... the simplest scripting is like pulling teeth to me.

in other words, even though this is probably an easy task, it is not within my skillset. I was hoping someone who enjoys this type of thing would take a crack at it... i have little to offer other than gratitude (and server privlidges)...lol

thnx to any and all efforts!!!
__________________
cybersquare420 is offline
atmuh
Member
Join Date: Nov 2008
Old 03-22-2009 , 12:11   Re: [REQ] TF2 Snipers Headshot Only
Reply With Quote #4

skill on an allcrit server?
atmuh is offline
cybersquare420
Veteran Member
Join Date: Nov 2008
Old 03-22-2009 , 19:38   Re: [REQ] TF2 Snipers Headshot Only
Reply With Quote #5

Quote:
Originally Posted by atmuh View Post
skill on an allcrit server?
troll... was that really helpful or necessary? unless u got something helpful or supportive to say... STFU
__________________
cybersquare420 is offline
cybersquare420
Veteran Member
Join Date: Nov 2008
Old 05-16-2009 , 08:52   Re: [REQ] TF2 Snipers Headshot Only
Reply With Quote #6

bump
__________________
cybersquare420 is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 05-16-2009 , 10:50   Re: [REQ] TF2 Snipers Headshot Only
Reply With Quote #7

Unfortunately I think you are going to need an extension for this. I tried using DukesHacks to stop player damage from the sniper rifle however with 100% crits on there is no way to differentiate between a headshot and a normal shot. I also tried hooking the player_death event as customkill = 1 from a sniper headshot however it is not possible to alter the outcome of the death without an extension.
Wazz is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 05-16-2009 , 11:26   Re: [REQ] TF2 Snipers Headshot Only
Reply With Quote #8

Criticals cause DMG_ACID I believe it is. (might be burn) So you could check the damagetype.
__________________
CrimsonGT is offline
MikeJS
Senior Member
Join Date: Nov 2008
Old 05-16-2009 , 11:58   Re: [REQ] TF2 Snipers Headshot Only
Reply With Quote #9

You'd have to modify the crits plugin to not affect snipers then do as Crimson said.
__________________
MikeJS is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 05-16-2009 , 12:10   Re: [REQ] TF2 Snipers Headshot Only
Reply With Quote #10

Aye that would work.
Wazz 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 10:13.


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