Raised This Month: $120 Target: $400
 30% 

[CSGO] Axe and hammer pick up


Post New Thread Reply   
 
Thread Tools Display Modes
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 12-09-2018 , 11:54   Re: [CSGO] Axe and hammer pick up
Reply With Quote #11

Quote:
Originally Posted by Papero View Post
This will make you pickup all the new melee weapons.
Note that this is intended to be used with mp_drop_knife_enable set to 1, or you won't be able to drop your knife to pickup a dropped axe/wrench/hammer.
Well done, thats how I would have written it, maybe release it as a plugin in the plugins section?

Quote:
Originally Posted by Papero View Post
I've attached another plugin, if you'd like to play with the breaching charges throwing more than 3 at the same time, just use sm_breaches and it will fill you breach charge amount.
ammo_grenade_limit_breachcharge could have the same effect, maybe, or at least allows you to stack more

PS:

ammo_grenade_limit_breachcharge 3
mp_death_drop_breachcharge 1
sv_breachcharge_arm_delay 0.3
sv_breachcharge_delay_max 0.8
sv_breachcharge_delay_min 0
sv_breachcharge_distance_max 1200
sv_breachcharge_distance_min 600
sv_breachcharge_fuse_max 1.0
sv_breachcharge_fuse_min 0.7

AND forgot to mention in my last post about healthshot changes:

healthshot_allow_use_at_full 1 // Maybe doesn't heal more, but other effects can be used
healthshot_healthboost_time 10 // HP regen over time + time for next 2 cvars
healthshot_healthboost_damage_multiplier 0.5 // Multiply incomming damage, intended to be set between 0.0 and 1.0
healthshot_healthboost_speed_multiplier 1.5 // Multiply movement speed
__________________

Last edited by zipcore; 12-09-2018 at 11:58.
zipcore is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 12-09-2018 , 13:37   Re: [CSGO] Axe and hammer pick up
Reply With Quote #12

Quote:
Originally Posted by zipcore View Post
...
A money plugin killing floor style is now possible, ...
https://forums.alliedmods.net/showthread.php?p=2558324
__________________
free software
coding
shanapu is offline
root88
Senior Member
Join Date: May 2016
Old 12-09-2018 , 14:39   Re: [CSGO] Axe and hammer pick up
Reply With Quote #13

Quote:
Originally Posted by Papero View Post
This will make you pickup all the new melee weapons.
Note that this is intended to be used with mp_drop_knife_enable set to 1, or you won't be able to drop your knife to pickup a dropped axe/wrench/hammer.
PHP Code:
public void OnPluginStart()
{
    
//Lateload
    
for (int i 1<= MaxClientsi++) if (IsClientInGame(i)) OnClientPutInServer(i);
}

public 
void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_WeaponCanUseHook_WeaponCanUse);
}

public 
Action Hook_WeaponCanUse(int clientint weapon)
{
    
char classname[64];
    
GetEntityClassname(weaponclassnamesizeof classname);
    
    if (
StrEqual(classname"weapon_melee") && !(HasWeapon(client"weapon_melee") || HasWeapon(client"weapon_knife")))
        
EquipPlayerWeapon(clientweapon);
}

stock bool HasWeapon(int client, const char[] classname)
{
    
int index;
    
int weapon;
    
char sName[64];
    
    while((
weapon GetNextWeapon(clientindex)) != -1)
    {
        
GetEdictClassname(weaponsNamesizeof(sName));
        if (
StrEqual(sNameclassname))
            return 
true;
    }
    return 
false;
}

