hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.04.19. 10:15



Jelenlévő felhasználók

Jelenleg 234 felhasználó van jelen :: 1 regisztrált, 0 rejtett és 233 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot] az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 10 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Alt End Round Sounds [Lang nélkül]
HozzászólásElküldve: 2015.01.23. 21:20 
Offline
Felfüggesztve
Avatar

Csatlakozott: 2014.12.05. 20:46
Hozzászólások: 177
Megköszönt másnak: 3 alkalommal
Megköszönték neki: 23 alkalommal
Üdv!

Valaki át tudná nekem úgy írni, hogy langot ne kelljen olvasni neki? Köszönöm előre is!

SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4.  
  5. new const
  6. // _________________________________________________
  7.  
  8. PLUGIN [] = "Alternative End Round Sounds",
  9. VERSION[] = "2.3b",
  10. AUTHOR [] = "Arkshine";
  11. // _________________________________________________
  12.  
  13.  
  14. #if AMXX_VERSION_NUM < 180
  15. #define old_amxx
  16. #endif
  17.  
  18.  
  19. /* ========================= [ "START" AERA FOR CHANGES ] ========================= */
  20.  
  21.  
  22. #define _DEBUG // Active debug
  23. #define MAX_FILE_LENGTH 196 // Max length for files + path.
  24.  
  25. #if defined old_amxx
  26. #define MAX_SOUNDS 25 // Max sounds per team
  27. #endif
  28.  
  29. new const
  30.  
  31. g_FileName[] = "roundsound", // Name of the main file if no files is found in 'g_FileFolder'.
  32. g_FileFolder[] = "round_sound", // Name of the directory in amxmodx/configs/ for per-map files.
  33. g_FilePrefix[] = "ini", // File extension used for the files.
  34. g_CmdChat[] = "/roundsound"; // Chat command for player.
  35.  
  36.  
  37. /* ========================= [ "END" AERA FOR CHANGES ] ========================= */
  38.  
  39.  
  40.  
  41. // - - - - - - - - - - - - - - - - - - - - - - -
  42.  
  43. #define MAX_PLAYERS 32
  44. #define TASKID_ADS 1333
  45. #define SIZE_FILE 0
  46. #define NULL -1
  47.  
  48. new
  49. bool:g_pHeardSound[ MAX_PLAYERS + 1 ],
  50.  
  51. #if !defined old_amxx
  52. Array:g_lstSoundCT,
  53. Array:g_lstSoundT,
  54. #endif
  55.  
  56. p_enabled,
  57. p_player_toggle,
  58. p_time_ads,
  59. p_random_precache,
  60.  
  61. g_sRp_value[12],
  62. g_msgSayText;
  63.  
  64.  
  65. enum _:e_Team
  66. {
  67. T = 0,
  68. CT,
  69. };
  70.  
  71. new g_nSnd[ e_Team ];
  72.  
  73. #if defined old_amxx
  74. new g_sTeam_sounds[ MAX_SOUNDS ][ e_Team ][ MAX_FILE_LENGTH ];
  75. #define charsmax(%1) sizeof( %1 ) - 1
  76. #endif
  77.  
  78. #define _is_wav(%1) equali( %1[strlen( %1 ) - 4 ], ".wav" )
  79.  
  80. // - - - - - - - - - - - - - - - - - - - - - - -
  81.  
  82.  
  83. public plugin_precache()
  84. {
  85. register_dictionary( "end_roundsound.txt" );
  86.  
  87. if( ( p_random_precache = get_cvar_pointer( "erc_random_precache" ) ) )
  88. get_pcvar_string( p_random_precache, g_sRp_value, charsmax( g_sRp_value ) );
  89.  
  90. if( !p_random_precache )
  91. return;
  92.  
  93. #if !defined old_amxx
  94. g_lstSoundCT = ArrayCreate( MAX_FILE_LENGTH );
  95. g_lstSoundT = ArrayCreate( MAX_FILE_LENGTH );
  96. #endif
  97.  
  98. loading_file();
  99. }
  100.  
  101.  
  102. public plugin_init()
  103. {
  104. register_plugin( PLUGIN, VERSION, AUTHOR );
  105. register_cvar( "ers_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY );
  106.  
  107. register_event( "SendAudio", "eT_win" , "a", "2&%!MRAD_terwin" );
  108. register_event( "SendAudio", "eCT_win", "a", "2&%!MRAD_ctwin" );
  109.  
  110. p_enabled = register_cvar( "ers_enabled" , "1" );
  111. p_player_toggle = register_cvar( "ers_player_toggle" , "1" );
  112. p_time_ads = register_cvar( "erc_time_ads" , "120" );
  113.  
  114. if( !p_random_precache )
  115. {
  116. register_cvar( "erc_random_precache", g_sRp_value );
  117. server_cmd( "restart" );
  118. }
  119.  
  120. register_clcmd( "say" , "cmd_Say" );
  121. register_clcmd( "say_team" , "cmd_Say" );
  122.  
  123. g_msgSayText = get_user_msgid( "SayText" );
  124. }
  125.  
  126.  
  127. public client_authorized( id )
  128. g_pHeardSound[id] = true;
  129.  
  130.  
  131. public client_disconnect( id )
  132. {
  133. g_pHeardSound[id] = true;
  134. remove_task( id + TASKID_ADS );
  135. }
  136.  
  137.  
  138. public client_putinserver( id )
  139. {
  140. new Float:time = get_pcvar_float( p_time_ads );
  141.  
  142. if( !time )
  143. return;
  144.  
  145. remove_task( id + TASKID_ADS );
  146. set_task( time, "show_ads", id + TASKID_ADS, _, _, "b" );
  147. }
  148.  
  149.  
  150. public show_ads( taskid )
  151. {
  152. new id = taskid - TASKID_ADS;
  153. ShowPrint( id, "%L", id, "ERS_DISPLAY_ADS", g_CmdChat );
  154. }
  155.  
  156.  
  157. public cmd_Say( id )
  158. {
  159. if( !get_pcvar_num( p_enabled ) )
  160. return PLUGIN_CONTINUE;
  161.  
  162. static sMsg[64];
  163. read_argv( 1, sMsg, charsmax( sMsg ) );
  164.  
  165. if( equali( sMsg, g_CmdChat ) )
  166. {
  167. if( !get_pcvar_num( p_player_toggle ) )
  168. {
  169. ShowPrint( id, "%L", id, "ERS_CMD_DISABLED" );
  170. return PLUGIN_HANDLED;
  171. }
  172.  
  173. g_pHeardSound[id] = g_pHeardSound[id] ? false : true;
  174. ShowPrint( id, "%L", id, g_pHeardSound[id] ? "ERS_SOUND_ENABLED" : "ERS_SOUND_DISABLED" );
  175.  
  176. return PLUGIN_HANDLED;
  177. }
  178.  
  179. return PLUGIN_CONTINUE;
  180. }
  181.  
  182.  
  183. public eT_win()
  184. {
  185. if( !g_nSnd[ e_Team:T ] )
  186. return;
  187.  
  188. play_sound( e_Team:T );
  189. }
  190.  
  191.  
  192. public eCT_win()
  193. {
  194. if( !g_nSnd[ e_Team:CT ] )
  195. return;
  196.  
  197. play_sound( e_Team:CT );
  198. }
  199.  
  200.  
  201. play_sound( iTeam )
  202. {
  203. static
  204. // - - - - - - - - - - - - - - - -
  205. sCurSnd[ MAX_FILE_LENGTH ];
  206. // - - - - - - - - - - - - - - - -
  207.  
  208. new iRand;
  209.  
  210. if( g_nSnd[ iTeam ] > 1 )
  211. iRand = random( g_nSnd[ iTeam ] );
  212.  
  213. #if defined old_amxx
  214. copy( sCurSnd, MAX_FILE_LENGTH - 1, g_sTeam_sounds[ iRand ][ iTeam ] );
  215. #else
  216. ArrayGetString( iTeam == CT ? g_lstSoundCT : g_lstSoundT, iRand, sCurSnd, MAX_FILE_LENGTH - 1 );
  217. #endif
  218.  
  219. _is_wav( sCurSnd ) ?
  220.  
  221. format( sCurSnd, MAX_FILE_LENGTH - 1, "spk %s", sCurSnd[6] ) :
  222. format( sCurSnd, MAX_FILE_LENGTH - 1, "mp3 play %s", sCurSnd );
  223.  
  224. if( get_pcvar_num( p_player_toggle ) )
  225. {
  226. static
  227. // - - - - - - - - - - -
  228. iPlayers[32],
  229. iNum, pid;
  230. // - - - - - - - - - - -
  231.  
  232. get_players( iPlayers, iNum, "c" );
  233.  
  234. for( new i; i < iNum; i++ )
  235. {
  236. pid = iPlayers[i];
  237.  
  238. if( !g_pHeardSound[pid] || is_user_bot( pid ) )
  239. continue;
  240.  
  241. client_cmd( pid, "%s", sCurSnd );
  242. }
  243. }
  244. else
  245. client_cmd( 0, "%s", sCurSnd );
  246. }
  247.  
  248.  
  249. get_prefix( sMap[], iLen_map, sMapType[], iLen_type )
  250. {
  251. new
  252. // - - - - - - - - -
  253. sRest[32];
  254. // - - - - - - - - -
  255.  
  256. get_mapname( sMap, iLen_map );
  257. strtok( sMap, sMapType, iLen_type, sRest, charsmax( sRest ), '_', 1 );
  258. }
  259.  
  260.  
  261. loading_file()
  262. {
  263. static
  264. // - - - - - - - - - - - - - - - - -
  265. sPath[ MAX_FILE_LENGTH ],
  266. // |
  267. sConfigsDir[64],
  268. sPrefix[6],
  269. sMap[32];
  270. // - - - - - - - - - - - - - - - - -
  271.  
  272. get_prefix( sMap, charsmax( sMap ), sPrefix, charsmax( sPrefix ) );
  273. get_configsdir( sConfigsDir, charsmax( sConfigsDir ) );
  274.  
  275.  
  276. new bool:bFound;
  277.  
  278. for( new i = 1; i <= 3; i++ )
  279. {
  280. switch( i )
  281. {
  282. case 1 : formatex( sPath, charsmax( sPath ), "%s/%s/prefix-%s.%s", sConfigsDir, g_FileFolder, sPrefix, g_FilePrefix );
  283. case 2 : formatex( sPath, charsmax( sPath ), "%s/%s/%s.%s", sConfigsDir, g_FileFolder, sMap, g_FilePrefix );
  284. case 3 : formatex( sPath, charsmax( sPath ), "%s/%s.%s", sConfigsDir, g_FileName, g_FilePrefix );
  285.  
  286. default : break;
  287. }
  288.  
  289. if( !CheckFile( sPath ) )
  290. continue;
  291.  
  292. bFound = true;
  293. break;
  294. }
  295.  
  296. log_amx( "---" );
  297.  
  298. bFound ?
  299. log_amx( "%L", LANG_SERVER, "ERS_LOG_LOADING", sPath ) :
  300. log_amx( "%L", LANG_SERVER, "ERS_LOG_NO_FILES_FOUND" );
  301.  
  302. load_sound( sPath );
  303. }
  304.  
  305.  
  306. load_sound( const file[] )
  307. {
  308. new
  309. // - - - - - - - - - - - - - - -
  310. sBuffer[256],
  311. // |
  312. sLeft[ MAX_FILE_LENGTH ],
  313. sRight[4],
  314. sExt[6],
  315. // |
  316. eTeam;
  317. // - - - - - - - - - - - - - - -
  318.  
  319. new fp = fopen( file, "rt" );
  320.  
  321. while( !feof( fp ) )
  322. {
  323. fgets( fp, sBuffer, charsmax( sBuffer ) );
  324.  
  325. trim( sBuffer );
  326.  
  327. if( !sBuffer[0] || sBuffer[0] == ';' || ( sBuffer[0] == '/' && sBuffer[1] == '/' ) )
  328. continue;
  329.  
  330. if( sBuffer[0] != '"' || strlen( sBuffer ) < 11 )
  331. continue;
  332.  
  333. parse( sBuffer, sLeft, charsmax( sLeft ), sRight, charsmax( sRight ) );
  334. formatex( sExt, charsmax( sExt ), sLeft[ strlen( sLeft ) - 4 ] );
  335.  
  336. if( equali( sExt, ".mp3" ) == -1 || equali( sExt, ".wav" ) == -1 )
  337. {
  338. log_amx( "%L", LANG_SERVER, "ERS_LOG_UNKNOW_EXTENSION", sExt );
  339. continue;
  340. }
  341.  
  342. if( !file_exists( sLeft ) )
  343. {
  344. log_amx( "%L", LANG_SERVER, "ERS_LOG_INEXISTENT_FILE", sLeft );
  345. continue;
  346. }
  347.  
  348. eTeam = NULL;
  349.  
  350. if( equali( sRight, "CT" ) )
  351. eTeam = CT;
  352.  
  353. else if( equali( sRight, "T" ) )
  354. eTeam = T;
  355.  
  356. if( eTeam == NULL )
  357. {
  358. log_amx( "%L", LANG_SERVER, "ERS_LOG_NO_TEAM_SOUND", sLeft );
  359. continue;
  360. }
  361.  
  362. #if defined old_amxx
  363. copy( g_sTeam_sounds[ g_nSnd[ eTeam ] ][ eTeam ], MAX_FILE_LENGTH - 1, sLeft );
  364. #else
  365. ArrayPushString( eTeam == CT ? g_lstSoundCT : g_lstSoundT, sLeft );
  366. #endif
  367.  
  368. ++g_nSnd[ eTeam ];
  369. }
  370. fclose( fp );
  371.  
  372. if( g_nSnd[ e_Team:T ] > 1 || g_nSnd[ e_Team:CT ] > 1 )
  373. {
  374. new iMax_t, iMax_ct;
  375. GetPrecacheValue( iMax_t, iMax_ct );
  376.  
  377. #if defined old_amxx
  378. UpdateArray( iMax_t, e_Team:T );
  379. UpdateArray( iMax_ct, e_Team:CT );
  380. #else
  381. p_DeleteRandomItem( iMax_t , e_Team:T , g_lstSoundT );
  382. p_DeleteRandomItem( iMax_ct, e_Team:CT, g_lstSoundCT );
  383. #endif
  384. }
  385.  
  386. log_amx( "---" );
  387.  
  388. #if defined _DEBUG
  389. log_amx( "[ Loading %d CTs Sounds ]", g_nSnd[ e_team:CT ] );
  390. #endif
  391. #if defined old_amxx
  392. PrecacheSounds( e_Team:CT );
  393. #else
  394. PrecacheSounds_n( g_lstSoundCT );
  395. #endif
  396.  
  397. #if defined _DEBUG
  398. log_amx( "[ Loading %d Ts Sounds ]", g_nSnd[ e_team:T ] );
  399. #endif
  400. #if defined old_amxx
  401. PrecacheSounds( e_Team:T );
  402. #else
  403. PrecacheSounds_n( g_lstSoundT );
  404. #endif
  405. }
  406.  
  407.  
  408. GetPrecacheValue( &iMax_t, &iMax_ct )
  409. {
  410. trim( g_sRp_value );
  411. new pos = contain( g_sRp_value, "-" );
  412.  
  413. if( pos > 0 )
  414. {
  415. iMax_ct = str_to_num( g_sRp_value[ pos + 1 ] )
  416. g_sRp_value[ pos ] = '^0';
  417. iMax_t = str_to_num( g_sRp_value );
  418. }
  419. else
  420. {
  421. iMax_t = str_to_num( g_sRp_value );
  422. iMax_ct = iMax_t;
  423. }
  424. }
  425.  
  426.  
  427. stock UpdateArray( iMax, iTeam )
  428. {
  429. new const iCnt_sound = g_nSnd[ iTeam ];
  430.  
  431. if( !iMax || iMax == iCnt_sound )
  432. return;
  433.  
  434. if( iMax >= iCnt_sound )
  435. iMax = iCnt_sound - 1;
  436.  
  437. static
  438. sTmp_sounds[ MAX_SOUNDS ][ e_Team ][ MAX_FILE_LENGTH ],
  439. iLast_number[ MAX_SOUNDS ];
  440.  
  441. new i, iRand;
  442. for( i = 0; i < iCnt_sound; i++ )
  443. {
  444. copy( sTmp_sounds[i][ iTeam ], MAX_FILE_LENGTH - 1, g_sTeam_sounds[i][ iTeam ] );
  445. g_sTeam_sounds[i][ iTeam ][0] = '^0';
  446. }
  447.  
  448. arrayset( iLast_number, 0, charsmax( iLast_number ) );
  449.  
  450. i = 0;
  451. while( i != iMax )
  452. {
  453. check:
  454. iRand = random( iCnt_sound );
  455.  
  456. if( iLast_number[ iRand ] )
  457. goto check;
  458.  
  459. copy( g_sTeam_sounds[i][ iTeam ], MAX_FILE_LENGTH - 1, sTmp_sounds[ iRand ][ iTeam ] );
  460. ++i;
  461.  
  462. iLast_number[ iRand ] = 1;
  463. }
  464.  
  465. g_nSnd[ iTeam ] = iMax;
  466. }
  467.  
  468.  
  469. stock p_DeleteRandomItem( iMax, iTeam, Array:sSound_a )
  470. {
  471. new const iCnt_sound = g_nSnd[ iTeam ];
  472.  
  473. if( !iMax || iMax == iCnt_sound )
  474. return;
  475.  
  476. if( iMax >= iCnt_sound )
  477. iMax = iCnt_sound - 1;
  478.  
  479. DeleteRandomItem( iCnt_sound - iMax, sSound_a );
  480. g_nSnd[ iTeam ] = iMax;
  481. }
  482.  
  483.  
  484. stock DeleteRandomItem( iRandom_n, Array:sSound_a )
  485. {
  486. new i;
  487.  
  488. while( i++ != iRandom_n )
  489. ArrayDeleteItem( sSound_a, random( ArraySize( sSound_a ) ) );
  490. }
  491.  
  492.  
  493. stock PrecacheSounds( iTeam )
  494. {
  495. for( new i; i < g_nSnd[ iTeam ]; i++ )
  496. {
  497. PrecacheFile( g_sTeam_sounds[i][ iTeam ] );
  498.  
  499. #if defined _DEBUG
  500. log_amx( " - %s", g_sTeam_sounds[i][ iTeam ] );
  501. #endif
  502. }
  503.  
  504. log_amx( "---" );
  505. }
  506.  
  507.  
  508. stock PrecacheSounds_n( Array:sSound_a )
  509. {
  510. static
  511. // - - - - - - - - - - - - - - - - - - -
  512. sFile[ MAX_FILE_LENGTH ],
  513. iFileLen = charsmax( sFile );
  514. // - - - - - - - - - - - - - - - - - - -
  515.  
  516. for( new i; i < ArraySize( sSound_a ); i++ )
  517. {
  518. ArrayGetString( sSound_a, i, sFile, iFileLen );
  519. PrecacheFile( sFile );
  520.  
  521. #if defined _DEBUG
  522. log_amx( " - %s", sFile );
  523. #endif
  524. }
  525.  
  526. log_amx( "---" );
  527. }
  528.  
  529.  
  530. PrecacheFile( const sound[] )
  531. {
  532. _is_wav( sound ) ?
  533.  
  534. precache_sound( sound[6] ) :
  535. precache_generic( sound );
  536. }
  537.  
  538.  
  539. ShowPrint( id, const sMsg[], { Float, Sql, Result, _ }:... )
  540. {
  541. static
  542. // - - - - - - - - -
  543. newMsg[191],
  544. message[191],
  545. // |
  546. tNewMsg;
  547. // - - - - - - - - -
  548.  
  549. tNewMsg = charsmax( newMsg );
  550. vformat( newMsg, tNewMsg, sMsg, 3 );
  551.  
  552. replace_all( newMsg, tNewMsg, "!t", "^3" );
  553. replace_all( newMsg, tNewMsg, "!g", "^4" );
  554. replace_all( newMsg, tNewMsg, "!n", "^1" );
  555.  
  556. formatex( message, charsmax( message ), "^4[ERS]^1 %s", newMsg );
  557.  
  558. emessage_begin( MSG_ONE, g_msgSayText, _, id );
  559. ewrite_byte( id );
  560. ewrite_string( message );
  561. emessage_end();
  562. }
  563.  
  564.  
  565. bool:CheckFile( const file[] )
  566. {
  567. new
  568. // - - - - - - - - - - - - - - - - -
  569. sBuffer[256],
  570. fp = fopen( file, "rt" );
  571. // - - - - - - - - - - - - - - - - -
  572.  
  573. if( !fp )
  574. return false;
  575.  
  576. while( !feof( fp ) )
  577. {
  578. fgets( fp, sBuffer, charsmax( sBuffer ) );
  579.  
  580. trim( sBuffer );
  581.  
  582. if( !sBuffer[0] || sBuffer[0] == ';' || ( sBuffer[0] == '/' && sBuffer[1] == '/' ) || sBuffer[0] != '"' )
  583. continue;
  584.  
  585. if( ( contain( sBuffer, ".mp3^"" ) != -1 || contain( sBuffer, ".wav^"" ) != -1 ) && ( contain( sBuffer, "^"T^"" ) != -1 || contain( sBuffer, "^"CT^"" ) != -1 ) )
  586. return true;
  587. }
  588. fclose( fp );
  589.  
  590. return false;
  591. }

_________________
Kép
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Alt End Round Sounds [Lang nélkül]
HozzászólásElküldve: 2015.01.23. 22:01 
Offline
Jómunkásember
Avatar

Csatlakozott: 2014.09.27. 19:51
Hozzászólások: 411
Megköszönt másnak: 89 alkalommal
Megköszönték neki: 14 alkalommal
Talán
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4.  
  5. new const
  6. // _________________________________________________
  7.  
  8. PLUGIN [] = "Alternative End Round Sounds",
  9. VERSION[] = "2.3b",
  10. AUTHOR [] = "Arkshine";
  11. // _________________________________________________
  12.  
  13.  
  14. #if AMXX_VERSION_NUM < 180
  15. #define old_amxx
  16. #endif
  17.  
  18.  
  19. /* ========================= [ "START" AERA FOR CHANGES ] ========================= */
  20.  
  21.  
  22. #define _DEBUG // Active debug
  23. #define MAX_FILE_LENGTH 196 // Max length for files + path.
  24.  
  25. #if defined old_amxx
  26. #define MAX_SOUNDS 25 // Max sounds per team
  27. #endif
  28.  
  29. new const
  30.  
  31. g_FileName[] = "roundsound", // Name of the main file if no files is found in 'g_FileFolder'.
  32. g_FileFolder[] = "round_sound", // Name of the directory in amxmodx/configs/ for per-map files.
  33. g_FilePrefix[] = "ini", // File extension used for the files.
  34. g_CmdChat[] = "/roundsound"; // Chat command for player.
  35.  
  36.  
  37. /* ========================= [ "END" AERA FOR CHANGES ] ========================= */
  38.  
  39.  
  40.  
  41. // - - - - - - - - - - - - - - - - - - - - - - -
  42.  
  43. #define MAX_PLAYERS 32
  44. #define TASKID_ADS 1333
  45. #define SIZE_FILE 0
  46. #define NULL -1
  47.  
  48. new
  49. bool:g_pHeardSound[ MAX_PLAYERS + 1 ],
  50.  
  51. #if !defined old_amxx
  52. Array:g_lstSoundCT,
  53. Array:g_lstSoundT,
  54. #endif
  55.  
  56. p_enabled,
  57. p_player_toggle,
  58. p_time_ads,
  59. p_random_precache,
  60.  
  61. g_sRp_value[12],
  62. g_msgSayText;
  63.  
  64.  
  65. enum _:e_Team
  66. {
  67. T = 0,
  68. CT,
  69. };
  70.  
  71. new g_nSnd[ e_Team ];
  72.  
  73. #if defined old_amxx
  74. new g_sTeam_sounds[ MAX_SOUNDS ][ e_Team ][ MAX_FILE_LENGTH ];
  75. #define charsmax(%1) sizeof( %1 ) - 1
  76. #endif
  77.  
  78. #define _is_wav(%1) equali( %1[strlen( %1 ) - 4 ], ".wav" )
  79.  
  80. // - - - - - - - - - - - - - - - - - - - - - - -
  81.  
  82.  
  83. public plugin_precache()
  84. {
  85. register_dictionary( "end_roundsound.txt" );
  86.  
  87. if( ( p_random_precache = get_cvar_pointer( "erc_random_precache" ) ) )
  88. get_pcvar_string( p_random_precache, g_sRp_value, charsmax( g_sRp_value ) );
  89.  
  90. if( !p_random_precache )
  91. return;
  92.  
  93. #if !defined old_amxx
  94. g_lstSoundCT = ArrayCreate( MAX_FILE_LENGTH );
  95. g_lstSoundT = ArrayCreate( MAX_FILE_LENGTH );
  96. #endif
  97.  
  98. loading_file();
  99. }
  100.  
  101.  
  102. public plugin_init()
  103. {
  104. register_plugin( PLUGIN, VERSION, AUTHOR );
  105. register_cvar( "ers_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY );
  106.  
  107. register_event( "SendAudio", "eT_win" , "a", "2&%!MRAD_terwin" );
  108. register_event( "SendAudio", "eCT_win", "a", "2&%!MRAD_ctwin" );
  109.  
  110. p_enabled = register_cvar( "ers_enabled" , "1" );
  111. p_player_toggle = register_cvar( "ers_player_toggle" , "1" );
  112. p_time_ads = register_cvar( "erc_time_ads" , "120" );
  113.  
  114. if( !p_random_precache )
  115. {
  116. register_cvar( "erc_random_precache", g_sRp_value );
  117. server_cmd( "restart" );
  118. }
  119.  
  120. register_clcmd( "say" , "cmd_Say" );
  121. register_clcmd( "say_team" , "cmd_Say" );
  122.  
  123. g_msgSayText = get_user_msgid( "SayText" );
  124. }
  125.  
  126.  
  127. public client_authorized( id )
  128. g_pHeardSound[id] = true;
  129.  
  130.  
  131. public client_disconnect( id )
  132. {
  133. g_pHeardSound[id] = true;
  134. remove_task( id + TASKID_ADS );
  135. }
  136.  
  137.  
  138. public client_putinserver( id )
  139. {
  140. new Float:time = get_pcvar_float( p_time_ads );
  141.  
  142. if( !time )
  143. return;
  144.  
  145. remove_task( id + TASKID_ADS );
  146. set_task( time, "show_ads", id + TASKID_ADS, _, _, "b" );
  147. }
  148.  
  149.  
  150. public show_ads( taskid )
  151. {
  152. new id = taskid - TASKID_ADS;
  153. ShowPrint( id, "%L", id, "ERS_DISPLAY_ADS", g_CmdChat );
  154. }
  155.  
  156.  
  157. public cmd_Say( id )
  158. {
  159. if( !get_pcvar_num( p_enabled ) )
  160. return PLUGIN_CONTINUE;
  161.  
  162. static sMsg[64];
  163. read_argv( 1, sMsg, charsmax( sMsg ) );
  164.  
  165. if( equali( sMsg, g_CmdChat ) )
  166. {
  167. if( !get_pcvar_num( p_player_toggle ) )
  168. {
  169. ShowPrint( id, "%L", id, "ERS_CMD_DISABLED" );
  170. return PLUGIN_HANDLED;
  171. }
  172.  
  173. g_pHeardSound[id] = g_pHeardSound[id] ? false : true;
  174. ShowPrint( id, "%L", id, g_pHeardSound[id] ? "ERS_SOUND_ENABLED" : "ERS_SOUND_DISABLED" );
  175.  
  176. return PLUGIN_HANDLED;
  177. }
  178.  
  179. return PLUGIN_CONTINUE;
  180. }
  181.  
  182.  
  183. public eT_win()
  184. {
  185. if( !g_nSnd[ e_Team:T ] )
  186. return;
  187.  
  188. play_sound( e_Team:T );
  189. }
  190.  
  191.  
  192. public eCT_win()
  193. {
  194. if( !g_nSnd[ e_Team:CT ] )
  195. return;
  196.  
  197. play_sound( e_Team:CT );
  198. }
  199.  
  200.  
  201. play_sound( iTeam )
  202. {
  203. static
  204. // - - - - - - - - - - - - - - - -
  205. sCurSnd[ MAX_FILE_LENGTH ];
  206. // - - - - - - - - - - - - - - - -
  207.  
  208. new iRand;
  209.  
  210. if( g_nSnd[ iTeam ] > 1 )
  211. iRand = random( g_nSnd[ iTeam ] );
  212.  
  213. #if defined old_amxx
  214. copy( sCurSnd, MAX_FILE_LENGTH - 1, g_sTeam_sounds[ iRand ][ iTeam ] );
  215. #else
  216. ArrayGetString( iTeam == CT ? g_lstSoundCT : g_lstSoundT, iRand, sCurSnd, MAX_FILE_LENGTH - 1 );
  217. #endif
  218.  
  219. _is_wav( sCurSnd ) ?
  220.  
  221. format( sCurSnd, MAX_FILE_LENGTH - 1, "spk %s", sCurSnd[6] ) :
  222. format( sCurSnd, MAX_FILE_LENGTH - 1, "mp3 play %s", sCurSnd );
  223.  
  224. if( get_pcvar_num( p_player_toggle ) )
  225. {
  226. static
  227. // - - - - - - - - - - -
  228. iPlayers[32],
  229. iNum, pid;
  230. // - - - - - - - - - - -
  231.  
  232. get_players( iPlayers, iNum, "c" );
  233.  
  234. for( new i; i < iNum; i++ )
  235. {
  236. pid = iPlayers[i];
  237.  
  238. if( !g_pHeardSound[pid] || is_user_bot( pid ) )
  239. continue;
  240.  
  241. client_cmd( pid, "%s", sCurSnd );
  242. }
  243. }
  244. else
  245. client_cmd( 0, "%s", sCurSnd );
  246. }
  247.  
  248.  
  249. get_prefix( sMap[], iLen_map, sMapType[], iLen_type )
  250. {
  251. new
  252. // - - - - - - - - -
  253. sRest[32];
  254. // - - - - - - - - -
  255.  
  256. get_mapname( sMap, iLen_map );
  257. strtok( sMap, sMapType, iLen_type, sRest, charsmax( sRest ), '_', 1 );
  258. }
  259.  
  260.  
  261. loading_file()
  262. {
  263. static
  264. // - - - - - - - - - - - - - - - - -
  265. sPath[ MAX_FILE_LENGTH ],
  266. // |
  267. sConfigsDir[64],
  268. sPrefix[6],
  269. sMap[32];
  270. // - - - - - - - - - - - - - - - - -
  271.  
  272. get_prefix( sMap, charsmax( sMap ), sPrefix, charsmax( sPrefix ) );
  273. get_configsdir( sConfigsDir, charsmax( sConfigsDir ) );
  274.  
  275.  
  276. new bool:bFound;
  277.  
  278. for( new i = 1; i <= 3; i++ )
  279. {
  280. switch( i )
  281. {
  282. case 1 : formatex( sPath, charsmax( sPath ), "%s/%s/prefix-%s.%s", sConfigsDir, g_FileFolder, sPrefix, g_FilePrefix );
  283. case 2 : formatex( sPath, charsmax( sPath ), "%s/%s/%s.%s", sConfigsDir, g_FileFolder, sMap, g_FilePrefix );
  284. case 3 : formatex( sPath, charsmax( sPath ), "%s/%s.%s", sConfigsDir, g_FileName, g_FilePrefix );
  285.  
  286. default : break;
  287. }
  288.  
  289. if( !CheckFile( sPath ) )
  290. continue;
  291.  
  292. bFound = true;
  293. break;
  294. }
  295.  
  296. log_amx( "---" );
  297.  
  298.  
  299. load_sound( sPath );
  300. }
  301.  
  302.  
  303. load_sound( const file[] )
  304. {
  305. new
  306. // - - - - - - - - - - - - - - -
  307. sBuffer[256],
  308. // |
  309. sLeft[ MAX_FILE_LENGTH ],
  310. sRight[4],
  311. sExt[6],
  312. // |
  313. eTeam;
  314. // - - - - - - - - - - - - - - -
  315.  
  316. new fp = fopen( file, "rt" );
  317.  
  318. while( !feof( fp ) )
  319. {
  320. fgets( fp, sBuffer, charsmax( sBuffer ) );
  321.  
  322. trim( sBuffer );
  323.  
  324. if( !sBuffer[0] || sBuffer[0] == ';' || ( sBuffer[0] == '/' && sBuffer[1] == '/' ) )
  325. continue;
  326.  
  327. if( sBuffer[0] != '"' || strlen( sBuffer ) < 11 )
  328. continue;
  329.  
  330. parse( sBuffer, sLeft, charsmax( sLeft ), sRight, charsmax( sRight ) );
  331. formatex( sExt, charsmax( sExt ), sLeft[ strlen( sLeft ) - 4 ] );
  332.  
  333. if( equali( sExt, ".mp3" ) == -1 || equali( sExt, ".wav" ) == -1 )
  334. {
  335. continue;
  336. }
  337.  
  338. if( !file_exists( sLeft ) )
  339. {
  340. continue;
  341. }
  342.  
  343. eTeam = NULL;
  344.  
  345. if( equali( sRight, "CT" ) )
  346. eTeam = CT;
  347.  
  348. else if( equali( sRight, "T" ) )
  349. eTeam = T;
  350.  
  351. if( eTeam == NULL )
  352. {
  353. continue;
  354. }
  355.  
  356. #if defined old_amxx
  357. copy( g_sTeam_sounds[ g_nSnd[ eTeam ] ][ eTeam ], MAX_FILE_LENGTH - 1, sLeft );
  358. #else
  359. ArrayPushString( eTeam == CT ? g_lstSoundCT : g_lstSoundT, sLeft );
  360. #endif
  361.  
  362. ++g_nSnd[ eTeam ];
  363. }
  364. fclose( fp );
  365.  
  366. if( g_nSnd[ e_Team:T ] > 1 || g_nSnd[ e_Team:CT ] > 1 )
  367. {
  368. new iMax_t, iMax_ct;
  369. GetPrecacheValue( iMax_t, iMax_ct );
  370.  
  371. #if defined old_amxx
  372. UpdateArray( iMax_t, e_Team:T );
  373. UpdateArray( iMax_ct, e_Team:CT );
  374. #else
  375. p_DeleteRandomItem( iMax_t , e_Team:T , g_lstSoundT );
  376. p_DeleteRandomItem( iMax_ct, e_Team:CT, g_lstSoundCT );
  377. #endif
  378. }
  379.  
  380. log_amx( "---" );
  381.  
  382. #if defined _DEBUG
  383. log_amx( "[ Loading %d CTs Sounds ]", g_nSnd[ e_team:CT ] );
  384. #endif
  385. #if defined old_amxx
  386. PrecacheSounds( e_Team:CT );
  387. #else
  388. PrecacheSounds_n( g_lstSoundCT );
  389. #endif
  390.  
  391. #if defined _DEBUG
  392. log_amx( "[ Loading %d Ts Sounds ]", g_nSnd[ e_team:T ] );
  393. #endif
  394. #if defined old_amxx
  395. PrecacheSounds( e_Team:T );
  396. #else
  397. PrecacheSounds_n( g_lstSoundT );
  398. #endif
  399. }
  400.  
  401.  
  402. GetPrecacheValue( &iMax_t, &iMax_ct )
  403. {
  404. trim( g_sRp_value );
  405. new pos = contain( g_sRp_value, "-" );
  406.  
  407. if( pos > 0 )
  408. {
  409. iMax_ct = str_to_num( g_sRp_value[ pos + 1 ] )
  410. g_sRp_value[ pos ] = '^0';
  411. iMax_t = str_to_num( g_sRp_value );
  412. }
  413. else
  414. {
  415. iMax_t = str_to_num( g_sRp_value );
  416. iMax_ct = iMax_t;
  417. }
  418. }
  419.  
  420.  
  421. stock UpdateArray( iMax, iTeam )
  422. {
  423. new const iCnt_sound = g_nSnd[ iTeam ];
  424.  
  425. if( !iMax || iMax == iCnt_sound )
  426. return;
  427.  
  428. if( iMax >= iCnt_sound )
  429. iMax = iCnt_sound - 1;
  430.  
  431. static
  432. sTmp_sounds[ MAX_SOUNDS ][ e_Team ][ MAX_FILE_LENGTH ],
  433. iLast_number[ MAX_SOUNDS ];
  434.  
  435. new i, iRand;
  436. for( i = 0; i < iCnt_sound; i++ )
  437. {
  438. copy( sTmp_sounds[i][ iTeam ], MAX_FILE_LENGTH - 1, g_sTeam_sounds[i][ iTeam ] );
  439. g_sTeam_sounds[i][ iTeam ][0] = '^0';
  440. }
  441.  
  442. arrayset( iLast_number, 0, charsmax( iLast_number ) );
  443.  
  444. i = 0;
  445. while( i != iMax )
  446. {
  447. check:
  448. iRand = random( iCnt_sound );
  449.  
  450. if( iLast_number[ iRand ] )
  451. goto check;
  452.  
  453. copy( g_sTeam_sounds[i][ iTeam ], MAX_FILE_LENGTH - 1, sTmp_sounds[ iRand ][ iTeam ] );
  454. ++i;
  455.  
  456. iLast_number[ iRand ] = 1;
  457. }
  458.  
  459. g_nSnd[ iTeam ] = iMax;
  460. }
  461.  
  462.  
  463. stock p_DeleteRandomItem( iMax, iTeam, Array:sSound_a )
  464. {
  465. new const iCnt_sound = g_nSnd[ iTeam ];
  466.  
  467. if( !iMax || iMax == iCnt_sound )
  468. return;
  469.  
  470. if( iMax >= iCnt_sound )
  471. iMax = iCnt_sound - 1;
  472.  
  473. DeleteRandomItem( iCnt_sound - iMax, sSound_a );
  474. g_nSnd[ iTeam ] = iMax;
  475. }
  476.  
  477.  
  478. stock DeleteRandomItem( iRandom_n, Array:sSound_a )
  479. {
  480. new i;
  481.  
  482. while( i++ != iRandom_n )
  483. ArrayDeleteItem( sSound_a, random( ArraySize( sSound_a ) ) );
  484. }
  485.  
  486.  
  487. stock PrecacheSounds( iTeam )
  488. {
  489. for( new i; i < g_nSnd[ iTeam ]; i++ )
  490. {
  491. PrecacheFile( g_sTeam_sounds[i][ iTeam ] );
  492.  
  493. #if defined _DEBUG
  494. log_amx( " - %s", g_sTeam_sounds[i][ iTeam ] );
  495. #endif
  496. }
  497.  
  498. log_amx( "---" );
  499. }
  500.  
  501.  
  502. stock PrecacheSounds_n( Array:sSound_a )
  503. {
  504. static
  505. // - - - - - - - - - - - - - - - - - - -
  506. sFile[ MAX_FILE_LENGTH ],
  507. iFileLen = charsmax( sFile );
  508. // - - - - - - - - - - - - - - - - - - -
  509.  
  510. for( new i; i < ArraySize( sSound_a ); i++ )
  511. {
  512. ArrayGetString( sSound_a, i, sFile, iFileLen );
  513. PrecacheFile( sFile );
  514.  
  515. #if defined _DEBUG
  516. log_amx( " - %s", sFile );
  517. #endif
  518. }
  519.  
  520. log_amx( "---" );
  521. }
  522.  
  523.  
  524. PrecacheFile( const sound[] )
  525. {
  526. _is_wav( sound ) ?
  527.  
  528. precache_sound( sound[6] ) :
  529. precache_generic( sound );
  530. }
  531.  
  532.  
  533. ShowPrint( id, const sMsg[], { Float, Sql, Result, _ }:... )
  534. {
  535. static
  536. // - - - - - - - - -
  537. newMsg[191],
  538. message[191],
  539. // |
  540. tNewMsg;
  541. // - - - - - - - - -
  542.  
  543. tNewMsg = charsmax( newMsg );
  544. vformat( newMsg, tNewMsg, sMsg, 3 );
  545.  
  546. replace_all( newMsg, tNewMsg, "!t", "^3" );
  547. replace_all( newMsg, tNewMsg, "!g", "^4" );
  548. replace_all( newMsg, tNewMsg, "!n", "^1" );
  549.  
  550. formatex( message, charsmax( message ), "^4[ERS]^1 %s", newMsg );
  551.  
  552. emessage_begin( MSG_ONE, g_msgSayText, _, id );
  553. ewrite_byte( id );
  554. ewrite_string( message );
  555. emessage_end();
  556. }
  557.  
  558.  
  559. bool:CheckFile( const file[] )
  560. {
  561. new
  562. // - - - - - - - - - - - - - - - - -
  563. sBuffer[256],
  564. fp = fopen( file, "rt" );
  565. // - - - - - - - - - - - - - - - - -
  566.  
  567. if( !fp )
  568. return false;
  569.  
  570. while( !feof( fp ) )
  571. {
  572. fgets( fp, sBuffer, charsmax( sBuffer ) );
  573.  
  574. trim( sBuffer );
  575.  
  576. if( !sBuffer[0] || sBuffer[0] == ';' || ( sBuffer[0] == '/' && sBuffer[1] == '/' ) || sBuffer[0] != '"' )
  577. continue;
  578.  
  579. if( ( contain( sBuffer, ".mp3^"" ) != -1 || contain( sBuffer, ".wav^"" ) != -1 ) && ( contain( sBuffer, "^"T^"" ) != -1 || contain( sBuffer, "^"CT^"" ) != -1 ) )
  580. return true;
  581. }
  582. fclose( fp );
  583.  
  584. return false;
  585. }


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Alt End Round Sounds [Lang nélkül]
HozzászólásElküldve: 2015.01.23. 22:04 
Offline
Beavatott
Avatar

Csatlakozott: 2015.01.15. 22:08
Hozzászólások: 99
Megköszönt másnak: 1 alkalommal
Megköszönték neki: 15 alkalommal
SMA Forráskód: [ Mindet kijelol ]
  1. ShowPrint( id, "%L", id, "ERS_DISPLAY_ADS", g_CmdChat );


Talán nem
Tudod mi az a lang?
Mit írtál át egyébként :lol: :lol: :lol: Ha otthon leszek meg csinálom.

_________________
Kép
http://www.klanhaboru.hu/ Gyere játssz!!! világ 28-ban vagyok.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Alt End Round Sounds [Lang nélkül]
HozzászólásElküldve: 2015.01.23. 22:26 
Offline
Jómunkásember
Avatar

Csatlakozott: 2014.09.27. 19:51
Hozzászólások: 411
Megköszönt másnak: 89 alkalommal
Megköszönték neki: 14 alkalommal
SMA Forráskód: [ Mindet kijelol ]
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4.  
  5. new const
  6. // _________________________________________________
  7.  
  8. PLUGIN [] = "Alternative End Round Sounds",
  9. VERSION[] = "2.3b",
  10. AUTHOR [] = "Arkshine";
  11. // _________________________________________________
  12.  
  13.  
  14. #if AMXX_VERSION_NUM < 180
  15. #define old_amxx
  16. #endif
  17.  
  18.  
  19. /* ========================= [ "START" AERA FOR CHANGES ] ========================= */
  20.  
  21.  
  22. #define _DEBUG // Active debug
  23. #define MAX_FILE_LENGTH 196 // Max length for files + path.
  24.  
  25. #if defined old_amxx
  26. #define MAX_SOUNDS 25 // Max sounds per team
  27. #endif
  28.  
  29. new const
  30.  
  31. g_FileName[] = "roundsound", // Name of the main file if no files is found in 'g_FileFolder'.
  32. g_FileFolder[] = "round_sound", // Name of the directory in amxmodx/configs/ for per-map files.
  33. g_FilePrefix[] = "ini", // File extension used for the files.
  34. g_CmdChat[] = "/roundsound"; // Chat command for player.
  35.  
  36.  
  37. /* ========================= [ "END" AERA FOR CHANGES ] ========================= */
  38.  
  39.  
  40.  
  41. // - - - - - - - - - - - - - - - - - - - - - - -
  42.  
  43. #define MAX_PLAYERS 32
  44. #define TASKID_ADS 1333
  45. #define SIZE_FILE 0
  46. #define NULL -1
  47.  
  48. new
  49. bool:g_pHeardSound[ MAX_PLAYERS + 1 ],
  50.  
  51. #if !defined old_amxx
  52. Array:g_lstSoundCT,
  53. Array:g_lstSoundT,
  54. #endif
  55.  
  56. p_enabled,
  57. p_player_toggle,
  58. p_time_ads,
  59. p_random_precache,
  60.  
  61. g_sRp_value[12],
  62. g_msgSayText;
  63.  
  64.  
  65. enum _:e_Team
  66. {
  67. T = 0,
  68. CT,
  69. };
  70.  
  71. new g_nSnd[ e_Team ];
  72.  
  73. #if defined old_amxx
  74. new g_sTeam_sounds[ MAX_SOUNDS ][ e_Team ][ MAX_FILE_LENGTH ];
  75. #define charsmax(%1) sizeof( %1 ) - 1
  76. #endif
  77.  
  78. #define _is_wav(%1) equali( %1[strlen( %1 ) - 4 ], ".wav" )
  79.  
  80. // - - - - - - - - - - - - - - - - - - - - - - -
  81.  
  82.  
  83. public plugin_precache()
  84. {
  85. register_dictionary( "end_roundsound.txt" );
  86.  
  87. if( ( p_random_precache = get_cvar_pointer( "erc_random_precache" ) ) )
  88. get_pcvar_string( p_random_precache, g_sRp_value, charsmax( g_sRp_value ) );
  89.  
  90. if( !p_random_precache )
  91. return;
  92.  
  93. #if !defined old_amxx
  94. g_lstSoundCT = ArrayCreate( MAX_FILE_LENGTH );
  95. g_lstSoundT = ArrayCreate( MAX_FILE_LENGTH );
  96. #endif
  97.  
  98. loading_file();
  99. }
  100.  
  101.  
  102. public plugin_init()
  103. {
  104. register_plugin( PLUGIN, VERSION, AUTHOR );
  105. register_cvar( "ers_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY );
  106.  
  107. register_event( "SendAudio", "eT_win" , "a", "2&%!MRAD_terwin" );
  108. register_event( "SendAudio", "eCT_win", "a", "2&%!MRAD_ctwin" );
  109.  
  110. p_enabled = register_cvar( "ers_enabled" , "1" );
  111. p_player_toggle = register_cvar( "ers_player_toggle" , "1" );
  112. p_time_ads = register_cvar( "erc_time_ads" , "120" );
  113.  
  114. if( !p_random_precache )
  115. {
  116. register_cvar( "erc_random_precache", g_sRp_value );
  117. server_cmd( "restart" );
  118. }
  119.  
  120. register_clcmd( "say" , "cmd_Say" );
  121. register_clcmd( "say_team" , "cmd_Say" );
  122.  
  123. }
  124.  
  125.  
  126. public client_authorized( id )
  127. g_pHeardSound[id] = true;
  128.  
  129.  
  130. public client_disconnect( id )
  131. {
  132. g_pHeardSound[id] = true;
  133. remove_task( id + TASKID_ADS );
  134. }
  135.  
  136.  
  137. public client_putinserver( id )
  138. {
  139. new Float:time = get_pcvar_float( p_time_ads );
  140.  
  141. if( !time )
  142. return;
  143.  
  144. remove_task( id + TASKID_ADS );
  145. set_task( time, "show_ads", id + TASKID_ADS, _, _, "b" );
  146. }
  147.  
  148.  
  149. public show_ads( taskid )
  150. {
  151. new id = taskid - TASKID_ADS;
  152. }
  153.  
  154.  
  155. public cmd_Say( id )
  156. {
  157. if( !get_pcvar_num( p_enabled ) )
  158. return PLUGIN_CONTINUE;
  159.  
  160. static sMsg[64];
  161. read_argv( 1, sMsg, charsmax( sMsg ) );
  162.  
  163. if( equali( sMsg, g_CmdChat ) )
  164. {
  165. if( !get_pcvar_num( p_player_toggle ) )
  166. {
  167. return PLUGIN_HANDLED;
  168. }
  169.  
  170. g_pHeardSound[id] = g_pHeardSound[id] ? false : true;
  171.  
  172. return PLUGIN_HANDLED;
  173. }
  174.  
  175. return PLUGIN_CONTINUE;
  176. }
  177.  
  178.  
  179. public eT_win()
  180. {
  181. if( !g_nSnd[ e_Team:T ] )
  182. return;
  183.  
  184. play_sound( e_Team:T );
  185. }
  186.  
  187.  
  188. public eCT_win()
  189. {
  190. if( !g_nSnd[ e_Team:CT ] )
  191. return;
  192.  
  193. play_sound( e_Team:CT );
  194. }
  195.  
  196.  
  197. play_sound( iTeam )
  198. {
  199. static
  200. // - - - - - - - - - - - - - - - -
  201. sCurSnd[ MAX_FILE_LENGTH ];
  202. // - - - - - - - - - - - - - - - -
  203.  
  204. new iRand;
  205.  
  206. if( g_nSnd[ iTeam ] > 1 )
  207. iRand = random( g_nSnd[ iTeam ] );
  208.  
  209. #if defined old_amxx
  210. copy( sCurSnd, MAX_FILE_LENGTH - 1, g_sTeam_sounds[ iRand ][ iTeam ] );
  211. #else
  212. ArrayGetString( iTeam == CT ? g_lstSoundCT : g_lstSoundT, iRand, sCurSnd, MAX_FILE_LENGTH - 1 );
  213. #endif
  214.  
  215. _is_wav( sCurSnd ) ?
  216.  
  217. format( sCurSnd, MAX_FILE_LENGTH - 1, "spk %s", sCurSnd[6] ) :
  218. format( sCurSnd, MAX_FILE_LENGTH - 1, "mp3 play %s", sCurSnd );
  219.  
  220. if( get_pcvar_num( p_player_toggle ) )
  221. {
  222. static
  223. // - - - - - - - - - - -
  224. iPlayers[32],
  225. iNum, pid;
  226. // - - - - - - - - - - -
  227.  
  228. get_players( iPlayers, iNum, "c" );
  229.  
  230. for( new i; i < iNum; i++ )
  231. {
  232. pid = iPlayers[i];
  233.  
  234. if( !g_pHeardSound[pid] || is_user_bot( pid ) )
  235. continue;
  236.  
  237. client_cmd( pid, "%s", sCurSnd );
  238. }
  239. }
  240. else
  241. client_cmd( 0, "%s", sCurSnd );
  242. }
  243.  
  244.  
  245. get_prefix( sMap[], iLen_map, sMapType[], iLen_type )
  246. {
  247. new
  248. // - - - - - - - - -
  249. sRest[32];
  250. // - - - - - - - - -
  251.  
  252. get_mapname( sMap, iLen_map );
  253. strtok( sMap, sMapType, iLen_type, sRest, charsmax( sRest ), '_', 1 );
  254. }
  255.  
  256.  
  257. loading_file()
  258. {
  259. static
  260. // - - - - - - - - - - - - - - - - -
  261. sPath[ MAX_FILE_LENGTH ],
  262. // |
  263. sConfigsDir[64],
  264. sPrefix[6],
  265. sMap[32];
  266. // - - - - - - - - - - - - - - - - -
  267.  
  268. get_prefix( sMap, charsmax( sMap ), sPrefix, charsmax( sPrefix ) );
  269. get_configsdir( sConfigsDir, charsmax( sConfigsDir ) );
  270.  
  271.  
  272. new bool:bFound;
  273.  
  274. for( new i = 1; i <= 3; i++ )
  275. {
  276. switch( i )
  277. {
  278. case 1 : formatex( sPath, charsmax( sPath ), "%s/%s/prefix-%s.%s", sConfigsDir, g_FileFolder, sPrefix, g_FilePrefix );
  279. case 2 : formatex( sPath, charsmax( sPath ), "%s/%s/%s.%s", sConfigsDir, g_FileFolder, sMap, g_FilePrefix );
  280. case 3 : formatex( sPath, charsmax( sPath ), "%s/%s.%s", sConfigsDir, g_FileName, g_FilePrefix );
  281.  
  282. default : break;
  283. }
  284.  
  285. if( !CheckFile( sPath ) )
  286. continue;
  287.  
  288. bFound = true;
  289. break;
  290. }
  291.  
  292. log_amx( "---" );
  293.  
  294.  
  295. load_sound( sPath );
  296. }
  297.  
  298.  
  299. load_sound( const file[] )
  300. {
  301. new
  302. // - - - - - - - - - - - - - - -
  303. sBuffer[256],
  304. // |
  305. sLeft[ MAX_FILE_LENGTH ],
  306. sRight[4],
  307. sExt[6],
  308. // |
  309. eTeam;
  310. // - - - - - - - - - - - - - - -
  311.  
  312. new fp = fopen( file, "rt" );
  313.  
  314. while( !feof( fp ) )
  315. {
  316. fgets( fp, sBuffer, charsmax( sBuffer ) );
  317.  
  318. trim( sBuffer );
  319.  
  320. if( !sBuffer[0] || sBuffer[0] == ';' || ( sBuffer[0] == '/' && sBuffer[1] == '/' ) )
  321. continue;
  322.  
  323. if( sBuffer[0] != '"' || strlen( sBuffer ) < 11 )
  324. continue;
  325.  
  326. parse( sBuffer, sLeft, charsmax( sLeft ), sRight, charsmax( sRight ) );
  327. formatex( sExt, charsmax( sExt ), sLeft[ strlen( sLeft ) - 4 ] );
  328.  
  329. if( equali( sExt, ".mp3" ) == -1 || equali( sExt, ".wav" ) == -1 )
  330. {
  331. continue;
  332. }
  333.  
  334. if( !file_exists( sLeft ) )
  335. {
  336. continue;
  337. }
  338.  
  339. eTeam = NULL;
  340.  
  341. if( equali( sRight, "CT" ) )
  342. eTeam = CT;
  343.  
  344. else if( equali( sRight, "T" ) )
  345. eTeam = T;
  346.  
  347. if( eTeam == NULL )
  348. {
  349. continue;
  350. }
  351.  
  352. #if defined old_amxx
  353. copy( g_sTeam_sounds[ g_nSnd[ eTeam ] ][ eTeam ], MAX_FILE_LENGTH - 1, sLeft );
  354. #else
  355. ArrayPushString( eTeam == CT ? g_lstSoundCT : g_lstSoundT, sLeft );
  356. #endif
  357.  
  358. ++g_nSnd[ eTeam ];
  359. }
  360. fclose( fp );
  361.  
  362. if( g_nSnd[ e_Team:T ] > 1 || g_nSnd[ e_Team:CT ] > 1 )
  363. {
  364. new iMax_t, iMax_ct;
  365. GetPrecacheValue( iMax_t, iMax_ct );
  366.  
  367. #if defined old_amxx
  368. UpdateArray( iMax_t, e_Team:T );
  369. UpdateArray( iMax_ct, e_Team:CT );
  370. #else
  371. p_DeleteRandomItem( iMax_t , e_Team:T , g_lstSoundT );
  372. p_DeleteRandomItem( iMax_ct, e_Team:CT, g_lstSoundCT );
  373. #endif
  374. }
  375.  
  376. log_amx( "---" );
  377.  
  378. #if defined _DEBUG
  379. log_amx( "[ Loading %d CTs Sounds ]", g_nSnd[ e_team:CT ] );
  380. #endif
  381. #if defined old_amxx
  382. PrecacheSounds( e_Team:CT );
  383. #else
  384. PrecacheSounds_n( g_lstSoundCT );
  385. #endif
  386.  
  387. #if defined _DEBUG
  388. log_amx( "[ Loading %d Ts Sounds ]", g_nSnd[ e_team:T ] );
  389. #endif
  390. #if defined old_amxx
  391. PrecacheSounds( e_Team:T );
  392. #else
  393. PrecacheSounds_n( g_lstSoundT );
  394. #endif
  395. }
  396.  
  397.  
  398. GetPrecacheValue( &iMax_t, &iMax_ct )
  399. {
  400. trim( g_sRp_value );
  401. new pos = contain( g_sRp_value, "-" );
  402.  
  403. if( pos > 0 )
  404. {
  405. iMax_ct = str_to_num( g_sRp_value[ pos + 1 ] )
  406. g_sRp_value[ pos ] = '^0';
  407. iMax_t = str_to_num( g_sRp_value );
  408. }
  409. else
  410. {
  411. iMax_t = str_to_num( g_sRp_value );
  412. iMax_ct = iMax_t;
  413. }
  414. }
  415.  
  416.  
  417. stock UpdateArray( iMax, iTeam )
  418. {
  419. new const iCnt_sound = g_nSnd[ iTeam ];
  420.  
  421. if( !iMax || iMax == iCnt_sound )
  422. return;
  423.  
  424. if( iMax >= iCnt_sound )
  425. iMax = iCnt_sound - 1;
  426.  
  427. static
  428. sTmp_sounds[ MAX_SOUNDS ][ e_Team ][ MAX_FILE_LENGTH ],
  429. iLast_number[ MAX_SOUNDS ];
  430.  
  431. new i, iRand;
  432. for( i = 0; i < iCnt_sound; i++ )
  433. {
  434. copy( sTmp_sounds[i][ iTeam ], MAX_FILE_LENGTH - 1, g_sTeam_sounds[i][ iTeam ] );
  435. g_sTeam_sounds[i][ iTeam ][0] = '^0';
  436. }
  437.  
  438. arrayset( iLast_number, 0, charsmax( iLast_number ) );
  439.  
  440. i = 0;
  441. while( i != iMax )
  442. {
  443. check:
  444. iRand = random( iCnt_sound );
  445.  
  446. if( iLast_number[ iRand ] )
  447. goto check;
  448.  
  449. copy( g_sTeam_sounds[i][ iTeam ], MAX_FILE_LENGTH - 1, sTmp_sounds[ iRand ][ iTeam ] );
  450. ++i;
  451.  
  452. iLast_number[ iRand ] = 1;
  453. }
  454.  
  455. g_nSnd[ iTeam ] = iMax;
  456. }
  457.  
  458.  
  459. stock p_DeleteRandomItem( iMax, iTeam, Array:sSound_a )
  460. {
  461. new const iCnt_sound = g_nSnd[ iTeam ];
  462.  
  463. if( !iMax || iMax == iCnt_sound )
  464. return;
  465.  
  466. if( iMax >= iCnt_sound )
  467. iMax = iCnt_sound - 1;
  468.  
  469. DeleteRandomItem( iCnt_sound - iMax, sSound_a );
  470. g_nSnd[ iTeam ] = iMax;
  471. }
  472.  
  473.  
  474. stock DeleteRandomItem( iRandom_n, Array:sSound_a )
  475. {
  476. new i;
  477.  
  478. while( i++ != iRandom_n )
  479. ArrayDeleteItem( sSound_a, random( ArraySize( sSound_a ) ) );
  480. }
  481.  
  482.  
  483. stock PrecacheSounds( iTeam )
  484. {
  485. for( new i; i < g_nSnd[ iTeam ]; i++ )
  486. {
  487. PrecacheFile( g_sTeam_sounds[i][ iTeam ] );
  488.  
  489. #if defined _DEBUG
  490. log_amx( " - %s", g_sTeam_sounds[i][ iTeam ] );
  491. #endif
  492. }
  493.  
  494. log_amx( "---" );
  495. }
  496.  
  497.  
  498. stock PrecacheSounds_n( Array:sSound_a )
  499. {
  500. static
  501. // - - - - - - - - - - - - - - - - - - -
  502. sFile[ MAX_FILE_LENGTH ],
  503. iFileLen = charsmax( sFile );
  504. // - - - - - - - - - - - - - - - - - - -
  505.  
  506. for( new i; i < ArraySize( sSound_a ); i++ )
  507. {
  508. ArrayGetString( sSound_a, i, sFile, iFileLen );
  509. PrecacheFile( sFile );
  510.  
  511. #if defined _DEBUG
  512. log_amx( " - %s", sFile );
  513. #endif
  514. }
  515.  
  516. log_amx( "---" );
  517. }
  518.  
  519.  
  520. PrecacheFile( const sound[] )
  521. {
  522. _is_wav( sound ) ?
  523.  
  524. precache_sound( sound[6] ) :
  525. precache_generic( sound );
  526. }
  527.  
  528.  
  529. ShowPrint( id, const sMsg[], { Float, Sql, Result, _ }:... )
  530. {
  531. static
  532. // - - - - - - - - -
  533. newMsg[191],
  534. message[191],
  535. // |
  536. tNewMsg;
  537. // - - - - - - - - -
  538.  
  539. tNewMsg = charsmax( newMsg );
  540. vformat( newMsg, tNewMsg, sMsg, 3 );
  541.  
  542. replace_all( newMsg, tNewMsg, "!t", "^3" );
  543. replace_all( newMsg, tNewMsg, "!g", "^4" );
  544. replace_all( newMsg, tNewMsg, "!n", "^1" );
  545.  
  546. formatex( message, charsmax( message ), "^4[ERS]^1 %s", newMsg );
  547.  
  548. emessage_begin( MSG_ONE, g_msgSayText, _, id );
  549. ewrite_byte( id );
  550. ewrite_string( message );
  551. emessage_end();
  552. }
  553.  
  554.  
  555. bool:CheckFile( const file[] )
  556. {
  557. new
  558. // - - - - - - - - - - - - - - - - -
  559. sBuffer[256],
  560. fp = fopen( file, "rt" );
  561. // - - - - - - - - - - - - - - - - -
  562.  
  563. if( !fp )
  564. return false;
  565.  
  566. while( !feof( fp ) )
  567. {
  568. fgets( fp, sBuffer, charsmax( sBuffer ) );
  569.  
  570. trim( sBuffer );
  571.  
  572. if( !sBuffer[0] || sBuffer[0] == ';' || ( sBuffer[0] == '/' && sBuffer[1] == '/' ) || sBuffer[0] != '"' )
  573. continue;
  574.  
  575. if( ( contain( sBuffer, ".mp3^"" ) != -1 || contain( sBuffer, ".wav^"" ) != -1 ) && ( contain( sBuffer, "^"T^"" ) != -1 || contain( sBuffer, "^"CT^"" ) != -1 ) )
  576. return true;
  577. }
  578. fclose( fp );
  579.  
  580. return false;
  581. }


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Alt End Round Sounds [Lang nélkül]
HozzászólásElküldve: 2015.01.23. 22:27 
Offline
Beavatott
Avatar

Csatlakozott: 2015.01.15. 22:08
Hozzászólások: 99
Megköszönt másnak: 1 alkalommal
Megköszönték neki: 15 alkalommal
Szerintem hagyd ezt!

SMA Forráskód: [ Mindet kijelol ]
  1. ShowPrint( id, "%L", id, "ERS_DISPLAY_ADS", g_CmdChat );

Nem is azt csinálod amit kért mondtam haza érek és meg csinálom :)

_________________
Kép
http://www.klanhaboru.hu/ Gyere játssz!!! világ 28-ban vagyok.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Alt End Round Sounds [Lang nélkül]
HozzászólásElküldve: 2015.01.23. 22:54 
Offline
Felfüggesztve
Avatar

Csatlakozott: 2014.12.05. 20:46
Hozzászólások: 177
Megköszönt másnak: 3 alkalommal
Megköszönték neki: 23 alkalommal
PiStA99: Nem rosszindulatból, tudom hogy segíteni szeretnél, amit igazán köszönök, de PiStA99 tényleg hagy, mert nem jó.
Attól hogy törlöd a lang sort, még hibát fog írni. Ahol beolvassa a lang fájlba beleírt cuccost, oda kellene egy print_chat, és ennyi.

Illetve ha egy plugin nem használ langot, akkor nem értem minek akarod kiolvasni?
SMA Forráskód: [ Mindet kijelol ]
  1. register_dictionary( "end_roundsound.txt" );

________________________________________________________________________________________________________________
Atom: Köszönöm előre is. :)


Atom írta:

Szerintem hagyd ezt!

SMA Forráskód: [ Mindet kijelol ]
  1. ShowPrint( id, "%L", id, "ERS_DISPLAY_ADS", g_CmdChat );

Nem is azt csinálod amit kért mondtam haza érek és meg csinálom :)

