Raised This Month: $2 Target: $400
 0% 

remove knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jugule
Member
Join Date: Apr 2020
Old 06-16-2020 , 11:39   remove knife
Reply With Quote #1

Hi, do you have a function that removes a player's knife if he has a knife in his hand?
jugule is offline
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 06-16-2020 , 13:10   Re: remove knife
Reply With Quote #2

https://github.com/bcserv/smlib/tree...itional_syntax

PHP Code:
#include <smlib/clients> 
cstrike.inc:
PHP Code:
#define CS_TEAM_NONE        0   /**< No team yet. */
#define CS_TEAM_SPECTATOR   1   /**< Spectators. */
#define CS_TEAM_T           2   /**< Terrorists. */
#define CS_TEAM_CT          3   /**< Counter-Terrorists. */

#define CS_SLOT_PRIMARY     0   /**< Primary weapon slot. */
#define CS_SLOT_SECONDARY   1   /**< Secondary weapon slot. */
#define CS_SLOT_KNIFE       2   /**< Knife slot. */
#define CS_SLOT_GRENADE     3   /**< Grenade slot (will only return one grenade). */
#define CS_SLOT_C4          4   /**< C4 slot. */ 
PHP Code:
int GetPlayerWeaponSlot(int clientint slot)
bool GetEntityClassname(int entitychar[] clsnameint maxlength
PHP Code:
stock bool Client_RemoveWeapon(int client, const char[] classNamebool firstOnly=truebool clearAmmo=false

Last edited by Weetabix; 06-16-2020 at 13:13.
Weetabix is offline
Kellan123
AlliedModders Donor
Join Date: Aug 2012
Old 06-16-2020 , 13:11   Re: remove knife
Reply With Quote #3

#peace-maker (timer-weapons.sp plugin) =>

PHP Code:
stock RemovePlayerKnife(client)
{
    new 
iWeapon = -1;
    while((
iWeapon GetPlayerWeaponSlot(clientCS_SLOT_KNIFE)) != -1)
    {
        if(
iWeapon 0)
        {
            
RemovePlayerItem(clientiWeapon);
            
AcceptEntityInput(iWeapon"kill");
        }
    }

Kellan123 is offline
Kellan123
AlliedModders Donor
Join Date: Aug 2012
Old 06-16-2020 , 13:12   Re: remove knife
Reply With Quote #4

Quote:
Originally Posted by Weetabix View Post
https://github.com/bcserv/smlib/tree...itional_syntax

PHP Code:
#include <smlib/clients> 
PHP Code:
stock bool Client_RemoveWeapon(int client, const char[] classNamebool firstOnly=truebool clearAmmo=false
the build is failing
Kellan123 is offline
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 06-16-2020 , 13:25   Re: remove knife
Reply With Quote #5

PHP Code:
#include <smlib>
#include <sdktools>

void RemoveKnife(int iClient)
{
    
int iKnife GetPlayerWeaponSlot(iClientCS_SLOT_KNIFE);
    
    if(
iKnife != -1)
    {
        
char sName[32];
        
GetEntityClassname(iKnifesNamesizeof sName);
        
        
Client_RemoveWeapon(iClientsName); 
    }

Weetabix is offline
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 11:14.


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