Raised This Month: $ Target: $400
 0% 

Invalid trie handle provided (0)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mforce
Member
Join Date: Jan 2015
Old 04-16-2016 , 08:27   Invalid trie handle provided (0)
Reply With Quote #1

It happens to all Trie natives. How to solve this problem?

L 04/16/2016 - 14:252: Invalid trie handle provided (0)
L 04/16/2016 - 14:252: [AMXX] Run time error 10 (plugin "admin_weapon_skins.amxx") (native "TrieKeyExists") - debug not enabled!
L 04/16/2016 - 14:252: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).


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

new const PLUGIN[] = "Admin Weapon Skins";
new const 
VERSION[] = "1.0";
new const 
AUTHOR[] = "mforce";


#define ACCESS_FLAG    ADMIN_KICK

new Trie:weaponlist;

const 
m_pPlayer 41
const XO_WEAPON 4

#define get_weapon_owner(%1)        get_pdata_cbase(%1, m_pPlayer, XO_WEAPON)
#define AllocString(%1)             engfunc(EngFunc_AllocString,%1)

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
weaponlist TrieCreate();
}

public 
plugin_precache() {
    new 
sBuffer[256], sFile[64], sData[2][32], pFile;
    
get_localinfo("amxx_configsdir"sFilecharsmax(sFile));
    
format(sFilecharsmax(sFile), "%s/admin_weapon_skins.ini"sFile);
    
pFile fopen(sFile"rt");
    if(
pFile) {     
        while(!
feof(pFile)) {
            
fgets(pFilesBuffercharsmax(sBuffer));
            
trim(sBuffer);
            if(
sBuffer[0] == ';') continue;
            
parse(sBuffersData[0], charsmax(sData[]), sData[1], charsmax(sData[]));

            if((
containi(sData[0], "weapon_") != -1) && (containi(sData[1], ".mdl") != -1) && (!TrieKeyExists(weaponlistsData[0]))) {
                
precache_model(sData[1])
                
RegisterHam(Ham_Item_DeploysData[0], "ItemDeploy_Post"true);
                
TrieSetString(weaponlistsData[0], sData[1])
            }
        }
        
fclose(pFile);
    }
    else 
fprintf(pFile";^"weapon_ak47^" ^"models/adminskins/v_ak47.mdl^"^n");
}

public 
ItemDeploy_Post(Ent) {
    if(
Ent <=0)
        return 
HAM_IGNORED;

    new 
id get_weapon_owner(Ent)
    if((
id 0) && (get_user_flags(id) & ACCESS_FLAG)) {
        new 
szWeapon[32], WeaponPath[32];
        
get_weaponname(EntszWeaponcharsmax(szWeapon));
     
        
TrieGetString(weaponlistszWeaponWeaponPathcharsmax(WeaponPath));
        
set_pev_string(idpev_viewmodel2AllocString(WeaponPath));
    }
    return 
HAM_IGNORED;
}

public 
plugin_end() {
    
TrieDestroy(weaponlist);

__________________
mforce @ hlmod.hu
mforce is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-16-2016 , 08:32   Re: Invalid trie handle provided (0)
Reply With Quote #2

plugin_precache() is called before plugin_init().
Move "weaponlist = TrieCreate();" into precache.
Enable debug in the future for better diagnostics.
__________________

Last edited by Black Rose; 04-16-2016 at 08:33.
Black Rose is offline
mforce
Member
Join Date: Jan 2015
Old 04-16-2016 , 09:24   Re: Invalid trie handle provided (0)
Reply With Quote #3

Problem solved, thanks

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

new const PLUGIN[] = "Admin Weapon Skins";
new const 
VERSION[] = "1.0";
new const 
AUTHOR[] = "mforce";


new 
Trie:weaponlist

#define ACCESS_FLAG    ADMIN_KICK

const m_pPlayer 41
const XO_WEAPON 4

#define get_weapon_owner(%1)        get_pdata_cbase(%1, m_pPlayer, XO_WEAPON)
#define AllocString(%1)             engfunc(EngFunc_AllocString,%1)

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
}

public 
plugin_precache() {
    
weaponlist TrieCreate()
    
    new 
sBuffer[256], sFile[64], sData[2][32], pFile;
 
    
get_localinfo("amxx_configsdir"sFilecharsmax(sFile));
    
format(sFilecharsmax(sFile), "%s/admin_weapon_skins.ini"sFile);
 
    
pFile fopen(sFile"rt");
 
    if(
pFile) {        
        while(!
feof(pFile)) {
            
fgets(pFilesBuffercharsmax(sBuffer));
            
trim(sBuffer);
            if(
sBuffer[0] == ';') continue;
 
            
parse(sBuffersData[0], charsmax(sData[]), sData[1], charsmax(sData[]));

            if((
containi(sData[0], "weapon_") != -1) && (containi(sData[1], ".mdl") != -1) && (!TrieKeyExists(weaponlistsData[0]))) {
                
precache_model(sData[1])
                
RegisterHam(Ham_Item_DeploysData[0], "ItemDeploy_Post"true);
                
TrieSetString(weaponlistsData[0], sData[1])
            }
        }
        
fclose(pFile);
    }
    else 
fprintf(pFile";^"weapon_ak47^" ^"models/adminskins/v_ak47.mdl^"^n");
}

public 
ItemDeploy_Post(Ent) {
    if(
Ent <=0)
        return 
HAM_IGNORED;

    new 
id get_weapon_owner(Ent)
    if((
id 0) && (get_user_flags(id) & ACCESS_FLAG)) {
        new 
szWeapon[32], WeaponPath[32];
        
get_weaponname(cs_get_weapon_id(Ent), szWeaponcharsmax(szWeapon));
        
        
TrieGetString(weaponlistszWeaponWeaponPathcharsmax(WeaponPath));
        
set_pev_string(idpev_viewmodel2AllocString(WeaponPath));
    }
    return 
HAM_IGNORED;
}

public 
plugin_end() {
    
TrieDestroy(weaponlist);

__________________
mforce @ hlmod.hu
mforce 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 18:32.


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