AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_Item_Holster : Bad arg count. (https://forums.alliedmods.net/showthread.php?t=90100)

ConnorMcLeod 04-14-2009 04:24

Ham_Item_Holster : Bad arg count.
 
[HAMSANDWICH] Bad arg count. Expected 3, got 2.

That's the runtime error i got (WIN32, listenserver).

My code :
Code:

ExecuteHam(Ham_Item_Holster, pActiveItem)
HLSDK code :
Code:

m_pActiveItem->Holster( );
ham_const description :
Code:

        /**
        * Description:                Whether or not the entity (usually weapon) can be holstered.
        * Forward params:        function(this)
        * Return type:                Integer (boolean).
        * Execute params:        ExecuteHam(Ham_Item_Holster, this);
        */
        Ham_Item_Holster,

hamdata.ini is default one, last amxx release.

Any idea ? hamdata.ini would be false for win32 ? listenserver related ?


If someone wnat to try out the code :
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Strip"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.0.1"

//#define WEAPON_ALLWEAPONS        (~(1<<WEAPON_SUIT))

const MAX_ITEM_TYPES 6
const MAX_AMMO_SLOTS 14 // real is 32 but cs uses only 14

const m_rgpPlayerItems_Slot0 367
const m_pActiveItem 373
const m_pLastItem 375
const m_rgAmmo_Slot0 376

const EXTRAOFFSET_WEAPONS 4
const m_pNext 42

new gmsgCurWeapon

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
gmsgCurWeapon get_user_msgid("CurWeapon")

    
register_clcmd("drop""drop")
}

public 
dropid )
{
    
RemoveAllItems(id)
    return 
PLUGIN_HANDLED
}

RemoveAllItems(id/*, bool: removeSuit*/)
{
    new 
pActiveItem get_pdata_cbase(idm_pActiveItem)
    if(
pActiveItem 0)
    {
        
ExecuteHam(Ham_Item_HolsterpActiveItem)
        
set_pdata_cbase(idm_pActiveItem, -1)
    }

    
set_pdata_cbase(idm_pLastItem, -1)
    
//set_pdata_int(id, m_pLastItem, 0) ?

    
new rgpPlayerItemspPendingItem;
    for(
rgpPlayerItems m_rgpPlayerItems_Slot0rgpPlayerItems m_rgpPlayerItems_Slot0 MAX_ITEM_TYPESrgpPlayerItems++)
    {
        
pActiveItem get_pdata_cbase(idrgpPlayerItems)
        while(
pActiveItem)
        {
            
pPendingItem get_pdata_cbase(pActiveItemm_pNextEXTRAOFFSET_WEAPONS)
            
ExecuteHam(Ham_Item_DroppActiveItem)
            
pActiveItem pPendingItem
        
}
        
set_pdata_cbase(idrgpPlayerItems, -1)
    }
    
//m_pActiveItem = NULL;

    
set_pev(idpev_viewmodel0)
    
set_pev(idpev_weaponmodel0)
    
/*    if ( removeSuit )
    {
*/    
set_pev(idpev_weapons0)
/*    }
    else
    {
        set_pev(id, pev_weapons, pev(id, pev_weapons) & ~WEAPON_ALLWEAPONS)
    }
*/
    
for(new m_rgAmmo m_rgAmmo_Slot0m_rgAmmo m_rgAmmo_Slot0 MAX_AMMO_SLOTSm_rgAmmo++)
    {
        
set_pdata_int(idm_rgAmmo0)
    }

//    ExecuteHamB(Ham_Player_UpdateClientData, id) // crash ?
    
dllfunc(DLLFunc_UpdateClientDataid)

    
message_begin(MSG_ONE_UNRELIABLEgmsgCurWeapon_id)
    
write_byte(0)
    
write_byte(0)
    
write_byte(0)
    
message_end()



ot_207 04-14-2009 04:37

Re: Ham_Item_Holster : Bad arg count.
 
I suggest creating a forward with that, if you get that error... Try to see what the third argument is ... (in case of the forward the second one ...)

ConnorMcLeod 04-14-2009 04:45

Re: Ham_Item_Holster : Bad arg count.
 
Can't believe what i see !!

PHP Code:

    RegisterHam(Ham_Item_Holster"weapon_knife""Knife_Holster")
    
RegisterHam(Ham_Item_Holster"weapon_glock18""Glock_Holster")
    
RegisterHam(Ham_Item_Holster"weapon_ak47""Ak47_Holster")

    
register_clcmd("drop""drop")
}

