AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Error: could not load file (https://forums.alliedmods.net/showthread.php?t=321147)

Napoleon_be 01-27-2020 09:25

Error: could not load file
 
I'm trying to set player models according to which weapon the player is currently wearing, but without success. I'm having this error in my game console with every single model


Error: could not load file models/player/wbm4a1/wbm4a1.mdl

OciXCrom 01-27-2020 09:58

Re: Error: could not load file
 
How are you setting the model? Show the code.

Napoleon_be 01-27-2020 10:00

Re: Error: could not load file
 
Tried using some code u provided me earlier, here it is.

PHP Code:

#include <amxmodx>
#include <cstrike>

#define PLUGIN "FFA: WeaponBased PlayerModels"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

enum _:ModelsInfo
{
    
szName[32],
    
iWeapon,
    
CsTeams:iTeams
}

new 
szWeapons[][ModelsInfo] =
{
    { 
"wbknife"CSW_KNIFE },         // Knife
    
"wbawp"CSW_AWP },             // AWP
    
"wbfamas"CSW_FAMASCS_TEAM_CT },     // Famas
    
"wbm4a1"CSW_M4A1CS_TEAM_CT },     // M4A1
    
"wbak47"CSW_AK47CS_TEAM_T },     // AK47 
    
"wbgalil"CSW_GALILCS_TEAM_T },     // Galil
    
"wbtmp"CSW_TMPCS_TEAM_CT },     // TMP
    
"wbump45"CSW_UMP45 },         // Ump45
    
"wbscout"CSW_SCOUT },         // Scout
    
"wbxm1014"CSW_XM1014 },         // XM1014
    
"wbaug"CSW_AUGCS_TEAM_CT },     // AUG
    
"wbsg550"CSW_SG550CS_TEAM_CT },     // SG550
    
"wbmp5navy"CSW_MP5NAVY },         // MP5 Navy
    
"wbm249"CSW_M249 },             // M249
    
"wbm3"CSW_M3 },             // M3
    
"wbg3sg1"CSW_G3SG1CS_TEAM_T },     // G3SG1
    
"wbsg552"CSW_SG552CS_TEAM_T }     // SG552
};

precache_player_model(szModel[])
{
    static 
szFile[128];
    
formatex(szFilecharsmax(szFile), "models/player/wbmodels/%s/%s.mdl"szModelszModel);
    
precache_model(szFile);
    
replace(szFilecharsmax(szFile), ".mdl""T.mdl");

    if(
file_exists(szFile))
    {
        
precache_model(szFile);
    }
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_event("CurWeapon""CheckWeapons""be""1=1");
}

public 
plugin_precache()
{
    for(new 
isizeof(szWeapons); i++)
    {
        
precache_player_model(szWeapons[i][szName]);
    }
}

public 
CheckWeapons(id)
{
    for(new 
isizeof(szWeapons); i++)
    {
        if(
get_user_weapon(id) == szWeapons[i][iWeapon])
        {
            if(
cs_get_user_team(id) & szWeapons[i][iTeams]) 
            {
                
cs_set_user_model(idszWeapons[i][szName]);
                break;
            }
        }
    }



HamletEagle 01-27-2020 11:08

Re: Error: could not load file
 
I am not sure, but I do not think you can have subfolders for player models. For example a model called test.mdl should be inside models/player/test/test.mdl not models/player/subfolder/test/test.mdl

Napoleon_be 01-27-2020 11:11

Re: Error: could not load file
 
Quote:

Originally Posted by HamletEagle (Post 2681833)
I am not sure, but I do not think you can have subfolders for player models. For example a model called test.mdl should be inside models/player/test/test.mdl not models/player/subfolder/test/test.mdl

I'll try that out.

OciXCrom 01-27-2020 13:18

Re: Error: could not load file
 
That's right. Player model paths are hardcoded in the engine. You musy obey the path rule for all models, so don't change the one I put in the function.

Napoleon_be 01-27-2020 13:45

Re: Error: could not load file
 
Thanks for the help, that solved my problem :)

Napoleon_be 01-27-2020 15:20

Re: Error: could not load file
 
One more question about the code, as u can see i specify models to be set only for certain teams since certain guns are only available to T's or CT's. So the problem is that i have empty spaces that should fill in the team, causing my models not to be set, how can i fix this?

Current code:
PHP Code:

new szWeapons[][ModelsInfo] =
{
    { 
"wbknife"CSW_KNIFE },         // Knife    - DOESN'T WORK - REPLACED
    
"wbawp"CSW_AWP },             // AWP        - DOESN'T WORK - REPLACED
    
"wbfamas"CSW_FAMASCS_TEAM_CT },     // Famas    - WORKS
    
"wbm4a1"CSW_M4A1CS_TEAM_CT },     // M4A1     - WORKS
    
"wbak47"CSW_AK47CS_TEAM_T },     // AK47     - DOESN'T WORK - REPLACED
    
