AlliedModders

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

DoviuX 05-30-2010 08:02

host_error
 
I get this error:

Code:

Host_Error: PF_precache_model_I: 'models/w_medkit.mdl' Precache can only
be done in spawn functions.

Code:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>

new CLASSNAME[] = "item_healthkit"

#define ACCESS_LEVEL ADMIN_CFG

new const g_medkit_pickup[] = "umbrella/medkit_pickup.wav"

new boolg_zombie[33]
new 
boolg_human[33]
new 
g_medkit[33]

new 
FILE[96]

public 
plugin_init()
{
    
register_touch("my_entity""player""medkit_pickup"
    
register_clcmd("healthkit_spawn""cmd_healthkit_spawn"ACCESS_LEVEL"[save]")
    
register_concmd("healthkit_load""cmd_healthkit_load"ACCESS_LEVEL"<x> <y> <z>")
    
register_concmd("healthkit_clear""cmd_healthkit_clear"ACCESS_LEVEL)

    
register_forward(FM_Touch"fw_medkit_pickup")

    new 
configs_dir[64], map[32]
    
get_configsdir(configs_dir63)
    
get_mapname(map31)
    
format(FILE95"%s/maps/%s.cfg"configs_dirmap)
}

public 
plugin_precache()
{
    
precache_sound(g_medkit_pickup)
}

public 
fw_medkit_pickup(pToucherpTouchedclient)
{
    if ( 
pev_valid(pToucher))
    {
        static 
className[32], className2[32]
        
pev(pToucherpev_classnameclassName31)
        if ( 
pev_valid(pTouched)) pev(pTouchedpev_classnameclassName231)
        
        if ( 
equal(classNameCLASSNAME))
        {
            if ( 
pev_valid(pTouched))
            {
                if ( 
equal(className2"player") && is_user_connected(pTouched))
                {
                    static 
origin[3]
                    
get_user_origin(pTouchedorigin)
                    
                    if(
g_zombie[pToucher])
                    {
                        return 
PLUGIN_HANDLED
                    
}
                    else if(
g_human[pToucher])
                    {
                        
emit_sound(clientCHAN_ITEMg_medkit_pickup1.0ATTN_NORM0PITCH_NORM);
                        
g_medkit[client] = true
                    }
                    
                }
            }        
            
engfunc(EngFunc_RemoveEntitypToucher)
        }
    }
    return 
FMRES_IGNORED
}

public 
cmd_healthkit_spawn(idlevelcid) {
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED

    emit_sound
(idCHAN_ITEMg_medkit_pickup1.0ATTN_NORM0PITCH_NORM);

    new 
origin[3]
    
get_user_origin(idorigin)
    
healthkit_spawn(origin

    new 
arg1[6]
    
read_argv(1arg15)
    if (!
equali(arg1"save"))
        return 
PLUGIN_HANDLED

    
new command[48]
    
format(command47"healthkit_load %d %d %d"origin[0], origin[1], origin[2])
    
write_file(FILEcommand)

    return 
PLUGIN_HANDLED
}

public 
cmd_healthkit_load(idlevelcid) {
    if (!
cmd_access(idlevelcid4))
        return 
PLUGIN_HANDLED

    
new arg1[8], arg2[8], arg3[8], origin[3]
    
read_argv(1arg17)
    
read_argv(2arg27)
    
read_argv(3arg37)
    
origin[0] = str_to_num(arg1)
    
origin[1] = str_to_num(arg2)
    
origin[2] = str_to_num(arg3)
    
healthkit_spawn(origin)

    return 
PLUGIN_HANDLED
}

public 
cmd_healthkit_clear(idlevelcid) {
    if (!
cmd_access(idlevelcid1))
        return 
PLUGIN_HANDLED

    
new healthkit = -1
    
while ((healthkit find_ent_by_class(healthkitCLASSNAME)))
        
remove_entity(healthkit)

    return 
PLUGIN_HANDLED
}

healthkit_spawn(origin[3]) {
    new 
healthkit create_entity(CLASSNAME)
    if (!
healthkit)
        return

    new 
Float:vec[3]
    
IVecFVec(originvec)
    
entity_set_origin(healthkitvec)
    
DispatchSpawn(healthkit)



killer007774 06-05-2010 15:29

Re: host_error
 
Are you sure you got the Model?


All times are GMT -4. The time now is 05:25.

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