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

[CS:GO]How to drop weapon and give weapon?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 07-22-2015 , 18:39   [CS:GO]How to drop weapon and give weapon?
Reply With Quote #1

Hello,

I need to remove the players weapons and give them a new weapon. I try:
PHP Code:
for (new 1<= MaxClientsi++) 
      { 
          
GivePlayerItem(i"weapon_aug");  
          
SDKHook(iSDKHook_WeaponCanUseEvent_WeaponCanUse); 
          
SDKHook(iSDKHook_WeaponCanSwitchToEvent_WeaponCanSwitchTo); 
          
int weapon
          for (
int x 04x++)  
          {  
            if (
== 2)  
            {  
                continue;  
            } 
            while ((
weapon GetPlayerWeaponSlot(ii)) != -1
            {      
                
RemovePlayerItem(iweapon);  
                
AcceptEntityInput(weapon"Kill");  
            }  
          } 
      } 
Works, but not get a new weapon. Where is problem?
Thanks for reply.

Last edited by Fastmancz; 07-23-2015 at 01:27.
Fastmancz is offline
Dr. Api
BANNED
Join Date: Mar 2015
Location: France
Old 07-22-2015 , 19:42   Re: [CS:GO]How to drop weapon and give?
Reply With Quote #2

You took a hard way to do this. First check if the player have a weapon on the slot with GetPlayerWeaponSlot. If weapon found you remove and kill. And after you give the weapon GivePlayerItem.

Use the enum from cstrike.inc to get the weapon from the slot it's look like CS_SLOT_PRIMARY
Dr. Api is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 07-22-2015 , 22:55   Re: [CS:GO]How to drop weapon and give?
Reply With Quote #3

i think this is where your code is wrong

Code:
while ((weapon = GetPlayerWeaponSlot(i, i)) != -1)
do you want to remove all player's weapon except knife and give them an AUG??

Last edited by 8guawong; 07-22-2015 at 22:58.
8guawong is offline
hadesownage
AlliedModders Donor
Join Date: Jun 2013
Location: Romania, Iași
Old 07-23-2015 , 00:50   Re: [CS:GO]How to drop weapon and give?
Reply With Quote #4

PHP Code:
stock StripWeapons client ) {
    
    for ( new 
1<= 4j++) {
        
        new 
current GetPlayerWeaponSlot client);
        if ( 
current != INVALID_ENT_REFERENCE && IsValidEdict current ) ) {
            
RemovePlayerItem clientcurrent );
            
RemoveEdict current );
        }
        
    }
    
    new 
entity GivePlayerItem client"weapon_knife" );
    if ( 
entity == INVALID_ENT_REFERENCE || !IsValidEdict(entity))
        return;
    


Last edited by hadesownage; 07-23-2015 at 00:52.
hadesownage is offline
Send a message via Yahoo to hadesownage Send a message via Skype™ to hadesownage
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 07-23-2015 , 01:22   Re: [CS:GO]How to drop weapon and give?
Reply With Quote #5

Quote:
Originally Posted by hadesownage View Post
PHP Code:
stock StripWeapons client ) {
    
    for ( new 
1<= 4j++) {
        
        new 
current GetPlayerWeaponSlot client);
        if ( 
current != INVALID_ENT_REFERENCE && IsValidEdict current ) ) {
            
RemovePlayerItem clientcurrent );
            
RemoveEdict current );
        }
        
    }
    
    new 
entity GivePlayerItem client"weapon_knife" );
    if ( 
entity == INVALID_ENT_REFERENCE || !IsValidEdict(entity))
        return;
    

Thanks for reply, but i have 2 problems:
- stock StripWeapons ( i ) - invalid expression, assumed zero
- undefined symbol "StripWeapons"
- symbol is never used: "weapon"
Fastmancz is offline
Fastmancz
Senior Member
Join Date: Jul 2013
Location: Czech Republic
Old 07-23-2015 , 01:26   Re: [CS:GO]How to drop weapon and give?
Reply With Quote #6

Quote:
Originally Posted by 8guawong View Post
i think this is where your code is wrong

Code:
while ((weapon = GetPlayerWeaponSlot(i, i)) != -1)
do you want to remove all player's weapon except knife and give them an AUG??
Yes.
Fastmancz is offline
hadesownage
AlliedModders Donor
Join Date: Jun 2013
Location: Romania, Iași
Old 07-23-2015 , 07:41   Re: [CS:GO]How to drop weapon and give weapon?
Reply With Quote #7

The stock is allright, the problem is in your code.
hadesownage is offline
Send a message via Yahoo to hadesownage Send a message via Skype™ to hadesownage
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 17:02.


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