Raised This Month: $ Target: $400
 0% 

How to check if player has weapon with 0 bullets


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 10-28-2017 , 20:42   How to check if player has weapon with 0 bullets
Reply With Quote #1

Hello

i want to make an "if", but i just don't get it
i need to set than like a "If a player has a deagle in his secondary slot, he gives the deagle again and a he grenade" that is working all good but now i want to do another "IF" "if a player has a deagle in his secondary slot and the deagle is with 0/0 bullets just give him a grenade

idk how to do that :/ xd

PHP Code:
{
                    
//Take off money
                    
int Cash money cost;
                    
SetClientMoney(clientCash);
                    
                    
//Print message in chat
                    
CPrintToChat(client"{green}[%s] {default} You bought that item."Prefix);
                    
                    
int weapon GetPlayerWeaponSlot(client1);
                    if (
IsValidEntity(weapon))
                    {
                        
char weapon_name[32];
                        
GetEntityClassname(weaponweapon_name32);
                        if (
StrEqual(weapon_name"weapon_deagle")) //all working here, if player has weapon in secondary slot...
                        
{
                            
GivePlayerItem(client"weapon_hegrenade");
                            
Client_GiveWeaponAndAmmo(client"weapon_deagle"_0_1);
                            
g_bUserhegrenade[client] = true;
                        }
                        else if (
StrEqual(weapon_name"weapon_deagle")) // idk how to do this "if" I want to set "if deagle is with 0/0 bullets"
                        
{
                            
                        }
                    }
                    else
                    {
                        
GivePlayerItem(client"weapon_hegrenade");
                        
g_bUserhegrenade[client] = true;
                    }
                } 
__________________
Elitcky is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 10-28-2017 , 22:40   Re: How to check if player has weapon with 0 bullets
Reply With Quote #2

PHP Code:
if (StrEqual(weapon_name"weapon_deagle") && GetEntProp(weaponProp_Send"m_iClip1") == && GetEntProp(weaponProp_Send"m_iClip2") == 0)
{
    
// Do something                


Last edited by ThatKidWhoGames; 10-28-2017 at 22:40.
ThatKidWhoGames is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 10-29-2017 , 00:59   Re: How to check if player has weapon with 0 bullets
Reply With Quote #3

did i do it right ? i want if a player has a deagle with 0/0 just give the grenade and if player has deagle with 1 bullet "1/0" do other thing

PHP Code:
else if (money >= cost)
                {
                    
//Take off money
                    
int Cash money cost;
                    
SetClientMoney(clientCash);
                    
                    
//Print message in chat
                    
CPrintToChat(client"{green}[%s] {default} Su item ha sido comprado."Prefix);
                    
                    
int weapon GetPlayerWeaponSlot(client1);
                    if (
IsValidEntity(weapon))
                    {
                        
char weapon_name[32];
                        
GetEntityClassname(weaponweapon_name32);
                        if (
StrEqual(weapon_name"weapon_deagle") && (GetEntProp(weaponProp_Send"m_iClip1") == && GetEntProp(weaponProp_Send"m_iClip2") == 0)) 
                        { 
                                
GivePlayerItem(client"weapon_hegrenade");
                                
g_bUserhegrenade[client] = true;
                        }
                        else if (
StrEqual(weapon_name"weapon_deagle") && (GetEntProp(weaponProp_Send"m_iClip1") == && GetEntProp(weaponProp_Send"m_iClip2") == 1))
                        {
                            
GivePlayerItem(client"weapon_hegrenade");
                            
Client_GiveWeaponAndAmmo(client"weapon_deagle"_0_1);
                            
g_bUserhegrenade[client] = true;
                        }
                    }
                    else
                    {
                        
GivePlayerItem(client"weapon_hegrenade");
                        
g_bUserhegrenade[client] = true;
                    }
                } 
i tried this but it is not giving me anything if i have a deagle in my slot :/

EDIT:

nvm fixed it searching other things :/ thanks
PHP Code:
if (StrEqual(weapon_name"weapon_deagle") && (GetEntProp(weaponProp_Send"m_iClip1") == && GetEntProp(weaponProp_Send"m_iPrimaryReserveAmmoCount") == 0)) 
                        { 
                                
GivePlayerItem(client"weapon_hegrenade");
                                
g_bUserhegrenade[client] = true;
                        } 
now it works

with this

Code:
GetEntProp(weapon, Prop_Send, "m_iPrimaryReserveAmmoCount") == 0
__________________

Last edited by Elitcky; 10-29-2017 at 01:47. Reason: ADDING THINGS
Elitcky 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:29.


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