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_Damage, ADMFLAG_ROOT);
}
RegCvars() {
CreateConVar("sm_idamage_version", PLUGIN_VERSION, "Infinite damage version.", FCVAR_SPONLY || FCVAR_NOTIFY || FCVAR_DONTRECORD);
}
/* Commands ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
public Action Cmd_Damage(client, args) {
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
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 client, bool bAllowBots = false, bool bAllowDead = true) {
if (!(1 <= 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.