An example could be if a player was to take over 99 damage with an AWP, instead of killing him, it just registers that -100 damage as a kill on the scoreboard but the player is left unharmed (edit: without having to use sv_godemode)
im not sure if something like this is possible because im still learning sp
Hook SDKHook_OnTakeDamage for check if damage >= current victim health, remove weapons and add a kill to the player and a dead to the victim with coding.
Hook SDKHook_OnTakeDamage for check if damage >= current victim health, remove weapons and add a kill to the player and a dead to the victim with coding.
Im not sure how to code this since im still a beginner at sp even though i've been looking over resources and researching it. any way for you to write that part for me so i can use it as a reference?
Hook SDKHook_OnTakeDamage for check if damage >= current victim health, remove weapons and add a kill to the player and a dead to the victim with coding.
So, you need to make it that when the player takes damage if it's more than his health the damage will be 0 and the attacker will get +1 frag.
I have 4 variations for you:
1. Check if Damage is more than victim's health + Check if the attacker has an AWP
Spoiler
PHP Code:
#include <sourcemod> #include <sdkhooks>
//Plugin Info public Plugin myinfo = { name = "Friendly Frags", author = "SniperHero", description = "Registering a frag without anyone dying.", version = "1.0", url = "https://steamcommunity.com/id/sniperheroofficialu" };
public void OnPluginStart() { for (int i = 1; i <= MaxClients; i++) { if (IsValidClient(i)) { SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage); } } }
public void OnClientPutInServer(int client) { //Hook OnTakeDamage when the player enters the server. SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); }
public void OnClientDisconnect(int client) { //Unhook OnTakeDamage when the player leaves the server. SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage); }
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype) { //Check if player is valid if (IsValidClient(attacker)) { //Get player's weapon char clientWep[128]; GetClientWeapon(attacker, clientWep, sizeof(clientWep));
//check if he has awp if (StrEqual(clientWep, "weapon_awp")) { //check if the damage is more than his health if (damage >= GetEntProp(victim, Prop_Send, "m_iHealth")) { //set the damage to 0 damage = 0.0; //set the frags to +1 SetClientFrags(attacker, GetClientFrags(attacker) + 1); return Plugin_Changed; //to make return that something is changed (the damage) } else { return Plugin_Continue; } } else { return Plugin_Continue; } }
2. Check if Damage is more than victim's health without AWP check
Spoiler
PHP Code:
#include <sourcemod> #include <sdkhooks>
//Plugin Info public Plugin myinfo = { name = "Friendly Frags", author = "SniperHero", description = "Registering a frag without anyone dying.", version = "1.0", url = "https://steamcommunity.com/id/sniperheroofficialu" };
public void OnPluginStart() { for (int i = 1; i <= MaxClients; i++) { if (IsValidClient(i)) { SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage); } } }
public void OnClientPutInServer(int client) { //Hook OnTakeDamage when the player enters the server. SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); }
public void OnClientDisconnect(int client) { //Unhook OnTakeDamage when the player leaves the server. SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage); }
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype) { //Check if player is valid if (IsValidClient(attacker)) { //check if the damage is more than his health if (damage >= GetEntProp(victim, Prop_Send, "m_iHealth")) { //set the damage to 0 damage = 0.0; //set the frags to +1 SetClientFrags(attacker, GetClientFrags(attacker) + 1); return Plugin_Changed; //to make return that something is changed (the damage) } else { return Plugin_Continue; } }
3. Just sets the damage to 0 always and adds 1 frag to the attacker
Spoiler
PHP Code:
#include <sourcemod> #include <sdkhooks>
//Plugin Info public Plugin myinfo = { name = "Friendly Frags", author = "SniperHero", description = "Registering a frag without anyone dying.", version = "1.0", url = "https://steamcommunity.com/id/sniperheroofficialu" };
public void OnPluginStart() { for (int i = 1; i <= MaxClients; i++) { if (IsValidClient(i)) { SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage); } } }
public void OnClientPutInServer(int client) { //Hook OnTakeDamage when the player enters the server. SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); }
public void OnClientDisconnect(int client) { //Unhook OnTakeDamage when the player leaves the server. SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage); }
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype) { //Check if player is valid if (IsValidClient(attacker)) { //set the damage to 0 damage = 0.0; //set the frags to +1 SetClientFrags(attacker, GetClientFrags(attacker) + 1); return Plugin_Changed; //to make return that something is changed (the damage) }
4. Just sets the damage to 0 always and adds 1 frag to the attacker + check for AWP
Spoiler
PHP Code:
#include <sourcemod> #include <sdkhooks>
//Plugin Info public Plugin myinfo = { name = "Friendly Frags", author = "SniperHero", description = "Registering a frag without anyone dying.", version = "1.0", url = "https://steamcommunity.com/id/sniperheroofficialu" };
public void OnPluginStart() { for (int i = 1; i <= MaxClients; i++) { if (IsValidClient(i)) { SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage); } } }
public void OnClientPutInServer(int client) { //Hook OnTakeDamage when the player enters the server. SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); }
public void OnClientDisconnect(int client) { //Unhook OnTakeDamage when the player leaves the server. SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage); }
public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype) { //Check if player is valid if (IsValidClient(attacker)) { //Get player's weapon char clientWep[128]; GetClientWeapon(attacker, clientWep, sizeof(clientWep));
//check if he has awp if (StrEqual(clientWep, "weapon_awp")) { //set the damage to 0 damage = 0.0; //set the frags to +1 SetClientFrags(attacker, GetClientFrags(attacker) + 1); return Plugin_Changed; //to make return that something is changed (the damage) } else { return Plugin_Continue; } }