Raised This Month: $32 Target: $400
 8% 

Getting weapon classname from slot and..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
farawayf
Senior Member
Join Date: Jan 2019
Old 04-27-2019 , 11:49   Getting weapon classname from slot and..
Reply With Quote #1

how to get the classname of the weapon from slot which client doesn't hold ?
need to give ammo to the players at the round_start if client has weapon, or give weapon if it does not have.

PHP Code:
public Action Event_RoundStart(Event event, const char[] namebool dontBroadcast) {
    for (
int client 1client <= MaxClientsclient++) {
    .......
            
//get the weapon classname from slot1

            //if client has weapon_awp. do
            
if(StrEqual(weapon"weapon_awp") {  
                
int ammotype GetEntProp(slot1Prop_Data"m_iPrimaryAmmoType"); 
                    
SetEntData(clientammotype1004true); 
           }
           
//else if client does not have weapon_awp
           
GivePlayerItem(client"weapon_awp");
        }
    }


Last edited by farawayf; 04-27-2019 at 11:52.
farawayf is offline
Whai
Senior Member
Join Date: Jul 2018
Old 04-27-2019 , 12:39   Re: Getting weapon classname from slot and..
Reply With Quote #2

Use for getting the index of the weapon then use :
__________________
Whai is offline
farawayf
Senior Member
Join Date: Jan 2019
Old 04-27-2019 , 13:17   Re: Getting weapon classname from slot and..
Reply With Quote #3

Quote:
Originally Posted by Whai View Post
Use for getting the index of the weapon then use :
working good, but if player has another weapon it crashs server
farawayf is offline
farawayf
Senior Member
Join Date: Jan 2019
Old 04-27-2019 , 13:19   Re: Getting weapon classname from slot and..
Reply With Quote #4

anyone can give the full code for example please ?

Last edited by farawayf; 04-27-2019 at 13:19.
farawayf is offline
Kolapsicle
Senior Member
Join Date: Oct 2014
Old 04-28-2019 , 08:25   Re: Getting weapon classname from slot and..
Reply With Quote #5

If I'm not mistaken, you want the weapon property "m_iClip1". To set reserve ammo, I think you need the client property "m_iAmmo" which is an array.

PHP Code:
int weapon GetPlayerWeaponSlot(client0);
if (!
IsValidEntity(weapon))
{
    return 
Plugin_Continue;
}

SetEntProp(weaponProp_Send"m_iClip1"100); 
Kolapsicle 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 12:35.


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