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

How to get weapon from certain slot


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 12-13-2018 , 09:33   How to get weapon from certain slot
Reply With Quote #1

I created a code.
PHP Code:
void StealAmmo(int victimint attackerint amount)
{
    
int weapon_active_victim GetEntPropEnt(victimProp_Data"m_hActiveWeapon");
    
int weapon_active_attacker GetEntPropEnt(attackerProp_Data"m_hActiveWeapon");
    
// Here I check if active weapon is from slot1 or slot2. If it is from other slot or it is not valid then we just do return.
if((weapon_active_attacker != GetWeaponSlot(attacker1) && weapon_active_attacker != GetWeaponSlot(attacker2)) 
    || (
weapon_active_victim != GetWeaponSlot(victim1) && weapon_active_victim != GetWeaponSlot(victim2)) 
    || (!
IsValidEntity(weapon_active_attacker)) || (!IsValidEntity(weapon_active_victim)))
    {
        return;
    }
    
    
int ammovictim GetEntProp(weapon_active_victimProp_Send"m_iClip1");
    
int ammoattacker GetEntProp(weapon_active_attackerProp_Send"m_iClip1");
    
    
int StealAmmo = (ammovictim>amount)?(amount):(ammovictim);
    if(
StealAmmo>0)
    {
        
SetEntProp(weapon_active_victimProp_Send"m_iClip1"ammovictim StealAmmo);
        
SetEntProp(weapon_active_attackerProp_Send"m_iClip1"ammoattacker StealAmmo);
    }

But there s one problem, function int GetWeaponSlot(int client, int slotIndex) doesnt exist. Can you help me?)

Game - CS GO

Last edited by impossible_cc; 12-14-2018 at 14:45.
impossible_cc is offline
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 12-13-2018 , 09:59   Re: How to get weapon from certain slot
Reply With Quote #2

Use GetPlayerWeaponSlot
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.


Last edited by Franc1sco; 12-13-2018 at 10:00.
Franc1sco is offline
Send a message via MSN to Franc1sco
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 12-13-2018 , 10:17   Re: How to get weapon from certain slot
Reply With Quote #3

Thank you.
impossible_cc is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 12-14-2018 , 14:44   Re: How to get weapon from certain slot
Reply With Quote #4

I thought it is solved, but it doesnt work at all
Can you help me?
impossible_cc is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 12-15-2018 , 09:42   Re: How to get weapon from certain slot
Reply With Quote #5

Can you be more concretely? What's mean "not work"? Only blonde can say that.
Crash? Not compile? Return 0? ... Did you check input values before passing to GetPlayerWeaponSlot()?
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 12-15-2018 , 18:15   Re: How to get weapon from certain slot
Reply With Quote #6

Of course it doesn't crash, but it returns void before int ammovictim is declared. On some reasons code below 'check for slot' is unreachable.
impossible_cc is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 12-17-2018 , 08:53   Re: How to get weapon from certain slot
Reply With Quote #7

Check that they're are valid clients and alive as well...that may be your issue...PrintToChat each line to see exactly where its breakin for more thorough inspection.
MasterMind420 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 09:43.


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