_________________
Kép
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Alt End Round Sounds [Lang nélkül]
HozzászólásElküldve: 2015.01.23. 23:20 
Offline
Jómunkásember
Avatar

Csatlakozott: 2014.09.27. 19:51
Hozzászólások: 411
Megköszönt másnak: 89 alkalommal
Megköszönték neki: 14 alkalommal
Csak segiteni próbálok Bocsi


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Alt End Round Sounds [Lang nélkül]
HozzászólásElküldve: 2015.01.24. 07:16 
Offline
Felfüggesztve
Avatar

Csatlakozott: 2014.12.05. 20:46
Hozzászólások: 177
Megköszönt másnak: 3 alkalommal
Megköszönték neki: 23 alkalommal
PiStA99 írta:
Csak segiteni próbálok Bocsi


Mondtam, ezzel semmi baj nincs, sőt, igazán köszönöm, de amiket posztoltál, azok nem jók. :S

_________________
Kép
Kép


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Alt End Round Sounds [Lang nélkül]
HozzászólásElküldve: 2015.01.24. 10:41 
Offline
Jómunkásember

Csatlakozott: 2012.01.29. 12:48
Hozzászólások: 408
Megköszönt másnak: 15 alkalommal
Megköszönték neki: 126 alkalommal
SMA Forráskód: [ Mindet kijelol ]
  1.  
  2.  
  3. /* - - - - - - - - - - -
  4.  
  5.   AMX Mod X script.
  6.   Copyright (C) 2007 - Arkshine
  7.  
  8.   Plugin : 'Alternative End Round Sounds'
  9.   Version : v2.3b
  10.  
  11.   Original idea and plugin by PaintLancer.
  12.  
  13.   This program is free software; you can redistribute it and/or modify it
  14.   under the terms of the GNU General Public License as published by the
  15.   Free Software Foundation; either version 2 of the License, or (at
  16.   your option) any later version.
  17.  
  18.   This program is distributed in the hope that it will be useful, but
  19.   WITHOUT ANY WARRANTY; without even the implied warranty of
  20.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21.   General Public License for more details.
  22.  
  23.   You should have received a copy of the GNU General Public License
  24.   along with this program; if not, write to the Free Software Foundation,
  25.   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26.  
  27.   In addition, as a special exception, the author gives permission to
  28.   link the code of this program with the Half-Life Game Engine ("HL
  29.   Engine") and Modified Game Libraries ("MODs") developed by Valve,
  30.   L.L.C ("Valve"). You must obey the GNU General Public License in all
  31.   respects for all of the code used other than the HL Engine and MODs
  32.   from Valve. If you modify this file, you may extend this exception
  33.   to your version of the file, but you are not obligated to do so. If
  34.   you do not wish to do so, delete this exception statement from your
  35.   version.
  36.  
  37.   ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
  38.  
  39.   Description :
  40.   - - - - - - -
  41.   Plays random music at the end of a round according to who wins,
  42.   instead of just "Terrorists Win" or "Counter-Terrorists Win".
  43.  
  44.  
  45.   Features :
  46.   - - - - - -
  47.   * Support for mp3 and wav files
  48.   * Using a file for the sounds
  49.   * Per-map config files supported
  50.   * Per-map prefix config files supported
  51.   * Sounds can be toggle on/off by players
  52.   * Ability to choice x sounds to be precache per map
  53.   * Multilingual support
  54.  
  55.  
  56.   Requirements :
  57.   - - - - - - - -
  58.   * CS 1.6 / CZ
  59.   * AMX/X 1.7x or higher
  60.  
  61.  
  62.   Cvars :
  63.   - - - -
  64.   * ers_enabled <iNum
  65.  
  66.   <0|1> Disable/Enable this plugin.
  67.   (default: 1)
  68.  
  69.  
  70.   * ers_player_toggle <iNum>
  71.  
  72.   <0|1> Disable/Enable the client command /roundsound
  73.   (default: 1)
  74.  
  75.  
  76.   * erc_time_ads <iTime>
  77.  
  78.   Times in seconds between each ads messages. 0 disable ads.
  79.   (default: 120)
  80.  
  81.  
  82.   * erc_random_precache <iMaxTeam or iMax_T-iMax_CT>
  83.  
  84.   Specify how many sounds by team you want to precache randomly among all sounds.
  85.   This means that x sounds will be choosen randomly among all sounds of each team so to be precache at each map. ( 0 = disable feature )
  86.  
  87.   e.g : erc_random_precache "2" : 2 sounds will be choosen among all CTs sounds and all Ts sounds
  88.   erc_random_precache "2-3" : 2 Ts sounds will be choosen randomly among all Ts sounds.
  89.   3 CT sound will be choosen randomly among all CTs sounds.
  90.   /!\ Don't forget to insert '-' .
  91.  
  92.   /!\ Map change on cvar change required !
  93.  
  94.  
  95.   Client command :
  96.   - - - - - - - -
  97.   * say /roundsound : Give to players the ability to turn on/off the end round sounds
  98.  
  99.  
  100.   Changelog :
  101.   - - - - - -
  102.  
  103.   -> Arksine :
  104.  
  105.   v3.0 - [ 2007-xx-xx ] ( Major update )
  106.  
  107.   - Soon. A lot of changes/new features. Huge update. <!-- s;) --><img src=\"{SMILIES_PATH}/icon_e_wink.gif\" alt=\";)\" title=\"kacsintás\" /><!-- s;) -->
  108.  
  109.   v2.3b - [ 2007-11-22 ]
  110.  
  111.   (!) Fixed a compatibility bug from 2.3a version.
  112.  
  113.   v2.3a - [ 2007-11-19 ]
  114.  
  115.   (+) Added compatibility for Amxx 1.7x.
  116.   (!) Now 'erc_random_precache' cvar is set to 0 by default.
  117.   (!) Fixed. At the first start of server, value from 'erc_random_precache' cvar from a config file was not read.
  118.   (!) Some others minors changes.
  119.  
  120.   v2.3 - [ 2007-10-29 ]
  121.  
  122.   (+) Added 'erc_random_precache' cvar : Specify how many sounds per team you want to precache randomly among all sounds.
  123.   This means that x sounds will be choosen randomly among all sounds of each team so to be precache at each map. ( request by Arion )
  124.   (!) Debug mode is enabled by default now.
  125.   (-) Removed 3 keys languages. No more need.( ERS_LOG_TOTAL_SOUND_LOADED, ERS_LOG_DEBUG_T, ERS_LOG_DEBUG_CT )
  126.  
  127.   v2.2b - [ 2007-10-28 ]
  128.  
  129.   (!) Removed a check. Since trim() is used :
  130.   Now no need to check space, new line, tabs, carriage returns, etc..
  131.  
  132.   v2.2a - [ 2007-10-28 ]
  133.  
  134.   (!) Changed the method of checking empty file. Now it's more efficient.
  135.   (!) Added another check to ignore texts which are no comments.
  136.   (!) Fixed a typo ( key language ).
  137.  
  138.   v2.2 - [ 2007-10-27 ]
  139.  
  140.   (+) Added a check to prevent to get a warning when a team has no sound.
  141.   (+) Added a check to prevent to not load empty file.
  142.   (+) Added support for coding-style '//' comments.
  143.   (!) No longer has a predefined max sounds limit. ( using dynamic array from amxx 1.8.0 )
  144.   (!) Minors optimizations.
  145.   (-) Removed useless code.
  146.  
  147.   v2.1a - [ 2007-07-13 ]
  148.  
  149.   (!) Fixed a bug with ML system.
  150.   (!) Fixed a stupid glitch with formatex().
  151.  
  152.   v2.1 - [ 2007-07-06 ]
  153.  
  154.   (!) Optimize a little.
  155.   (!) Rewritted loading_file() function.
  156.   (+) Added ML system & some texts.
  157.   (+) Added Color in text. ( !g = green ; !t = team color; !n = yellow (normal) )
  158.   (+) Added #_DEBUG.
  159.   (+) Added chat command : toggle on/off end round sounds.
  160.   (+) Added "ers_enabled" cvar : enable/disable plugin
  161.   (+) Added "ers_player_toggle" cvar : enable/disabled command chat for players
  162.   (+) Added ads message for chat command
  163.   (+) Added "erc_time_ads" cvar : control amount of times between 2 messages.
  164.  
  165.   v2.0b - [ 2007-07-04 ]
  166.  
  167.   (!) No features added. Sma reorganized a little and more.
  168.  
  169.   v2.0a - [ 2007-06-26 ]
  170.  
  171.   (!) Fixed. Bug under linux. Some blank lines weren't ignored. (thanks Deejay & NiLuje)
  172.  
  173.   v2.0 - [ 2007-06-26 ]
  174.  
  175.   (!) Totaly rewritted
  176.   (+) Added support for mp3 files.
  177.   (+) Added support per file. No more to edit .sma file to add sounds.
  178.   (+) Added support per-map file.
  179.   (+) Added support per-map prefix file.
  180.  
  181.   -> Paintlancer :
  182.  
  183.   v1.0 : [ 2004-10-14 ]
  184.   First release by Paintlancer.
  185.  
  186.   Credits:
  187.   - - - - - - -
  188.   * PaintLancer : Original idea and plugin.
  189.   * Avalanche : Inspired color chat function from gungame plugin.
  190.   * Arion : Random precache idea.
  191.  
  192.   * Languages translation :
  193.   - [fr] : Arkshine
  194.   - [de] : Mordekay
  195.   - [es] : Darkless
  196.  
  197.  
  198.   - - - - - - - - - - - */
  199.  
  200. #include <amxmodx>
  201. #include <amxmisc>
  202.  
  203.  
  204. new const
  205. // _________________________________________________
  206.  
  207. PLUGIN [] = "Alternative End Round Sounds",
  208. VERSION[] = "2.3b",
  209. AUTHOR [] = "Arkshine";
  210. // _________________________________________________
  211.  
  212.  
  213. #if AMXX_VERSION_NUM < 180
  214. #define old_amxx
  215. #endif
  216.  
  217.  
  218. /* ========================= [ "START" AERA FOR CHANGES ] ========================= */
  219.  
  220.  
  221. #define _DEBUG // Active debug
  222. #define MAX_FILE_LENGTH 196 // Max length for files + path.
  223.  
  224. #if defined old_amxx
  225. #define MAX_SOUNDS 25 // Max sounds per team
  226. #endif
  227.  
  228. new const
  229.  
  230. g_FileName[] = "roundsound", // Name of the main file if no files is found in 'g_FileFolder'.
  231. g_FileFolder[] = "round_sound", // Name of the directory in amxmodx/configs/ for per-map files.
  232. g_FilePrefix[] = "ini", // File extension used for the files.
  233. g_CmdChat[] = "/roundsound"; // Chat command for player.
  234.  
  235.  
  236. /* ========================= [ "END" AERA FOR CHANGES ] ========================= */
  237.  
  238.  
  239.  
  240. // - - - - - - - - - - - - - - - - - - - - - - -
  241.  
  242. #define MAX_PLAYERS 32
  243. #define TASKID_ADS 1333
  244. #define SIZE_FILE 0
  245. #define NULL -1
  246.  
  247. new
  248. bool:g_pHeardSound[ MAX_PLAYERS + 1 ],
  249.  
  250. #if !defined old_amxx
  251. Array:g_lstSoundCT,
  252. Array:g_lstSoundT,
  253. #endif
  254.  
  255. p_enabled,
  256. p_player_toggle,
  257. p_time_ads,
  258. p_random_precache,
  259.  
  260. g_sRp_value[12],
  261. g_msgSayText;
  262.  
  263.  
  264. enum _:e_Team
  265. {
  266. T = 0,
  267. CT,
  268. };
  269.  
  270. new g_nSnd[ e_Team ];
  271.  
  272. #if defined old_amxx
  273. new g_sTeam_sounds[ MAX_SOUNDS ][ e_Team ][ MAX_FILE_LENGTH ];
  274. #define charsmax(%1) sizeof( %1 ) - 1
  275. #endif
  276.  
  277. #define _is_wav(%1) equali( %1[strlen( %1 ) - 4 ], ".wav" )
  278.  
  279. // - - - - - - - - - - - - - - - - - - - - - - -
  280.  
  281.  
  282. public plugin_precache()
  283. {
  284.  
  285. if( ( p_random_precache = get_cvar_pointer( "erc_random_precache" ) ) )
  286. get_pcvar_string( p_random_precache, g_sRp_value, charsmax( g_sRp_value ) );
  287.  
  288. if( !p_random_precache )
  289. return;
  290.  
  291. #if !defined old_amxx
  292. g_lstSoundCT = ArrayCreate( MAX_FILE_LENGTH );
  293. g_lstSoundT = ArrayCreate( MAX_FILE_LENGTH );
  294. #endif
  295.  
  296. loading_file();
  297. }
  298.  
  299.  
  300. public plugin_init()
  301. {
  302. register_plugin( PLUGIN, VERSION, AUTHOR );
  303. register_cvar( "ers_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY );
  304.  
  305. register_event( "SendAudio", "eT_win" , "a", "2&%!MRAD_terwin" );
  306. register_event( "SendAudio", "eCT_win", "a", "2&%!MRAD_ctwin" );
  307.  
  308. p_enabled = register_cvar( "ers_enabled" , "1" );
  309. p_player_toggle = register_cvar( "ers_player_toggle" , "1" );
  310. p_time_ads = register_cvar( "erc_time_ads" , "120" );
  311.  
  312. if( !p_random_precache )
  313. {
  314. register_cvar( "erc_random_precache", g_sRp_value );
  315. server_cmd( "restart" );
  316. }
  317.  
  318. register_clcmd( "say" , "cmd_Say" );
  319. register_clcmd( "say_team" , "cmd_Say" );
  320.  
  321. g_msgSayText = get_user_msgid( "SayText" );
  322. }
  323.  
  324.  
  325. public client_authorized( id )
  326. g_pHeardSound[id] = true;
  327.  
  328.  
  329. public client_disconnect( id )
  330. {
  331. g_pHeardSound[id] = true;
  332. remove_task( id + TASKID_ADS );
  333. }
  334.  
  335.  
  336. public client_putinserver( id )
  337. {
  338. new Float:time = get_pcvar_float( p_time_ads );
  339.  
  340. if( !time )
  341. return;
  342.  
  343. remove_task( id + TASKID_ADS );
  344. set_task( time, "show_ads", id + TASKID_ADS, _, _, "b" );
  345. }
  346.  
  347.  
  348. public show_ads( taskid )
  349. {
  350. new id = taskid - TASKID_ADS;
  351. ShowPrint( id, "Írd be hogy !t%s!n hogy ki/be tudd kapcsolni a körvégi zenéket.", g_CmdChat );
  352. }
  353.  
  354.  
  355. public cmd_Say( id )
  356. {
  357. if( !get_pcvar_num( p_enabled ) )
  358. return PLUGIN_CONTINUE;
  359.  
  360. static sMsg[64];
  361. read_argv( 1, sMsg, charsmax( sMsg ) );
  362.  
  363. if( equali( sMsg, g_CmdChat ) )
  364. {
  365. if( !get_pcvar_num( p_player_toggle ) )
  366. {
  367. ShowPrint( id, "Ezt a parancsot !tkikapcsolta!n egy admin!" );
  368. return PLUGIN_HANDLED;
  369. }
  370.  
  371. g_pHeardSound[id] = g_pHeardSound[id] ? false : true;
  372. ShowPrint( id, g_pHeardSound[id] ? "Hangok !tBekapcsolva!n! Te újra hallod a körvégi hangokat." : "Hangok !tKikapcsolva!n! Te nem hallod többet a körvégi hangokat." );
  373.  
  374. return PLUGIN_HANDLED;
  375. }
  376.  
  377. return PLUGIN_CONTINUE;
  378. }
  379.  
  380.  
  381. public eT_win()
  382. {
  383. if( !g_nSnd[ e_Team:T ] )
  384. return;
  385.  
  386. play_sound( e_Team:T );
  387. }
  388.  
  389.  
  390. public eCT_win()
  391. {
  392. if( !g_nSnd[ e_Team:CT ] )
  393. return;
  394.  
  395. play_sound( e_Team:CT );
  396. }
  397.  
  398.  
  399. play_sound( iTeam )
  400. {
  401. static
  402. // - - - - - - - - - - - - - - - -
  403. sCurSnd[ MAX_FILE_LENGTH ];
  404. // - - - - - - - - - - - - - - - -
  405.  
  406. new iRand;
  407.  
  408. if( g_nSnd[ iTeam ] > 1 )
  409. iRand = random( g_nSnd[ iTeam ] );
  410.  
  411. #if defined old_amxx
  412. copy( sCurSnd, MAX_FILE_LENGTH - 1, g_sTeam_sounds[ iRand ][ iTeam ] );
  413. #else
  414. ArrayGetString( iTeam == CT ? g_lstSoundCT : g_lstSoundT, iRand, sCurSnd, MAX_FILE_LENGTH - 1 );
  415. #endif
  416.  
  417. _is_wav( sCurSnd ) ?
  418.  
  419. format( sCurSnd, MAX_FILE_LENGTH - 1, "spk %s", sCurSnd[6] ) :
  420. format( sCurSnd, MAX_FILE_LENGTH - 1, "mp3 play %s", sCurSnd );
  421.  
  422. if( get_pcvar_num( p_player_toggle ) )
  423. {
  424. static
  425. // - - - - - - - - - - -
  426. iPlayers[32],
  427. iNum, pid;
  428. // - - - - - - - - - - -
  429.  
  430. get_players( iPlayers, iNum, "c" );
  431.  
  432. for( new i; i < iNum; i++ )
  433. {
  434. pid = iPlayers[i];
  435.  
  436. if( !g_pHeardSound[pid] || is_user_bot( pid ) )
  437. continue;
  438.  
  439. client_cmd( pid, "%s", sCurSnd );
  440. }
  441. }
  442. else
  443. client_cmd( 0, "%s", sCurSnd );
  444. }
  445.  
  446.  
  447. get_prefix( sMap[], iLen_map, sMapType[], iLen_type )
  448. {
  449. new
  450. // - - - - - - - - -
  451. sRest[32];
  452. // - - - - - - - - -
  453.  
  454. get_mapname( sMap, iLen_map );
  455. strtok( sMap, sMapType, iLen_type, sRest, charsmax( sRest ), '_', 1 );
  456. }
  457.  
  458.  
  459. loading_file()
  460. {
  461. static
  462. // - - - - - - - - - - - - - - - - -
  463. sPath[ MAX_FILE_LENGTH ],
  464. // |
  465. sConfigsDir[64],
  466. sPrefix[6],
  467. sMap[32];
  468. // - - - - - - - - - - - - - - - - -
  469.  
  470. get_prefix( sMap, charsmax( sMap ), sPrefix, charsmax( sPrefix ) );
  471. get_configsdir( sConfigsDir, charsmax( sConfigsDir ) );
  472.  
  473.  
  474. new bool:bFound;
  475.  
  476. for( new i = 1; i <= 3; i++ )
  477. {
  478. switch( i )
  479. {
  480. case 1 : formatex( sPath, charsmax( sPath ), "%s/%s/prefix-%s.%s", sConfigsDir, g_FileFolder, sPrefix, g_FilePrefix );
  481. case 2 : formatex( sPath, charsmax( sPath ), "%s/%s/%s.%s", sConfigsDir, g_FileFolder, sMap, g_FilePrefix );
  482. case 3 : formatex( sPath, charsmax( sPath ), "%s/%s.%s", sConfigsDir, g_FileName, g_FilePrefix );
  483.  
  484. default : break;
  485. }
  486.  
  487. if( !CheckFile( sPath ) )
  488. continue;
  489.  
  490. bFound = true;
  491. break;
  492. }
  493.  
  494. log_amx( "---" );
  495.  
  496. bFound ?
  497. log_amx( "Falj betoltese: %s", sPath ) :
  498. log_amx( "Nincs falj." );
  499.  
  500. load_sound( sPath );
  501. }
  502.  
  503.  
  504. load_sound( const file[] )
  505. {
  506. new
  507. // - - - - - - - - - - - - - - -
  508. sBuffer[256],
  509. // |
  510. sLeft[ MAX_FILE_LENGTH ],
  511. sRight[4],
  512. sExt[6],
  513. // |
  514. eTeam;
  515. // - - - - - - - - - - - - - - -
  516.  
  517. new fp = fopen( file, "rt" );
  518.  
  519. while( !feof( fp ) )
  520. {
  521. fgets( fp, sBuffer, charsmax( sBuffer ) );
  522.  
  523. trim( sBuffer );
  524.  
  525. if( !sBuffer[0] || sBuffer[0] == ';' || ( sBuffer[0] == '/' && sBuffer[1] == '/' ) )
  526. continue;
  527.  
  528. if( sBuffer[0] != '"' || strlen( sBuffer ) < 11 )
  529. continue;
  530.  
  531. parse( sBuffer, sLeft, charsmax( sLeft ), sRight, charsmax( sRight ) );
  532. formatex( sExt, charsmax( sExt ), sLeft[ strlen( sLeft ) - 4 ] );
  533.  
  534. if( equali( sExt, ".mp3" ) == -1 || equali( sExt, ".wav" ) == -1 )
  535. {
  536. log_amx( "Ismeretlen kiterjesztes: %s", sExt );
  537. continue;
  538. }
  539.  
  540. if( !file_exists( sLeft ) )
  541. {
  542. log_amx( "Hiba - Inexistent File: %s", sLeft );
  543. continue;
  544. }
  545.  
  546. eTeam = NULL;
  547.  
  548. if( equali( sRight, "CT" ) )
  549. eTeam = CT;
  550.  
  551. else if( equali( sRight, "T" ) )
  552. eTeam = T;
  553.  
  554. if( eTeam == NULL )
  555. {
  556. log_amx( "Hiba - You have to specify a team T or CT for this sound: %s", sLeft );
  557. continue;
  558. }
  559.  
  560. #if defined old_amxx
  561. copy( g_sTeam_sounds[ g_nSnd[ eTeam ] ][ eTeam ], MAX_FILE_LENGTH - 1, sLeft );
  562. #else
  563. ArrayPushString( eTeam == CT ? g_lstSoundCT : g_lstSoundT, sLeft );
  564. #endif
  565.  
  566. ++g_nSnd[ eTeam ];
  567. }
  568. fclose( fp );
  569.  
  570. if( g_nSnd[ e_Team:T ] > 1 || g_nSnd[ e_Team:CT ] > 1 )
  571. {
  572. new iMax_t, iMax_ct;
  573. GetPrecacheValue( iMax_t, iMax_ct );
  574.  
  575. #if defined old_amxx
  576. UpdateArray( iMax_t, e_Team:T );
  577. UpdateArray( iMax_ct, e_Team:CT );
  578. #else
  579. p_DeleteRandomItem( iMax_t , e_Team:T , g_lstSoundT );
  580. p_DeleteRandomItem( iMax_ct, e_Team:CT, g_lstSoundCT );
  581. #endif
  582. }
  583.  
  584. log_amx( "---" );
  585.  
  586. #if defined _DEBUG
  587. log_amx( "[ Loading %d CTs Sounds ]", g_nSnd[ e_team:CT ] );
  588. #endif
  589. #if defined old_amxx
  590. PrecacheSounds( e_Team:CT );
  591. #else
  592. PrecacheSounds_n( g_lstSoundCT );
  593. #endif
  594.  
  595. #if defined _DEBUG
  596. log_amx( "[ Loading %d Ts Sounds ]", g_nSnd[ e_team:T ] );
  597. #endif
  598. #if defined old_amxx
  599. PrecacheSounds( e_Team:T );
  600. #else
  601. PrecacheSounds_n( g_lstSoundT );
  602. #endif
  603. }
  604.  
  605.  
  606. GetPrecacheValue( &iMax_t, &iMax_ct )
  607. {
  608. trim( g_sRp_value );
  609. new pos = contain( g_sRp_value, "-" );
  610.  
  611. if( pos > 0 )
  612. {
  613. iMax_ct = str_to_num( g_sRp_value[ pos + 1 ] )
  614. g_sRp_value[ pos ] = '^0';
  615. iMax_t = str_to_num( g_sRp_value );
  616. }
  617. else
  618. {
  619. iMax_t = str_to_num( g_sRp_value );
  620. iMax_ct = iMax_t;
  621. }
  622. }
  623.  
  624.  
  625. stock UpdateArray( iMax, iTeam )
  626. {
  627. new const iCnt_sound = g_nSnd[ iTeam ];
  628.  
  629. if( !iMax || iMax == iCnt_sound )
  630. return;
  631.  
  632. if( iMax >= iCnt_sound )
  633. iMax = iCnt_sound - 1;
  634.  
  635. static
  636. sTmp_sounds[ MAX_SOUNDS ][ e_Team ][ MAX_FILE_LENGTH ],
  637. iLast_number[ MAX_SOUNDS ];
  638.  
  639. new i, iRand;
  640. for( i = 0; i < iCnt_sound; i++ )
  641. {
  642. copy( sTmp_sounds[i][ iTeam ], MAX_FILE_LENGTH - 1, g_sTeam_sounds[i][ iTeam ] );
  643. g_sTeam_sounds[i][ iTeam ][0] = '^0';
  644. }
  645.  
  646. arrayset( iLast_number, 0, charsmax( iLast_number ) );
  647.  
  648. i = 0;
  649. while( i != iMax )
  650. {
  651. check:
  652. iRand = random( iCnt_sound );
  653.  
  654. if( iLast_number[ iRand ] )
  655. goto check;
  656.  
  657. copy( g_sTeam_sounds[i][ iTeam ], MAX_FILE_LENGTH - 1, sTmp_sounds[ iRand ][ iTeam ] );
  658. ++i;
  659.  
  660. iLast_number[ iRand ] = 1;
  661. }
  662.  
  663. g_nSnd[ iTeam ] = iMax;
  664. }
  665.  
  666.  
  667. stock p_DeleteRandomItem( iMax, iTeam, Array:sSound_a )
  668. {
  669. new const iCnt_sound = g_nSnd[ iTeam ];
  670.  
  671. if( !iMax || iMax == iCnt_sound )
  672. return;
  673.  
  674. if( iMax >= iCnt_sound )
  675. iMax = iCnt_sound - 1;
  676.  
  677. DeleteRandomItem( iCnt_sound - iMax, sSound_a );
  678. g_nSnd[ iTeam ] = iMax;
  679. }
  680.  
  681.  
  682. stock DeleteRandomItem( iRandom_n, Array:sSound_a )
  683. {
  684. new i;
  685.  
  686. while( i++ != iRandom_n )
  687. ArrayDeleteItem( sSound_a, random( ArraySize( sSound_a ) ) );
  688. }
  689.  
  690.  
  691. stock PrecacheSounds( iTeam )
  692. {
  693. for( new i; i < g_nSnd[ iTeam ]; i++ )
  694. {
  695. PrecacheFile( g_sTeam_sounds[i][ iTeam ] );
  696.  
  697. #if defined _DEBUG
  698. log_amx( " - %s", g_sTeam_sounds[i][ iTeam ] );
  699. #endif
  700. }
  701.  
  702. log_amx( "---" );
  703. }
  704.  
  705.  
  706. stock PrecacheSounds_n( Array:sSound_a )
  707. {
  708. static
  709. // - - - - - - - - - - - - - - - - - - -
  710. sFile[ MAX_FILE_LENGTH ],
  711. iFileLen = charsmax( sFile );
  712. // - - - - - - - - - - - - - - - - - - -
  713.  
  714. for( new i; i < ArraySize( sSound_a ); i++ )
  715. {
  716. ArrayGetString( sSound_a, i, sFile, iFileLen );
  717. PrecacheFile( sFile );
  718.  
  719. #if defined _DEBUG
  720. log_amx( " - %s", sFile );
  721. #endif
  722. }
  723.  
  724. log_amx( "---" );
  725. }
  726.  
  727.  
  728. PrecacheFile( const sound[] )
  729. {
  730. _is_wav( sound ) ?
  731.  
  732. precache_sound( sound[6] ) :
  733. precache_generic( sound );
  734. }
  735.  
  736.  
  737. ShowPrint( id, const sMsg[], { Float, Sql, Result, _ }:... )
  738. {
  739. static
  740. // - - - - - - - - -
  741. newMsg[191],
  742. message[191],
  743. // |
  744. tNewMsg;
  745. // - - - - - - - - -
  746.  
  747. tNewMsg = charsmax( newMsg );
  748. vformat( newMsg, tNewMsg, sMsg, 3 );
  749.  
  750. replace_all( newMsg, tNewMsg, "!t", "^3" );
  751. replace_all( newMsg, tNewMsg, "!g", "^4" );
  752. replace_all( newMsg, tNewMsg, "!n", "^1" );
  753.  
  754. formatex( message, charsmax( message ), "^4[ERS]^1 %s", newMsg );
  755.  
  756. emessage_begin( MSG_ONE, g_msgSayText, _, id );
  757. ewrite_byte( id );
  758. ewrite_string( message );
  759. emessage_end();
  760. }
  761.  
  762.  
  763. bool:CheckFile( const file[] )
  764. {
  765. new
  766. // - - - - - - - - - - - - - - - - -
  767. sBuffer[256],
  768. fp = fopen( file, "rt" );
  769. // - - - - - - - - - - - - - - - - -
  770.  
  771. if( !fp )
  772. return false;
  773.  
  774. while( !feof( fp ) )
  775. {
  776. fgets( fp, sBuffer, charsmax( sBuffer ) );
  777.  
  778. trim( sBuffer );
  779.  
  780. if( !sBuffer[0] || sBuffer[0] == ';' || ( sBuffer[0] == '/' && sBuffer[1] == '/' ) || sBuffer[0] != '"' )
  781. continue;
  782.  
  783. if( ( contain( sBuffer, ".mp3^"" ) != -1 || contain( sBuffer, ".wav^"" ) != -1 ) && ( contain( sBuffer, "^"T^"" ) != -1 || contain( sBuffer, "^"CT^"" ) != -1 ) )
  784. return true;
  785. }
  786. fclose( fp );
  787.  
  788. return false;
  789. }
  790.  

Ők köszönték meg HuBaBuBa nek ezt a hozzászólást: aron87 (2015.01.27. 11:17)
  Népszerűség: 2.27%


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: Alt End Round Sounds [Lang nélkül]
HozzászólásElküldve: 2015.01.27. 11:17 
Offline
Felfüggesztve
Avatar

Csatlakozott: 2014.12.05. 20:46
Hozzászólások: 177
Megköszönt másnak: 3 alkalommal
Megköszönték neki: 23 alkalommal
Hibátlan! Köszönöm szépen!


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 10 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 4 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole