AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Editing Clip Size (https://forums.alliedmods.net/showthread.php?t=339916)

Fixsek Kot 10-08-2022 14:06

Editing Clip Size
 
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.

jimaway 10-08-2022 14:18

Re: Editing Clip Size
 
https://forums.alliedmods.net/showthread.php?p=728613

Fixsek Kot 10-08-2022 15:47

Re: Editing Clip Size
 
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 10-09-2022 11:41

Re: Editing Clip Size
 
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)
        }
    }



Natsheh 10-10-2022 13:09

Re: Editing Clip Size
 
The code is not readable use offsets name instead of numbers so people when they read it, they do understand.


All times are GMT -4. The time now is 15:38.

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