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

Instant Reload


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Owner123
Member
Join Date: Jun 2010
Old 11-21-2010 , 15:36   Instant Reload
Reply With Quote #1

Hi.
I have one problem with instant reload. I want to make instant reload when weapon is reloading (Ham_Weapon_Reload with post=0). All is ok, but when player press R server crash :F
Anyone know how to solve this problem?
__________________
Sorry for my bad english !
Owner123 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-21-2010 , 15:51   Re: Instant Reload
Reply With Quote #2

plugin ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Owner123
Member
Join Date: Jun 2010
Old 11-21-2010 , 15:53   Re: Instant Reload
Reply With Quote #3

PHP Code:
new szWeapon[64];
    for(new 
CSW_P228<= CSW_P90i++)
    {
        if(
get_weaponname(iszWeaponcharsmax(szWeapon)))
            
RegisterHam(Ham_Weapon_ReloadszWeapon"fwHamWeaponReload");
    }

public 
fwHamWeaponReload(ent)
{
    if(!
pev_valid(ent))
        return 
HAM_IGNORED;
    
    new 
id get_pdata_cbase(ent414);
    
    if(!
g_bHavePower[id])
        return 
HAM_IGNORED;
    
    
set_pdata_int(ent5414);
    
ExecuteHam(Ham_Item_PostFrameent);
    
    return 
HAM_IGNORED;

__________________
Sorry for my bad english !
Owner123 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-21-2010 , 16:02   Re: Instant Reload
Reply With Quote #4

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.1"
#define PLUGIN ""

#define XO_PLAYER    5
#define m_afButtonPressed 246
#define m_pActiveItem 373

#define XO_WEAPON                4
#define m_fInReload                54

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
}

public 
client_PostThink(id)
{
    if( 
is_user_aliveid ) && get_pdata_int(idm_afButtonPressedXO_PLAYER) & IN_RELOAD )
    {
        new 
iWeapon get_pdata_cbase(idm_pActiveItemXO_PLAYER)
        if( 
iWeapon )
        {
            
set_pdata_int(iWeaponm_fInReload1XO_WEAPON)
            
set_pev(idpev_buttonpev(idpev_button) & ~IN_RELOAD)
        }
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Owner123
Member
Join Date: Jun 2010
Old 11-22-2010 , 08:22   Re: Instant Reload
Reply With Quote #5

Now i have code like this:
PHP Code:
#define m_flInReload 54
#define m_pActiveItem 373
#define m_afButtonPressed 246
#define m_pWeaponOwner 41
#define DIFF_WEAPON 4
#define DIFF_PLAYER 5

public plugin_init()
{
    new 
szWeapon[64];
    for(new 
CSW_P228<= CSW_P90i++)
    {
        if(
get_weaponname(iszWeaponcharsmax(szWeapon)))
            
RegisterHam(Ham_Weapon_ReloadszWeapon"fwHamWeaponReload");
    }
}

public 
fwHamWeaponReload(ent)
{
    if(!
pev_valid(ent))
        return 
HAM_IGNORED;
    
    new 
id get_pdata_cbase(entm_pWeaponOwnerDIFF_WEAPON);
    
    if(!
gbHavePower[id])
        return 
HAM_IGNORED;
    
    
set_pdata_int(entm_flInReload1DIFF_WEAPON);
    
ExecuteHam(Ham_Item_PostFrameent);
    
    return 
HAM_IGNORED;
}

public 
client_PostThink(id)
{
    if(
is_user_alive(id) && get_pdata_int(idm_afButtonPressedDIFF_PLAYER) & IN_RELOAD)
    {
        new 
wid get_pdata_cbase(idm_pActiveItemDIFF_PLAYER);
        if(
wid 0)
        {
            
set_pdata_int(widm_flInReload1DIFF_WEAPON);
            
set_pev(idpev_buttonpev(idpev_button) & ~IN_RELOAD);
        }
    }

And i still have crashes ;/
__________________
Sorry for my bad english !
Owner123 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-22-2010 , 08:36   Re: Instant Reload
Reply With Quote #6

If you use my code, you don't need to hook Ham_Weapon_Realod.
If you use your first code, try to supercede the Reload if you reload weapon by yourself, or hook it post and if m_fInReload is 1, send ItemPostFrame.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Owner123
Member
Join Date: Jun 2010
Old 11-22-2010 , 09:49   Re: Instant Reload
Reply With Quote #7

When i hook this post and send ItemPostFrame i have crash.
So, i return SUPERCEDE when i reload weapon by myself.
__________________
Sorry for my bad english !
Owner123 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-22-2010 , 10:07   Re: Instant Reload
Reply With Quote #8

If you send ItemPostFrame, remove IN_RELOAD from player button, else, ItemPostFrame gonna call Reload and make an infinite loop, that's why your server crashes.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 14:27.


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