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

[CS:GO] how to give normal melee weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Neural
Junior Member
Join Date: Apr 2019
Old 04-14-2019 , 05:58   [CS:GO] how to give normal melee weapons
Reply With Quote #1

Does anybody know how to give fists, spanner and hammer? If I equip a player, he gets his weapon stripped after attack:

Code:
new iMelee = GivePlayerItem(client, "weapon_spanner");
EquipPlayerWeapon(client, iMelee);
Neural is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 04-14-2019 , 06:07   Re: [CS:GO] how to give normal melee weapons
Reply With Quote #2

Why don't you use https://forums.alliedmods.net/showthread.php?t=312699?
__________________
Steam - https://steamcommunity.com/id/sniperheroofficialu/
Discord - SniperHero#8545
cristian20042 is offline
Neural
Junior Member
Join Date: Apr 2019
Old 04-14-2019 , 06:19   Re: [CS:GO] how to give normal melee weapons
Reply With Quote #3

Quote:
Originally Posted by cristian20042 View Post
Because i don't see, what is the difference. In that plagin melee weapons also are given
Code:
iMelee = GivePlayerItem(client, "weapon_fists");
EquipPlayerWeapon(client, iMelee);

Last edited by Neural; 04-14-2019 at 06:20.
Neural is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 04-14-2019 , 06:39   Re: [CS:GO] how to give normal melee weapons
Reply With Quote #4

I think you forgot to define iMelee.

Write
PHP Code:
int iMelee
This is what you should add in your plugin also:

PHP Code:
// check if client valid
int client GetClientOfUserId(id);
if(!
client || !IsClientInGame(client) || !IsPlayerAlive(client) || (!= GetClientTeam(client)) || (!= GetClientTeam(client)))
    return;
        
// remove all the weapons on "melee slot" in order to prevent the bug of duplicated fists
int weapon;
while((
weapon GetPlayerWeaponSlot(clientCS_SLOT_KNIFE)) != -1)
{
    
RemovePlayerItem(clientweapon);
    
AcceptEntityInput(weapon"Kill");
}

int iMelee
EDIT: I think you will need to add this as well:

PHP Code:
public Action OnPlayerRunCmd(int clientint &buttonsint &impulsefloat vel[3], float angles[3], int &weapon)
{
    if (!
g_bBlockAttack2)
    {
        return 
Plugin_Continue;
    }
    
    
//Client is not valid
    
if (!IsValidClient(client) || !IsPlayerAlive(client))
    {
        return 
Plugin_Continue;
    }
    
    if (
g_iTeam && g_iTeam != GetClientTeam(client))
    {
        return 
Plugin_Continue;
    }
    
    
//Attempting to use right click
    
if (buttons IN_ATTACK2)
    {
        
char buffer[128];
        
        
int item GetEntPropEnt(clientProp_Send"m_hActiveWeapon");
        
        
// prevent log errors
        
if(item == -1)
            return 
Plugin_Continue;
        
        
GetEntityClassname(itembuffersizeof(buffer));
        
        if (
StrEqual(buffer"weapon_fists"false) || StrEqual(buffer"weapon_melee"false))
        {
            
buttons &= ~IN_ATTACK2//Don't press attack 2
            
return Plugin_Changed;
        }        
    }
    
    return 
Plugin_Continue;

__________________
Steam - https://steamcommunity.com/id/sniperheroofficialu/
Discord - SniperHero#8545

Last edited by cristian20042; 04-14-2019 at 06:45.
cristian20042 is offline
Neural
Junior Member
Join Date: Apr 2019
Old 04-14-2019 , 07:54   Re: [CS:GO] how to give normal melee weapons
Reply With Quote #5

Oh, now i see, what was the problem. I used a non-standard player model, and some of them stripped after attack melee weapons. So how can i fix it? Is it possible to make a fake model and disguise it in another?
Neural is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 04-15-2019 , 06:25   Re: [CS:GO] how to give normal melee weapons
Reply With Quote #6

Hmm, not so sure about that. But, you could try and use only models that works until somebody finds a solution.
__________________
Steam - https://steamcommunity.com/id/sniperheroofficialu/
Discord - SniperHero#8545
cristian20042 is offline
Neural
Junior Member
Join Date: Apr 2019
Old 04-16-2019 , 07:36   Re: [CS:GO] how to give normal melee weapons
Reply With Quote #7

Quote:
Originally Posted by cristian20042 View Post
Hmm, not so sure about that. But, you could try and use only models that works until somebody finds a solution.
Can I give him a standard model, but so that others see this model different?
Neural 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 04:00.


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