Есть ли что-то,чтобы это исправить?
Примеры:
Сделать обьект простреливаемым
Сделать обьект непростреливаемым,но убрать искры.
Замена искр на кровь в Сером цвете ( в помощь RegisterHam(Ham_BloodColor)))
- Код: Выделить всё
#include < amxmodx >
#include < amxmisc >
#include < fakemeta >
#include < cstrike >
#include < engine >
#include < hamsandwich >
new const MODEL[ ] = "models/tree_wc/tree_wc.mdl";
new g_szConfigFile[ 128 ];
public plugin_init( ) {
register_plugin( "Xmas shit", "1.0", "xPaw & Juice" );
register_clcmd( "tree_spawn", "CmdSpawnTree", ADMIN_MAP );
register_clcmd( "tree_remove", "CmdSpawnRemove", ADMIN_MAP );
}
public plugin_precache( ) {
precache_model( MODEL );
}
public plugin_cfg( ) {
new szMapName[ 32 ];
get_mapname( szMapName, 31 );
strtolower( szMapName );
formatex( g_szConfigFile, 127, "addons/amxmodx/data/tree_wc" );
if( !dir_exists( g_szConfigFile ) ) {
mkdir( g_szConfigFile );
format( g_szConfigFile, 127, "%s/%s.txt", g_szConfigFile, szMapName );
return;
}
format( g_szConfigFile, 127, "%s/%s.txt", g_szConfigFile, szMapName );
if( !file_exists( g_szConfigFile ) )
return;
new iFile = fopen( g_szConfigFile, "rt" );
if( !iFile )
return;
new Float:vOrigin[ 3 ], x[ 16 ], y[ 16 ], z[ 16 ], szData[ sizeof( x ) + sizeof( y ) + sizeof( z ) + 3 ];
while( !feof( iFile ) ) {
fgets( iFile, szData, charsmax( szData ) );
trim( szData );
if( !szData[ 0 ] )
continue;
parse( szData, x, 15, y, 15, z, 15 );
vOrigin[ 0 ] = str_to_float( x );
vOrigin[ 1 ] = str_to_float( y );
vOrigin[ 2 ] = str_to_float( z );
CreateTree( vOrigin );
}
fclose( iFile );
}
public CmdSpawnTree( const id, const iLevel, const iCid ) {
if( !cmd_access( id, iLevel, iCid, 1 ) )
return PLUGIN_HANDLED;
new Float:vOrigin[ 3 ];
entity_get_vector( id, EV_VEC_origin, vOrigin );
if( CreateTree( vOrigin ) )
SaveTrees( );
return PLUGIN_HANDLED;
}
public CmdSpawnRemove( const id, const iLevel, const iCid ) {
if( !cmd_access( id, iLevel, iCid, 1 ) )
return PLUGIN_HANDLED;
new Float:vOrigin[ 3 ], szClassName[ 10 ], iEntity = -1, iDeleted;
entity_get_vector( id, EV_VEC_origin, vOrigin );
while( ( iEntity = find_ent_in_sphere( iEntity, vOrigin, 100.0 ) ) > 0 ) {
entity_get_string( iEntity, EV_SZ_classname, szClassName, 9 );
if( equal( szClassName, "env_tree" ) ) {
remove_entity( iEntity );
iDeleted++;
}
}
if( iDeleted > 0 )
SaveTrees( );
console_print( id, "[AMXX] Deleted %i trees.%s", iDeleted, iDeleted == 0 ? " You need to stand in tree to remove it" : "" );
return PLUGIN_HANDLED;
}
CreateTree( const Float:vOrigin[ 3 ] ) {
new iEntity = create_entity("info_target");
if( !iEntity )
return 0;
if(!pev_valid(iEntity))
return PLUGIN_HANDLED;
set_pev(iEntity, pev_origin, vOrigin);
set_pev(iEntity, pev_classname, "env_tree");
set_pev(iEntity, pev_solid, SOLID_BBOX);
engfunc(EngFunc_SetModel, iEntity, MODEL);
engfunc(EngFunc_SetSize, iEntity, Float:{ -1.0, -1.0, -1.0 }, Float:{ 1.0, 1.0, 250.0 } );
set_pev( iEntity, pev_sequence, 0);
set_pev( iEntity, pev_gaitsequence, 1);
set_pev( iEntity, pev_framerate, 3.0);
drop_to_floor( iEntity );
return iEntity;
}
SaveTrees( ) {
if( file_exists( g_szConfigFile ) )
delete_file( g_szConfigFile );
new iFile = fopen( g_szConfigFile, "wt" );
if( !iFile )
return;
new Float:vOrigin[ 3 ], iEntity;
while( ( iEntity = find_ent_by_class( iEntity, "env_tree" ) ) > 0 ) {
entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
fprintf( iFile, "%f %f %f^n", vOrigin[ 0 ], vOrigin[ 1 ], vOrigin[ 2 ] );
}
fclose( iFile );
}