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

[INSSTD] - Set Mags for Weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
raghava
Junior Member
Join Date: Jun 2016
Old 09-02-2018 , 17:13   [INSSTD] - Set Mags for Weapon
Reply With Quote #1

Below code is working for clips & secondary ammo (like grenades, rocket & grenades laucher).
On screen Mags are displaying (as 5 Mags) but when reloaded, its showing as 0 Mags or 5 Mags but no ammo clips to shoot.

Whats the wrong with the code

Code:
	new activeweapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
	SetEntProp(weapon, Prop_Send, "m_iClip1", 30); ///--> Ammo working
	
	new m_iPrimaryAmmoType = GetEntProp(activeweapon, Prop_Send, "m_iPrimaryAmmoType");

	SetEntProp(client, Prop_Send, "m_iAmmo", 5, _, m_iPrimaryAmmoType); // Mags only displaying but not working

Last edited by raghava; 09-04-2018 at 11:02.
raghava is offline
MasterMind420
BANNED
Join Date: Nov 2010
Old 09-04-2018 , 19:43   Re: [INSSTD] - Set Mags for Weapon
Reply With Quote #2

Quote:
Originally Posted by raghava View Post
Below code is working for clips & secondary ammo (like grenades, rocket & grenades laucher).
On screen Mags are displaying (as 5 Mags) but when reloaded, its showing as 0 Mags or 5 Mags but no ammo clips to shoot.

Whats the wrong with the code

Code:
	new activeweapon = GetEntPropEnt(client, Prop_Data, "m_hActiveWeapon");
	SetEntProp(weapon, Prop_Send, "m_iClip1", 30); ///--> Ammo working
	
	new m_iPrimaryAmmoType = GetEntProp(activeweapon, Prop_Send, "m_iPrimaryAmmoType");

	SetEntProp(client, Prop_Send, "m_iAmmo", 5, _, m_iPrimaryAmmoType); // Mags only displaying but not working
Try this...
SetEntProp(weapon, Prop_Data, "m_iClip1", 30);
SetEntProp(weapon, Prop_Send, "m_iClip1", 30);

SetEntProp(client, Prop_Data, "m_iAmmo", 5, _, m_iPrimaryAmmoType);
SetEntProp(client, Prop_Send, "m_iAmmo", 5, _, m_iPrimaryAmmoType);

If that doesn't work then you may have to catch when the weapon reload ends and set it there...

Last edited by MasterMind420; 09-04-2018 at 19:47.
MasterMind420 is offline
SHUFEN
Senior Member
Join Date: Jun 2014
Location: Japan, Tokyo
Old 09-04-2018 , 21:09   Re: [INSSTD] - Set Mags for Weapon
Reply With Quote #3

You can change mag size with using DHooks

Code:
"GetMaxClip1"
{
	"windows"	"347"
	"linux"		"353"
}
SHUFEN is offline
Send a message via Skype™ to SHUFEN
raghava
Junior Member
Join Date: Jun 2016
Old 09-05-2018 , 12:26   Re: [INSSTD] - Set Mags for Weapon
Reply With Quote #4

Quote:
Originally Posted by MasterMind420 View Post
Try this...
SetEntProp(weapon, Prop_Data, "m_iClip1", 30);
SetEntProp(weapon, Prop_Send, "m_iClip1", 30);

SetEntProp(client, Prop_Data, "m_iAmmo", 5, _, m_iPrimaryAmmoType);
SetEntProp(client, Prop_Send, "m_iAmmo", 5, _, m_iPrimaryAmmoType);

If that doesn't work then you may have to catch when the weapon reload ends and set it there...
This is also not working
raghava is offline
Javierko
AlliedModders Donor
Join Date: Sep 2017
Location: Czech republic
Old 09-05-2018 , 13:17   Re: [INSSTD] - Set Mags for Weapon
Reply With Quote #5

what about
PHP Code:
stock void SetPlayerAmmo(int clientint weaponEntint clip = -1int ammo = -1)
{
    if (
weaponEnt == INVALID_ENT_REFERENCE)
        return;

    if (
clip != -1)
        
SetEntProp(weaponEntProp_Send"m_iClip1"clip);

    if (
ammo != -1)
    {
        
int iOffset FindDataMapInfo(client"m_iAmmo") + (GetEntProp(weaponEntProp_Data"m_iPrimaryAmmoType") * 4);
        
SetEntData(clientiOffsetammo4true);

        if (
GetEngineVersion() == Engine_CSGO
        {
            
SetEntProp(weaponEntProp_Send"m_iPrimaryReserveAmmoCount"ammo);
        }
    }

__________________
My Github & Sourcemod work.
If you like my work and if you want to support me, you can through PayPal.

Official SourceMod CZ/SK Discord: https://discord.gg/Qvar55a
Javierko is offline
raghava
Junior Member
Join Date: Jun 2016
Old 09-05-2018 , 17:58   Re: [INSSTD] - Set Mags for Weapon
Reply With Quote #6

Quote:
Originally Posted by Javierko View Post
what about
PHP Code:
stock void SetPlayerAmmo(int clientint weaponEntint clip = -1int ammo = -1)
{
    if (
weaponEnt == INVALID_ENT_REFERENCE)
        return;

    if (
clip != -1)
        
SetEntProp(weaponEntProp_Send"m_iClip1"clip);

    if (
ammo != -1)
    {
        
int iOffset FindDataMapInfo(client"m_iAmmo") + (GetEntProp(weaponEntProp_Data"m_iPrimaryAmmoType") * 4);
        
SetEntData(clientiOffsetammo4true);

        if (
GetEngineVersion() == Engine_CSGO
        {
            
SetEntProp(weaponEntProp_Send"m_iPrimaryReserveAmmoCount"ammo);
        }
    }

No, with the above code also only gun clips are working, Mags are just showing on HUD but when reloading no bullets are updating in weapon (0 bullets)
raghava 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 05:05.


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