"wbgalil"CSW_GALILCS_TEAM_T },     // Galil    - DOESN'T WORK - REPLACED
    
"wbtmp"CSW_TMPCS_TEAM_CT },     // TMP        - DOESN'T WORK - REPLACED
    
"wbump45"CSW_UMP45 },         // Ump45    - DOESN'T WORK - REPLACED
    
"wbscout"CSW_SCOUT },         // Scout    - DOESN'T WORK - REPLACED
    
"wbxm1014"CSW_XM1014 },         // XM1014    - DOESN'T WORK - REPLACED
    
"wbaug"CSW_AUGCS_TEAM_CT },     // AUG         - DOESN'T WORK - REPLACED
    
"wbsg550"CSW_SG550CS_TEAM_CT },     // SG550    - WORKS
    
"wbmp5navy"CSW_MP5NAVY },         // MP5 Navy    - DOESN'T WORK - REPLACED
    
"wbm249"CSW_M249 },             // M249        - DOESN'T WORK - REPLACED
    
"wbm3"CSW_M3 },             // M3        - DOESN'T WORK - REPLACED
    
"wbg3sg1"CSW_G3SG1CS_TEAM_T },     // G3SG1    - WORKS
    
"wbsg552"CSW_SG552CS_TEAM_T }     // SG552    - DOESN'T WORK - REPLACED
}; 

how i set my models

PHP Code:

public CheckWeapons(id)
{
    for(new 
isizeof(szWeapons); i++)
    {
        if(
get_user_weapon(id) == szWeapons[i][iWeapon])
        {
            if(
cs_get_user_team(id) & szWeapons[i][iTeams]) 
            {
                
cs_set_user_model(idszWeapons[i][szName]);
                break;
            }
        }
        else
        {
            
cs_reset_user_model(id);
        }
    }



Bugsy 01-27-2020 16:16

Re: Error: could not load file
 
Try this:
PHP Code:

new szWeapons[][ ModelsInfo ] =
{
    { 
"wbknife"CSW_KNIFE CS_TEAM_UNASSIGNED },         // Knife    - DOESN'T WORK - REPLACED
    
"wbawp"CSW_AWP CS_TEAM_UNASSIGNED },             // AWP        - DOESN'T WORK - REPLACED
    
"wbfamas"CSW_FAMASCS_TEAM_CT },     // Famas    - WORKS
    
"wbm4a1"CSW_M4A1CS_TEAM_CT },     // M4A1     - WORKS
    
"wbak47"CSW_AK47CS_TEAM_T },     // AK47     - DOESN'T WORK - REPLACED
    
"wbgalil"CSW_GALILCS_TEAM_T },     // Galil    - DOESN'T WORK - REPLACED
    
"wbtmp"CSW_TMPCS_TEAM_CT },     // TMP        - DOESN'T WORK - REPLACED
    
"wbump45"CSW_UMP45 CS_TEAM_UNASSIGNED},         // Ump45    - DOESN'T WORK - REPLACED
    
"wbscout"CSW_SCOUT CS_TEAM_UNASSIGNED},         // Scout    - DOESN'T WORK - REPLACED
    
"wbxm1014"CSW_XM1014 CS_TEAM_UNASSIGNED},         // XM1014    - DOESN'T WORK - REPLACED
    
"wbaug"CSW_AUGCS_TEAM_CT },     // AUG         - DOESN'T WORK - REPLACED
    
"wbsg550"CSW_SG550CS_TEAM_CT },     // SG550    - WORKS
    
"wbmp5navy"CSW_MP5NAVY CS_TEAM_UNASSIGNED},         // MP5 Navy    - DOESN'T WORK - REPLACED
    
"wbm249"CSW_M249 CS_TEAM_UNASSIGNED},             // M249        - DOESN'T WORK - REPLACED
    
"wbm3"CSW_M3 CS_TEAM_UNASSIGNED},             // M3        - DOESN'T WORK - REPLACED
    
"wbg3sg1"CSW_G3SG1CS_TEAM_T },     // G3SG1    - WORKS
    
"wbsg552"CSW_SG552CS_TEAM_T }     // SG552    - DOESN'T WORK - REPLACED
}; 

public 
CheckWeapons(id)
{
    new 
iWeapon get_user_weaponid );
    new 
CsTeams:csTeam cs_get_user_teamid );
    
    for ( new 
sizeofszWeapons ) ; i++ )
    {
        if ( 
iWeapon == szWeapons][ WeaponID ] )
        {
            if ( ( 
szWeapons][ TeamID ] == CS_TEAM_UNASSIGNED ) || ( csTeam == szWeapons][ TeamID ] ) ) 
            {
                
cs_set_user_modelid szWeapons][ szModel ] );
            }
            else
            {
                
cs_reset_user_modelid );
            }
            
            break;
        }
    }



Napoleon_be 01-27-2020 16:28

Re: Error: could not load file
 
Awesome, thanks Bugsy. Worked like a charm :)


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

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