public 
dropid )
{
    
RemoveAllItems(id)
    return 
PLUGIN_HANDLED
}

public 
Knife_Holster(iEntwhatisthis)
{
    
client_print(0print_chat"Knife %d %d"iEntwhatisthis)
}

public 
Glock_Holster(iEntFloat:whatisthis)
{
    
client_print(0print_chat"Glock %d %f"iEntwhatisthis)
}

public 
Ak47_Holster(iEntwhatisthis[]) // o_O
{
    
client_print(0print_chat"Ak47 %d %s"iEntwhatisthis)


Code:

Knife 108 0
Glock 109 0.000000
Ak47 110 HamFilter


purple_pixie 04-14-2009 04:47

Re: Ham_Item_Holster : Bad arg count.
 
I'm sure that makes sense :-S

ot_207 04-14-2009 04:49

Re: Ham_Item_Holster : Bad arg count.
 
LOL o.O
Edit: Try adding that string to HamExecute :)).

ConnorMcLeod 04-14-2009 04:50

Re: Ham_Item_Holster : Bad arg count.
 
May be it makes sense for sawce.

So :

ExecuteHam(Ham_Item_Holster, pActiveItem, 0) works.
ExecuteHam(Ham_Item_Holster, pActiveItem, "HamFilter") also works.

Found only this :
Code:

// This is the callback from the module, this handles any fatal errors.
// This will in turn call the "HamFilter(Ham:id, HamError:err, const reason[])" public, if it exists.
// Return PLUGIN_HANDLED from within the HamFilter to stop the plugin from failing.
// Any other return value will fail the plugin.
// You do not need to have a HamFilter, if there is none, all fatal errors will fail the plugin.
// Do not modify this!
public __fatal_ham_error(Ham:id, HamError:err, const reason[])
{
       
        new func=get_func_id("HamFilter", -1);
        new bool:fail=true;
       
        if (func != -1 && callfunc_begin_i(func, -1)==1)
        {
                callfunc_push_int(_:id);
                callfunc_push_int(_:err);
                callfunc_push_str(reason, false);
                if (callfunc_end()==PLUGIN_HANDLED)
                {
                        fail=false;
                }
        }
        if (fail)
        {
                set_fail_state(reason);
        }
       
}

Waiting for sawce explainations.

ot_207 04-14-2009 04:51

Re: Ham_Item_Holster : Bad arg count.
 
I'm also interested in seeing why did the developers put that...

Arkshine 04-14-2009 05:10

Re: Ham_Item_Holster : Bad arg count.
 
the third arg seems to be skiplocal. HLSDK says skiplocal is 1 if client is predicting weapon animations.

ExecuteHam(Ham_Item_Holster, pActiveItem, 0) or ExecuteHam(Ham_Item_Holster, pActiveItem, 1)


I guess "HamFilter" appears because the arg type is not valid.

Using ExecuteHam(Ham_Item_Holster, pActiveItem, "HamFilter") will not work and you will get "[HAMSANDWICH] Entity out of range (-1)"

ConnorMcLeod 04-14-2009 05:15

Re: Ham_Item_Holster : Bad arg count.
 
Quote:

Originally Posted by arkshine (Post 805030)
the third arg seems to be skiplocal.

Thanks, but how have you found that ?

ot_207 04-14-2009 05:23

Re: Ham_Item_Holster : Bad arg count.
 
I think by seems he meant that he is not sure ... :D


All times are GMT -4. The time now is 02:27.

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