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

Editing Clip Size


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fixsek Kot
Member
Join Date: Feb 2022
Old 10-08-2022 , 14:06   Editing Clip Size
Reply With Quote #1

Hey guys, I'm here again.

I've got an issue with editing clip size in galil to be only able to hold 2 bullets. I can change the gun's clip easily like this:

cs_set_weapon_ammo(find_ent_by_owner(-1, "weapon_galil", id), 2)

This command works just fine, but I also want this to work when I reload the gun, instead the galil after reloading gets 35 ammo and I couldn't find any solution to this for some reason, the only thing I've potentially got:
PHP Code:
public ham_reload_post(ent)
{
    static 
idid get_pdata_cbase(ent414)
    if(
get_pdata_int(ent544) && get_pdata_float(id835) <= 0.0)
    {
        if(
mushmaker[id]) set_pdata_int(ent5124)
    }

but it doesn't work, so I'll be glad for your advice.

Have a great day.
Fixsek Kot is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 10-08-2022 , 14:18   Re: Editing Clip Size
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?p=728613

Last edited by jimaway; 10-08-2022 at 14:27.
jimaway is offline
Fixsek Kot
Member
Join Date: Feb 2022
Old 10-08-2022 , 15:47   Re: Editing Clip Size
Reply With Quote #3

Thanks for sending me the link, I tried to write the code into mine from it but I've never worked with something like item_postframe... + The plugin is useless to me, 'cause I need to put this feature in my code so it can work properly, I've got an exclusively edited gun in shop menu and I need to edit the clip size for it (I could've said that earlier right)
Fixsek Kot is offline
Fixsek Kot
Member
Join Date: Feb 2022
Old 10-09-2022 , 11:41   Re: Editing Clip Size
Reply With Quote #4

Ok I got it working finally after lots of hours, if someone would use the code bellow, go ahead and use it:
PHP Code:
public plugin_init() {
    
RegisterHam(Ham_Item_PostFrame"weapon_galil""ham_postframe"0)
}
public 
ham_postframe(ent)
{
    static 
idid get_pdata_cbase(entG_PLAYERWEAPON_OFFSET)
    if(
get_pdata_int(entRELOAD_OFFSETWEAPON_OFFSET) && get_pdata_float(idNEXTATTACK_OFFSETPLAYER_OFFSET) <= 0.0)
    {
        if(
mushmaker[id])
        {
            
set_pdata_int(entCLIP_OFFSET2WEAPON_OFFSET)
            
set_pdata_int(entRELOAD_OFFSET0WEAPON_OFFSET)
        }
    }


Last edited by Fixsek Kot; 10-11-2022 at 11:22.
Fixsek Kot is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-10-2022 , 13:09   Re: Editing Clip Size
Reply With Quote #5

The code is not readable use offsets name instead of numbers so people when they read it, they do understand.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
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 15:20.


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