Raised This Month: $ Target: $400
 0% 

No pistol damage plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tanttinen
Junior Member
Join Date: Jan 2023
Old 02-22-2023 , 09:15   No pistol damage plugin
Reply With Quote #1

I'm makeing a csgo server and need a plugin that disables pistol damage. I have managed to make some code but it doesn't work. Thanks if you try to help

code:
#include <sourcemod>

#define WEAPON_GLOCK 4
#define WEAPON_HKP2000 32
#define WEAPON_USP_SILENCER 61
#define WEAPON_P250 36
#define WEAPON_TEC9 30
#define WEAPON_FIVESEVEN 3
#define WEAPON_CZ75A 63
#define WEAPON_REVOLVER 64

public Action OnTakeDamage(int victim, int attacker, float damage, int damageType, int weaponIndex)
{
if (weaponIndex == WEAPON_GLOCK || weaponIndex == WEAPON_HKP2000 || weaponIndex == WEAPON_USP_SILENCER || weaponIndex == WEAPON_P250 || weaponIndex == WEAPON_TEC9 || weaponIndex == WEAPON_FIVESEVEN || weaponIndex == WEAPON_CZ75A || weaponIndex == WEAPON_REVOLVER)
{
damage = 0.0;
return Plugin_Handled;
}
return Plugin_Continue;
}

(looks like the spacing is fucked up cuz i dont know how to add code properly)
Tanttinen is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 02-22-2023 , 09:33   Re: No pistol damage plugin
Reply With Quote #2

I don't think that "weaponIndex" is what you think.

Check: https://github.com/alliedmodders/sou...e/sdkhooks.inc

Is the weapon entity Index, not the weapon id (different things)
__________________
Marttt is offline
Tanttinen
Junior Member
Join Date: Jan 2023
Old 02-22-2023 , 11:18   Re: No pistol damage plugin
Reply With Quote #3

so this better? But it still isn't working:

#include <sourcemod>


public Action TakeDamageHook(int client, int &attacker, int &inflictor, float &damage, int &damagetype)
{
char WeaponName[64];
GetClientWeapon(attacker, WeaponName, sizeof(WeaponName));
if (StrContains(WeaponName, "weapon_glock") != -1 || StrEqual(WeaponName, "weapon_hkp2000") || StrEqual(WeaponName, "weapon_usp_silencer"))
{
damage = 0.0;
return Plugin_Changed;
}
return Plugin_Continue;
}
Tanttinen is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 02-22-2023 , 12:03   Re: No pistol damage plugin
Reply With Quote #4

Better check some plugin examples

You need hook something (a player)

https://forums.alliedmods.net/showthread.php?t=248095
__________________
Marttt is offline
Naathy
Member
Join Date: Mar 2022
Location: Brazil
Old 02-23-2023 , 04:56   Re: No pistol damage plugin
Reply With Quote #5

Quote:
Originally Posted by Tanttinen View Post
I'm makeing a csgo server and need a plugin that disables pistol damage. I have managed to make some code but it doesn't work. Thanks if you try to help

code:
#include <sourcemod>

#define WEAPON_GLOCK 4
#define WEAPON_HKP2000 32
#define WEAPON_USP_SILENCER 61
#define WEAPON_P250 36
#define WEAPON_TEC9 30
#define WEAPON_FIVESEVEN 3
#define WEAPON_CZ75A 63
#define WEAPON_REVOLVER 64

public Action OnTakeDamage(int victim, int attacker, float damage, int damageType, int weaponIndex)
{
if (weaponIndex == WEAPON_GLOCK || weaponIndex == WEAPON_HKP2000 || weaponIndex == WEAPON_USP_SILENCER || weaponIndex == WEAPON_P250 || weaponIndex == WEAPON_TEC9 || weaponIndex == WEAPON_FIVESEVEN || weaponIndex == WEAPON_CZ75A || weaponIndex == WEAPON_REVOLVER)
{
damage = 0.0;
return Plugin_Handled;
}
return Plugin_Continue;
}

(looks like the spacing is fucked up cuz i dont know how to add code properly)
Put the code inside php tags, its better to read.

~~btw

You dont need to define weapons, just include cstrike file. List of guns here

To use OnTakeDamage, do it:
PHP Code:
public void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_OnTakeDamage_SDKHook_OnTakeDamage);

Also, when you return Plugin_Handled, you're already blocking the damage. No need to put " damage = 0.0; ".

Last, dont return Plugin_Continue in this case. Instead, return Plugin_Changed.
__________________
Owner of NGServers

Contact
Discord | Steam | Github

Last edited by Naathy; 02-23-2023 at 05:02.
Naathy is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-23-2023 , 08:21   Re: No pistol damage plugin
Reply With Quote #6

https://sm.alliedmods.net/new-api/cstrike/__raw

https://sm.alliedmods.net/new-api/cstrike