stock int GetNextWeapon(int clientint &weaponIndex)
{
    static 
int weaponsOffset = -1;
    if (
weaponsOffset == -1)
        
weaponsOffset FindDataMapInfo(client"m_hMyWeapons");
    
    
int offset weaponsOffset + (weaponIndex 4);
    
    
int weapon;
    while (
weaponIndex 48
    {
        
weaponIndex++;
        
        
weapon GetEntDataEnt2(clientoffset);
        
        if (
IsValidEdict(weapon)) 
            return 
weapon;
        
        
offset += 4;
    }
    
    return -
1;

I've attached another plugin, if you'd like to play with the breaching charges throwing more than 3 at the same time, just use sm_breaches and it will fill you breach charge amount.
Thanks!

Quote:
Originally Posted by zipcore View Post
Well done, thats how I would have written it, maybe release it as a plugin in the plugins section?



ammo_grenade_limit_breachcharge could have the same effect, maybe, or at least allows you to stack more

PS:

ammo_grenade_limit_breachcharge 3
mp_death_drop_breachcharge 1
sv_breachcharge_arm_delay 0.3
sv_breachcharge_delay_max 0.8
sv_breachcharge_delay_min 0
sv_breachcharge_distance_max 1200
sv_breachcharge_distance_min 600
sv_breachcharge_fuse_max 1.0
sv_breachcharge_fuse_min 0.7

AND forgot to mention in my last post about healthshot changes:

healthshot_allow_use_at_full 1 // Maybe doesn't heal more, but other effects can be used
healthshot_healthboost_time 10 // HP regen over time + time for next 2 cvars
healthshot_healthboost_damage_multiplier 0.5 // Multiply incomming damage, intended to be set between 0.0 and 1.0
healthshot_healthboost_speed_multiplier 1.5 // Multiply movement speed
I've tested ammo_grenade_limit_breachcharge yesterday and it wasn't working.
__________________
root88 is offline
root88
Senior Member
Join Date: May 2016
Old 12-10-2018 , 16:30   Re: [CSGO] Axe and hammer pick up
Reply With Quote #14

Any ideas how to remove axes etc from player inventory for example on round end?
This
PHP Code:
public Action Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    for(
int client 1client <= MaxClientsclient++)
    {
        if (
IsClientInGame(client) && !IsFakeClient(client) && IsPlayerAlive(client))
        {
            
int knifes GetPlayerWeaponSlot(clientCS_SLOT_KNIFE);
            for (
int x 0<= 10x++)//just for test
            
{
                if(
IsValidEntity(knifes) && knifes != INVALID_ENT_REFERENCE)
                {
                    
RemovePlayerItem(clientknifes);
                    if(
IsValidEdict(knifes))//sometimes: Exception reported: Edict 454 (454) is not a valid edict
                    
{
                        
RemoveEdict(knifes);
                    }
                }
            }
        }
    }

doesn't work. AcceptEntityInput(knifes, "Kill") doesn't work either.

And also removing healtshot stop working after Danger Zone update because it has changed healtshot slot from C4 to...? Any ideas? Old code for removing healthshots, working before update:
PHP Code:
public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
    for(new 
client 1client <= MaxClientsclient++)
    {
        if (
IsClientInGame(client))
        {
            if((!
IsFakeClient(client)) && (IsPlayerAlive(client)))
            {
                for (new 
1<= 2x++)
                {
                    new 
c4 GetPlayerWeaponSlot(client4);
                    if(
IsValidEntity(c4) && c4 != INVALID_ENT_REFERENCE)
                    {
                        
RemovePlayerItem(clientc4);
                        
//RemoveEdict(c4);
                        
AcceptEntityInput(c4"Kill");
                    }
                }
            }
        }
    }

__________________

Last edited by root88; 12-10-2018 at 16:31.
root88 is offline
zipcore
Veteran Member
Join Date: Mar 2010
Location: m_flZipcore
Old 12-11-2018 , 10:39   Re: [CSGO] Axe and hammer pick up
Reply With Quote #15

When you grab the weapon by slot you can get the wrong weapon if there are multiple weapons on the same slot (like knife and axe). You have to cycle m_hMyWeapons to grab all of them.
__________________
zipcore is offline
root88
Senior Member
Join Date: May 2016
Old 12-11-2018 , 11:15   Re: [CSGO] Axe and hammer pick up
Reply With Quote #16

Quote:
Originally Posted by zipcore View Post
When you grab the weapon by slot you can get the wrong weapon if there are multiple weapons on the same slot (like knife and axe).
Yeah I know, that for loop was to remove all weapons from selected slot.
Quote:
Originally Posted by zipcore View Post
You have to cycle m_hMyWeapons to grab all of them.
Thanks! I will try it later.
__________________
root88 is offline
Bara
AlliedModders Donor
Join Date: Apr 2012
Location: Germany
Old 12-11-2018 , 13:58   Re: [CSGO] Axe and hammer pick up
Reply With Quote #17

https://github.com/Bara/TroubleinTer.../ttt.inc#L1030
Spanner, Axe and Hammer are known as "weapon_melee".

//Edit:
Code:
stock int TTT_HasClientMelee(int client)
{
    for(int offset = 0; offset < 128; offset += 4)
    {
        int weapon = GetEntDataEnt2(client, FindSendPropInfo("CBasePlayer", "m_hMyWeapons") + offset);

        if (IsValidEntity(weapon))
        {
            char sClass[32];
            GetEntityClassname(weapon, sClass, sizeof(sClass));

            if ((StrContains(sClass, "melee", false) != -1))
            {
                return weapon;
            }
        }
    }

    return -1;
}
__________________
Steam | More plugins | Discord: Bara#1676

Last edited by Bara; 12-11-2018 at 14:17.
Bara is offline
root88
Senior Member
Join Date: May 2016
Old 12-11-2018 , 17:31   Re: [CSGO] Axe and hammer pick up
Reply With Quote #18

Quote:
Originally Posted by Bara View Post
https://github.com/Bara/TroubleinTer.../ttt.inc#L1030
Spanner, Axe and Hammer are known as "weapon_melee".

//Edit:
Code:
stock int TTT_HasClientMelee(int client)
{
    for(int offset = 0; offset < 128; offset += 4)
    {
        int weapon = GetEntDataEnt2(client, FindSendPropInfo("CBasePlayer", "m_hMyWeapons") + offset);

        if (IsValidEntity(weapon))
        {
            char sClass[32];
            GetEntityClassname(weapon, sClass, sizeof(sClass));

            if ((StrContains(sClass, "melee", false) != -1))
            {
                return weapon;
            }
        }
    }

    return -1;
}
It's working great, thank you!

In case someone need it, I've modified Papero plugin:
  • it will give random melee on player spawn
  • it will remove all meles on round end
  • it will allow knife pickup

PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>
#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawn);
    
HookEvent("round_end"Event_RoundEndEventHookMode_PostNoCopy);
    
//Lateload 
    
for (int i 1<= MaxClientsi++) if (IsClientInGame(i)) OnClientPutInServer(i);
}

public 
void OnMapStart()
{
    
ServerCommand("mp_drop_knife_enable 1");
}

public 
void OnClientPutInServer(int client

    
SDKHook(clientSDKHook_WeaponCanUseHook_WeaponCanUse); 


public 
Action Hook_WeaponCanUse(int clientint weapon

    
char classname[64]; 
    
GetEntityClassname(weaponclassnamesizeof classname); 
     
    if (
StrEqual(classname"weapon_melee") || StrEqual(classname"weapon_knife")) 
        
EquipPlayerWeapon(clientweapon); 


public 
void Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    if(
IsPlayerAlive(client))
    {
        
int item GetRandomInt(13);
        if(
item == 1)
        {
            
GivePlayerItem(client"weapon_axe");
        }
        if(
item == 2)
        {
            
GivePlayerItem(client"weapon_hammer");
        }
        if(
item == 3)
        {
            
GivePlayerItem(client"weapon_spanner");
        }
    }
}

public 
Action Event_RoundEnd(Event event, const char[] namebool dontBroadcast)
{
    for(
int client 1client <= MaxClientsclient++)
    {
        if (
IsClientInGame(client) && !IsFakeClient(client) && IsPlayerAlive(client))
        {
            for(
int offset 0offset 128offset += 4)
            {
                
int weapon GetEntDataEnt2(clientFindSendPropInfo("CBasePlayer""m_hMyWeapons") + offset);

                if (
IsValidEntity(weapon))
                {
                    
char sClass[32];
                    
GetEntityClassname(weaponsClasssizeof(sClass));

                    if ((
StrContains(sClass"melee"false) != -1))
                    {
                        
RemovePlayerItem(clientweapon);
                        
AcceptEntityInput(weapon"Kill");
                    }
                }
            }
        }
    }

__________________
root88 is offline
Trsak
Junior Member
Join Date: Jul 2018
Old 12-13-2018 , 15:50   Re: [CSGO] Axe and hammer pick up
Reply With Quote #19

Well, if i give player weapon_fists, IsValidEntity with that fists index returns false. And idea how to workaroud this?

EDIT: When i hit someone, EventSDK_OnTakeDamage has weapon = -1

Last edited by Trsak; 12-13-2018 at 16:05.
Trsak is online now
Trsak
Junior Member
Join Date: Jul 2018
Old 12-14-2018 , 07:10   Re: [CSGO] Axe and hammer pick up
Reply With Quote #20

What would be the best way to block weapon_melee throwing and make ATTACK2 act just like ATTACK?
Trsak is online now
Reply


Thread Tools
Display Modes

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 13:15.


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