AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   OnWeapon_Precache error (https://forums.alliedmods.net/showthread.php?t=300193)

Tripaloski 08-08-2017 21:05

OnWeapon_Precache error
 
Hi everyone.
I'm having the following error in the logs.
Error:
PHP Code:

L 08/08/2017 02:21:36: [HAMSANDWICHFailed to retrieve classtype for ""hook for "OnWeapon_Precache" not active.
L 08/08/2017 02:21:36: [AMXXDisplaying debug trace (plugin "NoCustumeSkins.amxx")
L 08/08/2017 02:21:36: [AMXXRun time error 10native error (native "RegisterHam")
L 08/08/2017 02:21:36: [AMXXNoCustumeSkins.sma::plugin_precache (line 80

Line 80
PHP Code:

        g_hPrecacheHook[iWeaponId] = RegisterHam(Ham_PrecacheszWeaponName"OnWeapon_Precache"

PHP Code:

public plugin_precache()
{
    new 
szWeaponName[32]
    for(new 
iWeaponId 1iWeaponId < (MAX_WEAPONS); iWeaponId++) if(iWeaponId != 2)
    {
        
get_weaponname(iWeaponIdszWeaponNamecharsmax(szWeaponName))
        
        
g_hPrecacheHook[iWeaponId] = RegisterHam(Ham_PrecacheszWeaponName"OnWeapon_Precache")
        
g_hPrecacheHook_Post[iWeaponId] = RegisterHam(Ham_PrecacheszWeaponName"OnWeapon_Precache_Post"true)
    }


Does anyone know how to solve it?

Natsheh 08-09-2017 02:30

Re: OnWeapon_Precache error
 
public plugin_precache()
{
new szWeaponName[32]
for(new iWeaponId = 1; iWeaponId <= (CZW_P90); iWeaponId++) if(iWeaponId != 2)
{
get_weaponname(iWeaponId, szWeaponName, charsmax(szWeaponName))
if(szWeapon[0] == EOS) continue;
g_hPrecacheHook[iWeaponId] = RegisterHam(Ham_Precache, szWeaponName, "OnWeapon_Precache")
g_hPrecacheHook_Post[iWeaponId] = RegisterHam(Ham_Precache, szWeaponName, "OnWeapon_Precache_Post", true)
}
}

HamletEagle 08-09-2017 05:00

Re: OnWeapon_Precache error
 
get_weaponname is not going to work in precache on first map. The solution is probably to hardcode a list of weapon classnames and use them.

leonardo121 08-09-2017 07:44

Re: OnWeapon_Precache error
 
use a const with all weapon classname

Tripaloski 08-09-2017 09:04

Re: OnWeapon_Precache error
 
HamletEagle.
Sorry but I do not know how to get it to work properly.
Can you help?

HamletEagle 08-09-2017 09:14

Re: OnWeapon_Precache error
 
Quote:

Originally Posted by leonardo121 (Post 2540467)
use a const with all weapon classname

Just write manually all weapon names in a constant and loop over that.
PHP Code:

new const Something[][] = 
{
   ....
}

for()
{
  ....
code



leonardo121 08-09-2017 09:23

Re: OnWeapon_Precache error
 
Quote:

Originally Posted by HamletEagle (Post 2540492)
Just write manually all weapon names in a constant and loop over that.
PHP Code:

new const Something[][] = 
{
   ....
}

for()
{
  ....
code



yhea like this

Tripaloski 08-09-2017 09:43

Re: OnWeapon_Precache error
 
This?

PHP Code:

new const Something[][] =  

    
CSW_P228,       
    
CSW_SCOUT,       
    
CSW_HEGRENADE,      
    
CSW_XM1014,        
    
CSW_C4,           
    
CSW_MAC10,       
    
CSW_AUG,          
    
CSW_SMOKEGRENADE,  
    
CSW_ELITE,       
    
CSW_FIVESEVEN,      
    
CSW_UMP45,      
    
CSW_SG550,       
    
CSW_GALIL,       
    
CSW_FAMAS,      
    
CSW_USP,       
    
CSW_GLOCK18,      
    
CSW_AWP,          
    
CSW_MP5NAVY,       
    
CSW_M249,       
    
CSW_M3,           
    
CSW_M4A1,        
    
CSW_TMP,          
    
CSW_G3SG1,       
    
CSW_FLASHBANG,    
    
CSW_DEAGLE,        
    
CSW_SG552,        
    
CSW_AK47,       
    
CSW_KNIFE,      
    
CSW_P90           



leonardo121 08-09-2017 09:49

Re: OnWeapon_Precache error
 
Quote:

get_weaponname(iWeaponId, szWeaponName, charsmax(szWeaponName))
pick up the name not the ID
here it is
https://wiki.alliedmods.net/Cs_weapons_information

Tripaloski 08-09-2017 09:55

Re: OnWeapon_Precache error
 
Is it already correct?

PHP Code:

new const Something[][] =  

    
"weapon_p228",            
    
"weapon_scou",             
    
"weapon_hegrenade",               
    
"weapon_xm1014",
    
"weapon_c4",    
    
"weapon_mac10",         
    
"weapon_aug",
    
"weapon_smokegrenade",       
    
"weapon_elite",         
    
"weapon_fiveseven",
    
"weapon_ump45",         
    
"weapon_sg550"
    
"weapon_galil",
    
"weapon_famas"
    
"weapon_usp",   
    
"weapon_glock18",    
    
"weapon_awp",  
    
"weapon_mp5navy",      
    
"weapon_m249",              
    
"weapon_m3"
    
"weapon_m4a1",      
    
"weapon_tmp",      
    
"weapon_g3sg1",
    
"weapon_flashbang",   
    
"weapon_deagle",
    
"weapon_sg552",
    
"weapon_ak47",   
    
"weapon_knife",                 
    
"weapon_p90"




All times are GMT -4. The time now is 03:40.

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