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

No knife damage? [CS:GO]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
narwhalz
Junior Member
Join Date: Oct 2013
Old 03-13-2015 , 08:33   No knife damage? [CS:GO]
Reply With Quote #1

I've tried looking up for plugins that makes knives do no damage, i've seen some scripts, but they don't work perfectly, the closest one i could find was a script that removes knife damage, but the golden knife could still do damage.

I was planning on adding the knifeupgrade plugin, that let's you choose different knives (!karambit, !bayonet) etc, but the golden knife still do damage.
narwhalz is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 03-13-2015 , 10:42   Re: No knife damage? [CS:GO]
Reply With Quote #2

Past the script who was almost workibg here, too lazy to start from nothing.
__________________
Want to check my plugins ?
Arkarr is offline
narwhalz
Junior Member
Join Date: Oct 2013
Old 03-13-2015 , 15:14   Re: No knife damage? [CS:GO]
Reply With Quote #3

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

public OnPluginStart()
{
    
    for (new client = 1; client <= MaxClients; client++) 
    { 
        if (IsClientInGame(client)) 
        {
            SDKHook(client, SDKHook_OnTakeDamage, TakeDamageHook);
        }
    }
}

public OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_OnTakeDamage, TakeDamageHook);
}

public Action:TakeDamageHook(client, &attacker, &inflictor, &Float:damage, &damagetype)
{
    if ( (client>=1) && (client<=MaxClients) && (attacker>=1) && (attacker<=MaxClients) && (attacker==inflictor) )
    {
        decl String:WeaponName[64];
        GetClientWeapon(attacker, WeaponName, sizeof(WeaponName));
        if (StrEqual(WeaponName, "weapon_knife", false))
        {
            damage *= 0;
            return Plugin_Stop;
        }
    }
    return Plugin_Continue;
}
I'm using it for my HeadShot server, because they complain how frustrating people are knifing them is, so i want to keep knives and the knife plugin so players can "brag" about their knife, but still no knife damage. It was possible, but the golden knife still did damage. The mod it should interract with: https://forums.alliedmods.net/showthread.php?p=2160622

Last edited by narwhalz; 03-13-2015 at 15:18.
narwhalz is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 03-13-2015 , 15:20   Re: No knife damage? [CS:GO]
Reply With Quote #4

-Damage is a float so do damage = 0.0 then return Plugin_Changed instead of Plugin_Stop.
-Use StrContains(WeaponName, "knife", false) != -1 instead of StrEquals() to make sure you get the golden knife.
Darkness_ is offline
narwhalz
Junior Member
Join Date: Oct 2013
Old 03-13-2015 , 15:25   Re: No knife damage? [CS:GO]
Reply With Quote #5

Quote:
Originally Posted by Darkness_ View Post
-Damage is a float so do damage = 0.0 then return Plugin_Changed instead of Plugin_Stop.
-Use StrContains(WeaponName, "knife", false) != -1 instead of StrEquals() to make sure you get the golden knife.
Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public OnPluginStart()
{
    
    for (new client = 1; client <= MaxClients; client++) 
    { 
        if (IsClientInGame(client)) 
        {
            SDKHook(client, SDKHook_OnTakeDamage, TakeDamageHook);
        }
    }
}

public OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_OnTakeDamage, TakeDamageHook);
}

public Action:TakeDamageHook(client, &attacker, &inflictor, &Float:damage, &damagetype)
{
    if ( (client>=1) && (client<=MaxClients) && (attacker>=1) && (attacker<=MaxClients) && (attacker==inflictor) )
    {
        decl String:WeaponName[64];
        GetClientWeapon(attacker, WeaponName, sizeof(WeaponName));
        if StrContains(WeaponName, "knife", false) != -1)
        {
            damage *= 0,0;
            return Plugin_Changed;
        }
    }
    return Plugin_Continue;
}
Correct?
narwhalz is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 03-13-2015 , 15:38   Re: No knife damage? [CS:GO]
Reply With Quote #6

Try it out.
Darkness_ is offline
narwhalz
Junior Member
Join Date: Oct 2013
Old 03-13-2015 , 19:38   Re: No knife damage? [CS:GO]
Reply With Quote #7

Quote:
Originally Posted by Darkness_ View Post
Try it out.
Sourcemod online compiler forced me to edit my codes like this
Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public OnPluginStart()
{
    
    for (new client = 1; client <= MaxClients; client++) 
    { 
        if (IsClientInGame(client)) 
        {
            SDKHook(client, SDKHook_OnTakeDamage, TakeDamageHook);
        }
    }
}

public OnClientPutInServer(client)
{
    SDKHook(client, SDKHook_OnTakeDamage, TakeDamageHook);
}

public Action:TakeDamageHook(client, &attacker, &inflictor, &Float:damage, &damagetype)
{
    if ( (client>=1) && (client<=MaxClients) && (attacker>=1) && (attacker<=MaxClients) && (attacker==inflictor) )
    {
        decl String:WeaponName[64];
        GetClientWeapon(attacker, WeaponName, sizeof(WeaponName));
        if StrContains(WeaponName, "knife", false) != 0 *then
        {
            damage *= 0;
            return Plugin_Changed;
        }
    }
    return Plugin_Continue;
}
But it blocks all damage, from weapons etc, no one takes damage lol.
When i tried compile the code above it said:

