Raised This Month: $ Target: $400
 0% 

[TF2] Modify Sniper's Headshot Damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cooltad
Veteran Member
Join Date: Apr 2008
Old 12-17-2008 , 19:13   [TF2] Modify Sniper's Headshot Damage
Reply With Quote #1

a few months back deviouscreed made me this plugin:
Code:
#include <sourcemod>
#include <sdktools>

new maxplayers, maxents;
new TF_owneroffset;
new TF_CurrentWeapon;
new Handle: g_Sniper_Crit = INVALID_HANDLE;
new Handle: g_IsSniperCritOn = INVALID_HANDLE;
new bool:g_IsRunning = true;

public Plugin:myinfo = 
{
    name = "Sniper Crit Damage",
    author = "DeviusCreed",
    description = "Modifies Crit Damage of Sniper Headshots",
    version = "1.0",
    url = "<- URL ->"
}

public OnPluginStart()
{
    TF_owneroffset = FindSendPropOffs("CTFSniperRifle", "m_hOwner");
    TF_CurrentWeapon = FindSendPropOffs("CTFPlayer", "m_hActiveWeapon");
    
    g_Sniper_Crit = CreateConVar("sm_sniper_crit_dmg","1.0","Crit Damage Percent");
    g_IsSniperCritOn = CreateConVar("sm_sniper_crit_enabled","1"," 1 = enabled : 0 = disabled");
    
    HookConVarChange(g_Sniper_Crit, ConVarChange_Sniper_Crit);
    HookConVarChange(g_IsSniperCritOn, ConVarChange_IsSniperCritOn);
    HookEvent("player_hurt", Event_PlayerHurt)
}

public OnMapStart()
{
    maxplayers = GetMaxClients();
    maxents = GetMaxEntities();
}

public ConVarChange_IsSniperCritOn(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if (StringToInt(newValue) > 0)
    {
        g_IsRunning = true
        PrintToChatAll("Enabled Sniper Crit");
    }
    else
    {
        g_IsRunning = false;
        PrintToChatAll("Disabled Sniper Crit");
    }
}

public ConVarChange_Sniper_Crit(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if (StringToFloat(newValue) < 0.0 || StringToFloat(newValue) > 1.0)
    {
        SetConVarFloat(convar, StringToFloat(oldValue), false, false);
    }
}

public Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(!g_IsRunning)
        return;    
    
    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
    //new health = GetEventInt(event,"health");
    new ID = FindRifleByOwner(attacker);
    new weapon= GetEntDataEnt2(attacker, TF_CurrentWeapon)
        
    if(ID != 0 && ID == weapon){
        new Float:dmg = 150.0 - (150.0 * GetConVarFloat(g_Sniper_Crit))
        new ActualHealth = GetEntData(client, FindDataMapOffs(client, "m_iHealth"), 4)
        SetEntData(client, FindDataMapOffs(client, "m_iHealth"), (ActualHealth + RoundFloat(dmg)), 4)
    }
}

stock FindRifleByOwner(index){
    new i, String:classname[64];
    //Loop all entites
    for(i = maxplayers; i <= maxents; i++){
         //Is it valid?
         if(IsValidEntity(i)){
            GetEntityNetClass(i, classname, 64);
            if(StrEqual(classname, "CTFSniperRifle")){
                if(GetEntData(i, TF_owneroffset, 1) == index)
                    return i;
            }
        }
    }
    //Nothing found.
    return 0;
}
It had a problem, however, where it would allow the sniper to do damage to those charged with an uber. He then linked me to a new file for it which fixed it. However I am in need of the file again and the link is now broken on mediafire and he hasn't logged in in over 3 months.

So, would anyone be able to help me out here on fixing this code again?

Also, when compiled it gave these errors:
Code:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// snipercrit.sp
// D:\HLServer\orangebox\tf\addons\sourcemod\scripting\snipercrit.sp(28) : error
 100: function prototypes do not match
// D:\HLServer\orangebox\tf\addons\sourcemod\scripting\snipercrit.sp(29) : error
 100: function prototypes do not match
//
// 2 Errors.
//
// Compilation Time: 0.45 sec
// ----------------------------------------
__________________
Please, give me some rep if you found what I posted useful. :]

Last edited by Cooltad; 12-17-2008 at 19:40.
Cooltad 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 04:47.


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