AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hook end of reload. (https://forums.alliedmods.net/showthread.php?t=171030)

Screeaam.. 10-31-2011 16:29

Hook end of reload.
 
Hello! I have this code from this topic: http://forums.alliedmods.net/showthread.php?t=123645

And when he is in reload I'm adding to clip 30 ammo, but how to hook when he is end of reloading? Because when I add in this event it doesnt word (It adding and in moment it going to default)

joshknifer 10-31-2011 19:41

Re: Hook end of reload.
 
http://forums.alliedmods.net/showthr...ht=hook+reload

Screeaam.. 10-31-2011 19:50

Re: Hook end of reload.
 
I posted the same topic. ;F

There is "When u start reloading" and I want catch when u reload and when ammo id adding to clip.

Bugsy 10-31-2011 20:29

Re: Hook end of reload.
 
Hook CurWeapon for when clip ammo increases on same weapon?

Screeaam.. 11-01-2011 12:02

Re: Hook end of reload.
 
I made something like this:

Code:

public CurWeapon(id)
{
        new ammo = read_data(3);
       
        if(get_user_weapon(id) == CSW_M4A1)
        {
                if(ammo > old_ammo[id])
                {
                        add_ammo[id] = 50/2;
                        old_ammo[id] = ammo;
                }
                if(ile_dodac_magazynek[id] > 0)
                {
                        new ent = fm_get_user_weapon_entity(id);
                        if(ent){
                                cs_set_weapon_ammo(ent, ammo+1);
                                add_ammo[id]--;
                        }
                }
        }
}

Code:

register_event("CurWeapon","CurWeapon","be", "1=1")
But it working only once.

Bugsy 11-01-2011 23:26

Re: Hook end of reload.
 
I don't know if this will solve your problem. If you can't figure it out try to explain better what you're trying to do.
PHP Code:

#include <amxmodx>

enum WeaponInfo
{
    
LastWeapon,
    
LastAmmo
}
new 
g_PData33 ][ WeaponInfo ];

public 
plugin_init() 
{
    
register_event"CurWeapon" "EvCurWeapon" "be" "1=1" );
}

public 
EvCurWeapon(id)
{
    new 
iWeapon read_data);
    new 
iAmmo read_data);
    
    if ( ( 
iWeapon == g_PDataid ][ LastWeapon ] ) && ( iAmmo g_PDataid ][ LastAmmo ] ) )
    {
        
client_printid print_chat "reload complete" );
    }
    
    
g_PDataid ][ LastWeapon ] = iWeapon;
    
g_PDataid ][ LastAmmo ] = iAmmo;



ezio_auditore 12-28-2013 03:59

Re: Hook end of reload.
 
Quote:

Originally Posted by Bugsy (Post 1588201)
I don't know if this will solve your problem. If you can't figure it out try to explain better what you're trying to do.
PHP Code:

#include <amxmodx>
 
enum WeaponInfo
{
    
LastWeapon,
    
LastAmmo
}
new 
g_PData33 ][ WeaponInfo ];
 
public 
plugin_init() 
{
    
register_event"CurWeapon" "EvCurWeapon" "be" "1=1" );
}
 
public 
EvCurWeapon(id)
{
    new 
iWeapon read_data);
    new 
iAmmo read_data);
 
    if ( ( 
iWeapon == g_PDataid ][ LastWeapon ] ) && ( iAmmo g_PDataid ][ LastAmmo ] ) )
    {
        
client_printid print_chat "reload complete" );
    }
 
    
g_PDataid ][ LastWeapon ] = iWeapon;
    
g_PDataid ][ LastAmmo ] = iAmmo;




nice job man...
can you explain the functioning of this code


All times are GMT -4. The time now is 14:28.

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