/groups/sourcemod/upload_tmp/textb4WfFB.sp(2 : error 001: expected token: "*then", but found ")"
/groups/sourcemod/upload_tmp/textb4WfFB.sp(2 : error 029: invalid expression, assumed zero
/groups/sourcemod/upload_tmp/textb4WfFB.sp(30) : warning 215: expression has no effect

Last edited by narwhalz; 03-13-2015 at 19:39.
narwhalz is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 03-13-2015 , 21:47   Re: No knife damage? [CS:GO]
Reply With Quote #8

You forgot a '(' before StrContains, as well as some other things.
PHP Code:
public Action:TakeDamageHook(client, &attacker, &inflictor, &Float:damage, &damagetype)
{
    if ( (
client>=1) && (client<=MaxClients) && (attacker>=1) && (attacker<=MaxClients) && (attacker==inflictor) )
    {
        
decl String:WeaponName[64];
        
GetClientWeapon(attackerWeaponNamesizeof(WeaponName));
        if (
StrContains(WeaponName"knife"false) != -1)
        {
            
damage 0.0;
            return 
Plugin_Changed;
        }
    }
    return 
Plugin_Continue;


Last edited by Darkness_; 03-13-2015 at 21:48.
Darkness_ is offline
Sandervraun
Senior Member
Join Date: May 2019
Location: Denmark
Old 05-13-2022 , 14:39   Re: No knife damage? [CS:GO]
Reply With Quote #9

I have this plugin created.

Quote:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

public OnPluginStart()
{

for (new client = 1; client <= MaxClients; client++)
{
if (IsClientInGame(client))
{
SDKHook(client, SDKHook_OnTakeDamage, TakeDamageHook);
}
}
}

public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_OnTakeDamage, TakeDamageHook);
}

public Action:TakeDamageHook(client, &attacker, &inflictor, &Float:damage, &damagetype)
{
if ( (client>=1) && (client<=MaxClients) && (attacker>=1) && (attacker<=MaxClients) && (attacker==inflictor) )
{
decl String:WeaponName[64];
GetClientWeapon(attacker, WeaponName, sizeof(WeaponName));
if (StrEqual(WeaponName, "weapon_knife", false))
if (StrEqual(WeaponName, "weapon_knife_cord", false))
if (StrEqual(WeaponName, "weapon_knife_canis", false))
if (StrEqual(WeaponName, "weapon_knife_outdoor", false))
if (StrEqual(WeaponName, "weapon_knife_skeleton", false))
if (StrEqual(WeaponName, "weapon_knife_css", false))
if (StrEqual(WeaponName, "weapon_knife_ursus", false))
if (StrEqual(WeaponName, "weapon_knife_gypsy_jackknife", false))
if (StrEqual(WeaponName, "weapon_knife_stiletto", false))
if (StrEqual(WeaponName, "weapon_knife_widowmaker", false))
if (StrEqual(WeaponName, "weapon_knife_karambit", false))
if (StrEqual(WeaponName, "weapon_knife_m9_bayonet", false))
if (StrEqual(WeaponName, "weapon_bayonet", false))
if (StrEqual(WeaponName, "weapon_knife_survival_bowie", false))
if (StrEqual(WeaponName, "weapon_knife_butterfly", false))
if (StrEqual(WeaponName, "weapon_knife_flip", false))
if (StrEqual(WeaponName, "weapon_knife_push", false))
if (StrEqual(WeaponName, "weapon_knife_tactical", false))
if (StrEqual(WeaponName, "weapon_knife_falchion", false))
if (StrEqual(WeaponName, "weapon_knife_gut", false))
{
damage *= 0;
return Plugin_Stop;
}
}
return Plugin_Continue;
}
Sandervraun is offline
`666
AlliedModders Donor
Join Date: Jan 2006
Old 05-14-2022 , 04:07   Re: No knife damage? [CS:GO]
Reply With Quote #10

Just check for DMG_SLASH instead of adding bunch of knife names to check. Also I like to check for late load before running loop.

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdkhooks>
#include <sdktools>

bool g_bLateLoad;

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max) {
    
g_bLateLoad late;
    return 
APLRes_Success;
}

public 
void OnPluginStart() {
    if (
g_bLateLoad) {
        for (
int i 1<= MaxClientsi++) {
            if (!
IsClientInGame(i)) {
                continue;
            }
            
SDKHook(iSDKHook_OnTakeDamageOnTakeDamage);
        }
    }
}

public 
void OnClientPostAdminCheck(int client) {
    if (
client && client <= MaxClients) {
        
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
    }
}

public 
Action OnTakeDamage(int victimint &attackerint &inflictorfloat &damageint &damagetype) {
    if (
IsClientInGame(victim) && IsPlayerAlive(victim) && victim != attacker) {
        if (
damagetype DMG_SLASH) {
            return 
Plugin_Handled;
        }
    }
    return 
Plugin_Continue;

`666 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 09:20.


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