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

[TF2] SDKHooks_OnTakeDamage Script Not Working


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 09-01-2017 , 12:41   [TF2] SDKHooks_OnTakeDamage Script Not Working
Reply With Quote #1

Long story short, this script i'm coding isn't working.

PHP Code:
#include <sourcemod>
#include <sdkhooks>

#pragma semicolon 1

#define PLUGIN_VERSION "1.0.0"

new bool:bInfiniteDamage[MAXPLAYERS 1];

/* Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

public Plugin myinfo = {
    
name        "Infinite Damage",
    
author      "Sgt. Gremulock",
    
description "Instantly kills players on the first hit from any weapon with a command.",
    
version     PLUGIN_VERSION,
    
url         "grem-co.com"
};

public 
void OnPluginStart() {
    
RegCmds();
    
RegCvars();
}

RegCmds() {
    
RegAdminCmd("sm_idamage"Cmd_DamageADMFLAG_ROOT);
}

RegCvars() {
    
CreateConVar("sm_idamage_version"PLUGIN_VERSION"Infinite damage version."FCVAR_SPONLY || FCVAR_NOTIFY || FCVAR_DONTRECORD);
}

/* Commands ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

public Action Cmd_Damage(clientargs) {
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
    if (
IsValidClient(client)) {
        if (!
bInfiniteDamage[client]) {
            
bInfiniteDamage[client] = true;
            
PrintToChat(client"[SM] You have enabled infinite damage.");
        } else {
            
bInfiniteDamage[client] = false;
            
PrintToChat(client"[SM] You have disabled infinite damage.");
        }
    }
    return 
Plugin_Handled;
}

/* Events ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

public Action OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype) {
    if (
IsValidClient(victim) && IsValidClient(attacker)) {
        if (
bInfiniteDamage[attacker]) {
            
damage 255.0;
            return 
Plugin_Changed;
        }
    }
    return 
Plugin_Continue;
}

/* Stocks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

stock bool IsValidClient(int clientbool bAllowBots falsebool bAllowDead true) {
    if (!(
<= client <= MaxClients) || !IsClientInGame(client) || (IsFakeClient(client) && !bAllowBots) || IsClientSourceTV(client) || IsClientReplay(client) || (!bAllowDead && !IsPlayerAlive(client))) { 
        return 
false;
    }
    return 
true;

There is nothing in my error logs. Any help would be greatly appreciated!

EDIT: The command works and that but just the damage isn't modified.

Last edited by ThatKidWhoGames; 09-01-2017 at 12:42.
ThatKidWhoGames is offline
 



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 12:14.


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