AlliedModders

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

razermamba 01-20-2013 14:35

No precache
 
Hi everybody. Im making plugin with helping of Neeeeeeeel and I got this error all the time
Host_Error: no precache: w_glock18.mdl

This plugin is for weapon spawning on specific origins. Help please :)

PHP Code:

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

#define PLUGIN "Spawn Ents Example"
#define VERSION "v1.0"
#define AUTHOR "Neeeeeeeeeel.-"

#define WEAPON_ID pev_iuser1

new const g_Conf_File[ ] = { "weaponspawn.ini" };

new Array:
spawn_points_X;
new Array:
spawn_points_Y;
new Array:
spawn_points_Z;

enum {
    
0,
    
Y,
    
Z
};

enum _:Weapons {
    
Classname32 ],
    
Model32 ],
    
WeaponID,
    
AmmoAmount
}

new const 
WeaponList[ ][ ] = { 
    { 
"weapon_glock18""w_glock18.mdl"CSW_GLOCK18120 },
    { 
"weapon_usp""w_usp.mdl"CSW_USP100 },
    { 
"weapon_deagle""w_deagle.mdl"CSW_DEAGLE35 },
    { 
"weapon_ak47""w_ak47.mdl"CSW_AK4790 },
    { 
"weapon_m4a1""w_m4a1.mdl"CSW_M4A190 },
    { 
"weapon_famas""w_famas.mdl"CSW_FAMAS90 },
    { 
"weapon_galil""w_galil.mdl"CSW_GALIL90 },
    { 
"weapon_awp""w_awp.mdl"CSW_AWP30 },
    { 
"weapon_mp5""w_mp5.mdl"CSW_MP5NAVY120 },
    { 
"weapon_mac10""w_mac10.mdl"CSW_MAC10100 }
};

public 
plugin_precache( )
{
    new 
data64 ];
    
    for( new 
0sizeof WeaponListi++ )
    {
        
formatexdatacharsmaxdata ), "models/%s"WeaponList][ Model ] );
        
precache_modeldata );
    }
}

public 
plugin_init( )
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
    
register_clcmd"say /savespawn""cmdSaveSpawn" );
    
    
register_event"HLTV""event_round_start""a""1=0""2=0" );
    
    
register_touch"dropped_weapon""player""dropped_weapon_touch" );
    
    
spawn_points_X ArrayCreate1);
    
spawn_points_Y ArrayCreate1);
    
spawn_points_Z ArrayCreate1);
}

public 
plugin_cfg( )
{
    new 
confdir64 ], inifile64 ], data128 ], originX11 ], originY11 ], originZ11 ];
    
get_configsdirconfdircharsmaxconfdir ) );
    
formatexinifilecharsmaxconfdir ), "%s/%s"confdirg_Conf_File );
    new 
file fopeninifile"r" );
    
    while( !
feoffile ) )
    {
        
fgetsfiledatacharsmaxdata ) );
        
        if( !
data] )
            continue;
        
        
parsedataoriginX10originY10originZ10 );
        
        
ArrayPushCellspawn_points_Xstr_to_floatoriginX ) );
        
ArrayPushCellspawn_points_Ystr_to_floatoriginY ) );
        
ArrayPushCellspawn_points_Zstr_to_floatoriginZ ) );
    }
    
    
console_print0"Points loaded succesfuly" );
}

public 
dropped_weapon_touchenttoucher )
{
    static 
weaponid;
    
weaponid peventWEAPON_ID );
    
    
give_itemtoucherWeaponListweaponid ][ Classname ] );
    
cs_set_user_bpammotoucherWeaponListweaponid ][ WeaponID ], WeaponListweaponid ][ AmmoAmount ] );
}

public 
cmdSaveSpawnid )
{
    new 
Float:uOrigin], text64 ];
    
pevidpev_originuOrigin );
    
    new 
configdir64 ], file64 ];
    
get_configsdirconfigdircharsmaxconfigdir ) );
    
    
formatexfilecharsmaxfile ), "%s/%s"configdirg_Conf_File );
    
formatextextcharsmaxtext ), "%f %f %f"uOrigin], uOrigin], uOrigin] );
    
    
write_filefiletext );
    
    
client_printidprint_chat"WeaponSpawn Point saved!" );
}

public 
event_round_start( )
{
    if( 
ArraySizespawn_points_X ) < 10 )
        return;
    
    
console_print0"spawning weapons..." );
    
    for( new 
0sizeof WeaponListi++ )
    {
        static 
ent;
        
        
ent create_weaponi);
        
engfuncEngFunc_DropToFloorent );
    }
    
    
console_print0"weapons spawned!" );
}

create_weaponweaponidoriginid )
{
    static 
Ent;
    
Ent engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString"info_target" ) );
    
set_pevEntpev_classnameWeaponListweaponid ][ Classname ] );
    
engfuncEngFunc_SetModelEntWeaponListweaponid ][ Model ] );
    
set_pevEntpev_solidSOLID_TRIGGER );
    
set_pevEntWEAPON_IDweaponid );
    
engfuncEngFunc_SetSizeEntFloat:{ -50.0, -50.0, -50.0 }, Float:{ 50.050.050.0 } );
    
    static 
Float:origin];
    
origin] = Float:ArrayGetCellspawn_points_Xoriginid );
    
origin] = Float:ArrayGetCellspawn_points_Yoriginid );
    
origin] = Float:ArrayGetCellspawn_points_Zoriginid );
    
    
set_pevEntpev_originorigin );
    
    return 
Ent;



ConnorMcLeod 01-20-2013 16:29

Re: No precache
 
Better to create a weaponbox entity and to pass correct keyvalues, don't bother precaching anything.


All times are GMT -4. The time now is 13:46.

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