09/11/2019, 12:23 AM
Tengo un problema que habia solucionado pero hasta un cierto punto xD, la cosa es que vale al entrar al server se reproduce la musica de navidad en los arboles, pero a la siguiente ronda al ir hacia un arbol no suena la musica, es como si tuviera stop, se supone que esto tiene musica de fondo (dentro del rango del arbol), agradeceria mucho su ayuda <3
Pd: Ando actualizando el servidor tipo navidad xD
Pd: Ando actualizando el servidor tipo navidad xD
Código PHP:
#include < amxmodx >
#include < amxmisc >
#include < engine >
#include <fakemeta>
#define RADIO_SOUND 2 // pueden ser 2 4 y 8
new const MODEL[ ] = "models/christmas_tree1.mdl";
new const SOUND[ ] = "how_is_your_life_going.wav";
new g_szConfigFile[ 128 ];
public plugin_init( )
{
register_plugin( "Tree Spawner", "1.0", "xPaw" );
register_clcmd( "tree_spawn", "CmdSpawnTree" );
register_clcmd( "tree_remove", "CmdSpawnRemove" );
}
public plugin_precache( )
{
precache_model( MODEL );
precache_sound( SOUND );
}
public plugin_cfg( ) {
new szMapName[ 32 ];
get_mapname( szMapName, 31 );
strtolower( szMapName );
formatex( g_szConfigFile, 127, "addons/amxmodx/data/trees" );
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( );
console_print( id, "[AMXX] Arbol creado" );
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++;
console_print( id, "[AMXX] Arbol borrado" );
}
}
if( iDeleted > 0 )
SaveTrees( );
if( iDeleted == 0 )
console_print( id, "[AMXX] Tenes que estar en un arbol para poder borrarlo" );
return PLUGIN_HANDLED;
}
CreateTree( const Float:vOrigin[ 3 ] )
{
new iEntity = create_entity( "ambient_generic" );
if( !iEntity )
return 0;
set_pev( iEntity, pev_message, SOUND );
set_pev( iEntity, pev_spawnflags, RADIO_SOUND );
set_pev( iEntity, pev_effects, EF_BRIGHTFIELD );
client_cmd(0, "spk %s", SOUND)
set_pev( iEntity, pev_health, 10.0 );
DispatchSpawn( iEntity );
entity_set_string( iEntity, EV_SZ_classname, "env_tree" );
entity_set_int( iEntity, EV_INT_solid, SOLID_NOT );
entity_set_int( iEntity, EV_INT_movetype, MOVETYPE_NONE );
entity_set_size( iEntity, Float:{ -1.0, -1.0, -1.0 }, Float:{ 1.0, 1.0, 36.0 } );
entity_set_origin( iEntity, vOrigin);
entity_set_model( iEntity, MODEL );
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 );
}