https://sm.alliedmods.net/new-api/sdkhooks/SDKHookCB
PHP Code:

#include <sdkhooks>
#include <cstrike>






...






public 
Action OnTakeDamage(int victimintattackerintinflictorfloatdamageintdamagetypeintweaponfloat damageForce[3], float damagePosition[3])
{
    if(
weapon <= MaxClients)
        return 
Plugin_Continue;

    
CSWeaponID weaponID CSWeapon_NONE;

    
// csgo
    
if(HasEntProp(weaponProp_Send"m_iItemDefinitionIndex"))
    {
        
weaponID CS_ItemDefIndexToID(GetEntProp(weaponProp_Send"m_iItemDefinitionIndex"));
    }
    else 
// cstrike
    
{
        
char buffer[50];
        
GetEntityClassname(weaponbuffersizeof(buffer));
        
        
CS_GetTranslatedWeaponAlias(bufferbuffersizeof(buffer));
        
weaponID CS_AliasToWeaponID(buffer);
    }

    if(!
CS_IsValidWeaponID(weaponID))
        return 
Plugin_Continue;


    switch(
weaponID)
    {
        case 
CSWeapon_P228CSWeapon_GLOCKCSWeapon_ELITECSWeapon_FIVESEVENCSWeapon_USPCSWeapon_DEAGLECSWeapon_TEC9,
        
CSWeapon_P250CSWeapon_USP_SILENCERCSWeapon_CZ75ACSWeapon_REVOLVER:
        {
            
PrintToServer("Hey you used pistol!");
            
            return 
Plugin_Handled;
        }
    }


    return 
Plugin_Continue;

__________________
Do not Private Message @me
Bacardi is offline
Tanttinen
Junior Member
Join Date: Jan 2023
Old 02-23-2023 , 10:53   Re: No pistol damage plugin
Reply With Quote #7

Quote:
Originally Posted by Naathy View Post
Put the code inside php tags, its better to read.

~~btw

You dont need to define weapons, just include cstrike file. List of guns here

To use OnTakeDamage, do it:
PHP Code:
public void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_OnTakeDamage_SDKHook_OnTakeDamage);

Also, when you return Plugin_Handled, you're already blocking the damage. No need to put " damage = 0.0; ".

Last, dont return Plugin_Continue in this case. Instead, return Plugin_Changed.

Thanks alot for the help trying to get it to work
Tanttinen is offline
Tanttinen
Junior Member
Join Date: Jan 2023
Old 02-23-2023 , 10:54   Re: No pistol damage plugin
Reply With Quote #8

Quote:
Originally Posted by Bacardi View Post
https://sm.alliedmods.net/new-api/cstrike/__raw

https://sm.alliedmods.net/new-api/cstrike


https://sm.alliedmods.net/new-api/sdkhooks/SDKHookCB
PHP Code:

#include <sdkhooks>
#include <cstrike>






...






public 
Action OnTakeDamage(int victimintattackerintinflictorfloatdamageintdamagetypeintweaponfloat damageForce[3], float damagePosition[3])
{
    if(
weapon <= MaxClients)
        return 
Plugin_Continue;

    
CSWeaponID weaponID CSWeapon_NONE;

    
// csgo
    
if(HasEntProp(weaponProp_Send"m_iItemDefinitionIndex"))
    {
        
weaponID CS_ItemDefIndexToID(GetEntProp(weaponProp_Send"m_iItemDefinitionIndex"));
    }
    else 
// cstrike
    
{
        
char buffer[50];
        
GetEntityClassname(weaponbuffersizeof(buffer));
        
        
CS_GetTranslatedWeaponAlias(bufferbuffersizeof(buffer));
        
weaponID CS_AliasToWeaponID(buffer);
    }

    if(!
CS_IsValidWeaponID(weaponID))
        return 
Plugin_Continue;


    switch(
weaponID)
    {
        case 
CSWeapon_P228CSWeapon_GLOCKCSWeapon_ELITECSWeapon_FIVESEVENCSWeapon_USPCSWeapon_DEAGLECSWeapon_TEC9,
        
CSWeapon_P250CSWeapon_USP_SILENCERCSWeapon_CZ75ACSWeapon_REVOLVER:
        {
            
PrintToServer("Hey you used pistol!");
            
            return 
Plugin_Handled;
        }
    }


    return 
Plugin_Continue;

the code isn't working but it still gives me some idea how to do it
Tanttinen is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 02-23-2023 , 11:20   Re: No pistol damage plugin
Reply With Quote #9

exactly
__________________
Do not Private Message @me
Bacardi is offline
Tanttinen
Junior Member
Join Date: Jan 2023
Old 02-23-2023 , 12:56   Re: No pistol damage plugin
Reply With Quote #10

Quote:
Originally Posted by Bacardi View Post
exactly
Seems like you wanted to see if I understood anything from the previous posts . But thanks alot got it to working!
Tanttinen 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 03:10.


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