AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ERROR: SV_Modelindex Model not prechached (https://forums.alliedmods.net/showthread.php?t=332997)

Crackhead69 06-13-2021 05:53

ERROR: SV_Modelindex Model not prechached
 
Hello!
I have a strange error that is occurring randomly, not at start of the plugin.

I have existing plugin as this example, just with different names for easier understanding:
PHP Code:

#include <amxmodx>

new const model_1[] = "models/model_1.mdl"
new const model_2[] = "models/model_2.mdl"

public plugin_init()
    
register_event("CurWeapon""Event_CurWeapon""be")
    
public 
Event_CurWeapon(id){
    
set_pev(idpev_viewmodel2model_1)
    
set_pev(idpev_weaponmodel2model_2)
}


public 
plugin_precache(){
    
precache_model(model_1)
    
precache_model(model_2)


The error occurs from those 2 model files, the files are okay, and used wildly in other servers, this is not problem which occurs from the model file.

It happens often, but it has no fixed timing for when it gives the error.

FATAL ERROR (shutting down): SV_ModelIndex: SV_ModelIndex: model mdl not precach
ed
Segmentation fault

The "model mdl" has different symbols every time the error occurs, although the symbols are representing parts of the names of model_1 and model_2.

What should i look for that can cause this strange error? Is it a Plugin that can cause it, or something else ?

DJEarthQuake 06-13-2021 14:49

Re: ERROR: SV_Modelindex Model not prechached
 
Call is made before it is precached. Try putting precache up higher.

Celena Luna 06-14-2021 00:05

Re: ERROR: SV_Modelindex Model not prechached
 
I am not sure but try to put plugin_precache() after plugin_init()

Also, it is a bit out of topic but you shouldn't change weapon model at Event_CurWeapon since it will call many time cause increase in server usage. This way is out-dated.
Now we used Ham_Item_Deploy to set weapon model only once when you switch to that specific weapon only

PHP Code:

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

new const model_1[] = "models/model_1.mdl"
new const model_2[] = "models/model_2.mdl"

public plugin_init()
{
    
RegisterHam(Ham_Item_Deploy"weapon_usp""fw_Weapon_Deploy"1//change weapon_usp to the weapon you want to replace
}

public 
plugin_precache(){
    
precache_model(model_1)
    
precache_model(model_2)

    
public 
fw_Weapon_Deploy(ent)
{
    if(
pev_valid(ent) != 2)
        return
    static 
idid get_pdata_cbase(ent414//Get ID
    
if(get_pdata_cbase(id373) != ent//373 = m_pActiveItem. This check if current weapon is correct or not
        
return

    
set_pev(idpev_viewmodel2model_1)
    
set_pev(idpev_weaponmodel2model_2)


Edit: This is assuming you are try to make CS weapon.

Crackhead69 06-14-2021 09:46

Re: ERROR: SV_Modelindex Model not prechached
 
tried placing plugin_precache below plugin_init, error still occurs, symbols are getting more and more strange

FATAL ERROR (shutting down): SV_ModelIndex: SV_ModelIndex: model ****************** not precached. Segmentation fault

This is the latest error message that appeared. Seems the problem is more deep. The plugin i am working on is way too long, therefore i can't ask anybody to read every single line of it. If somebody could point me to where should i look for, that would be enough of a help, the rest i'll manage.

I have experienced similar error before:

FATAL ERROR SayText limit is 192 bytes, where the problem there was the way i placed colorchat's colors. The error occured when a colorchat text was typed like so:

Code:

ColorChat(id,team_color, "name ^3%s", szName)
in this situation the ^3% was counted as 1 unknown strange symbol that for some reason multiplied the text every time it's called by random amounts, giving errors similar to the

SV_ModelIndex: SV_ModelIndex,
Text written inside the colorchat in that situation was random, containing parts of the original message.

The solution there was to put aside ^3 and %s.

Although, i have checked every single type of similar symbols in the plugin and the others that i am using, there are none which are connected like the example "^3%s"

DJEarthQuake 06-14-2021 13:53

Re: ERROR: SV_Modelindex Model not prechached
 
Log and pause technique before it crashes may help part of your problem. Illustration snip:
Code:
public plugin_precache() {     if(file_exists("sound/misc/Temp.wav")){         precache_sound(SOUND_GOTATEMP);     }         else     {             log_amx("Paused to prevent crash from missing %s.",SOUND_GOTATEMP);             pause "a";     } }

Code:
    get_datadir(g_filepath, charsmax(g_filepath));     formatex(g_szFile[0], charsmax(g_szFile), "%s/%s", g_filepath, g_szRequired_Files[0]);     formatex(g_szFile[1], charsmax(g_szFile), "%s/%s", g_filepath, g_szRequired_Files[1]);     if( (!file_exists(g_szFile[0])) || !file_exists(g_szFile[1]) ){         server_print("Check your Maxmind databases...%s|%s...halting to prevent crash.",g_szFile[0],g_szFile[1]);         pause("a");     }

Crackhead69 06-14-2021 16:27

Re: ERROR: SV_Modelindex Model not prechached
 
This is very helpful, thank you, although the plugin is more or less calling a non-existing model name from within, therefore precache in this case does not seem to matter.

I will put if(file_exist) check on every line i am setting a model, this would seem to be a temporary solution. I am still satisfied that it is some kind of solution.

Will update if i have found a more permanent solution to the problem.

Napoleon_be 06-14-2021 21:49

Re: ERROR: SV_Modelindex Model not prechached
 
You're obviously looking at the wrong plugin if names aren't matching.

Natsheh 06-15-2021 00:57

Re: ERROR: SV_Modelindex Model not prechached
 
DJEarthQuake and celena forward order doesn't effect the function calling order..

DJEarthQuake 06-16-2021 15:47

Re: ERROR: SV_Modelindex Model not prechached
 
This is true precache at the top of the script or at bottom when it is right it does not matter. That being said I do not have any examples to show today but I have experienced situation where it does matter contrary to popular opinion that these things are happening so fast that I have had to put everything that is normally in init into precache to MAKE IT WORK and hold the server together. Also without metamod on the system at all these half names appearing I have seen enough with making maps that are too large for the system. So that could also be, assuming the script is right, the plugin list, the map, everything may have hit a hard ent limit. The main take away. I did not want to be rude. Somebody could have said learn debug and leave it there.

Crackhead69 06-19-2021 11:55

Re: ERROR: SV_Modelindex Model not prechached
 
The error is still going.
This time it seems that it cought a whole string :

Code:

FATAL ERROR (shutting down): SV_ModelIndex: SV_ModelIndex: model Cannot open menu
. not precached
Segmentation fault

The message string "Cannot open menu" in the code is called from a clcmd, cannot be called otherwise.
The clcmd for the string was Not called before the crash happened. Therefore the code seems to be trying to precache random strings throughout itself, i don't even know if that's possible but there it is.

I don't expect any answers, since i might be the only one so far whom experienced this kind of mad error, so i am just throwing the project away. Thanks to everybody whom spent their time replying to my thread.


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

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