HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1.  
  2. #include < amxmodx >
  3. #include < amxmisc >
  4.  
  5. #include < fakemeta >
  6. #include < hamsandwich >
  7. #include < engine >
  8. #include < cstrike >
  9. #include < fun >
  10. #include < xs >
  11.  
  12. #pragma semicolon 1
  13.  
  14. #define PLUGIN_VERSION "1.0.2"
  15.  
  16. #if AMXX_VERSION_NUM < 183
  17. #define MAX_PLAYERS 32
  18.  
  19. #define INT_BYTES 4
  20. #define BYTE_BITS 8
  21. #endif
  22.  
  23. #define AMBIENT_SOUND_LARGERADIUS 8
  24. #define ADMIN_ACCESS_FLAG ADMIN_BAN
  25.  
  26. #define TASKID_INVIS 2733
  27. #define IS_PLAYER(%1) ( 1 <= %1 <= gMaxPlayers )
  28.  
  29. enum _: iChristmasGifts
  30. {
  31. GIFT_ARMOR,
  32. GIFT_ARMOR_KEVLAR,
  33. GIFT_AMMO,
  34. GIFT_BONUS_HEALTH,
  35. GIFT_RANDOM_GRENADE,
  36. GIFT_FRAG,
  37. GIFT_INVISIBILITY,
  38. GIFT_RANDOM_GLOW,
  39. GIFT_RANDOM_HAT_GLOW_EFFECT,
  40. GIFT_DEFUSER,
  41. GIFT_CAMOUFLAGE,
  42. GIFT_MONEY
  43. };
  44.  
  45. enum _: iBombEvents
  46. {
  47. BOMB_PLANTED,
  48. BOMB_EXPLODED,
  49. BOMB_DEFUSED
  50. };
  51.  
  52. enum _: iGrenadeModels
  53. {
  54. VIEW_MODEL,
  55. PLAYER_MODEL,
  56. WORLD_MODEL
  57. };
  58.  
  59. enum _: iRGB
  60. {
  61. iRed = 0,
  62. iGreen,
  63. iBlue
  64. };
  65.  
  66. new const szGiftNames[ iChristmasGifts ][ ] =
  67. {
  68. "Armor",
  69. "Armor + Helmet",
  70. "Some Ammunition",
  71. "Bonus Health",
  72. "Random Grenade",
  73. "Bonus Frag",
  74. "Invisibility",
  75. "Random Glow",
  76. "Random Glow on Santa Hat",
  77. "Defuser Kit",
  78. "Camouflage: [You look like enemy until you die]",
  79. "Money"
  80. };
  81.  
  82. new const gCounterTerrModels[ ][ ] =
  83. {
  84. "urban",
  85. "gsg9",
  86. "gign",
  87. "sas"
  88. };
  89.  
  90. new const gTerroristModels[ ][ ] =
  91. {
  92. "terror",
  93. "leet",
  94. "artic",
  95. "guerilla"
  96. };
  97.  
  98. new const gGrenadeEntities[ ][ ] =
  99. {
  100. "weapon_hegrenade",
  101. "weapon_flashbang",
  102. "weapon_smokegrenade"
  103. };
  104.  
  105. new const gGunEvents[ ][ ] =
  106. {
  107. "events/awp.sc",
  108. "events/g3sg1.sc",
  109. "events/ak47.sc",
  110. "events/scout.sc",
  111. "events/m249.sc",
  112. "events/m4a1.sc",
  113. "events/sg552.sc",
  114. "events/aug.sc",
  115. "events/sg550.sc",
  116. "events/m3.sc",
  117. "events/xm1014.sc",
  118. "events/usp.sc",
  119. "events/mac10.sc",
  120. "events/ump45.sc",
  121. "events/fiveseven.sc",
  122. "events/p90.sc",
  123. "events/deagle.sc",
  124. "events/p228.sc",
  125. "events/glock18.sc",
  126. "events/mp5n.sc",
  127. "events/tmp.sc",
  128. "events/elite_left.sc",
  129. "events/elite_right.sc",
  130. "events/galil.sc",
  131. "events/famas.sc"
  132. };
  133.  
  134. new const gGiftModels[ ][ ] =
  135. {
  136. "models/aio_winter/present_1.mdl",
  137. "models/aio_winter/present_2.mdl",
  138. "models/aio_winter/present_3.mdl"
  139. };
  140.  
  141. new const gSantaHatModels[ ][ ] =
  142. {
  143. "models/aio_winter/santahat.mdl",
  144. "models/aio_winter/santahat_2.mdl"
  145. };
  146.  
  147. new const szChristmasTreeModels[ ][ ] =
  148. {
  149. "models/aio_winter/christmas_tree_1.mdl",
  150. "models/aio_winter/christmas_tree_2.mdl"
  151. };
  152.  
  153. new const szFrostBombModels[ ][ ] =
  154. {
  155. "models/aio_winter/snowman.mdl",
  156. "models/aio_winter/frost_man.mdl"
  157. };
  158.  
  159. new const gBombSounds[ iBombEvents ][ ] =
  160. {
  161. "aio_winter/bmb_planted_santa.wav",
  162. "aio_winter/bmb_exploded_santa.wav",
  163. "aio_winter/bmb_defused_santa.wav"
  164. };
  165.  
  166. new const szGrenadeModels[ iGrenadeModels ][ ] =
  167. {
  168. "models/aio_winter/v_xmasgrenade.mdl",
  169. "models/aio_winter/p_xmasgrenade.mdl",
  170. "models/aio_winter/w_xmasgrenade.mdl"
  171. };
  172.  
  173. new const szConfigFileName[ ] = "AIO_Winter.cfg";
  174. new const szPluginTag[ ] = "[ AIO Winter ]";
  175.  
  176. new const szSnowBallClassname[ ] = "SnowBall_Entity";
  177. new const szGiftClassname[ ] = "Present_Entity";
  178.  
  179. new const szSnowballModel[ ] = "sprites/bhit.spr";
  180. new const szTrailSprite[ ] = "sprites/laserbeam.spr";
  181. new const szGlowSpriteLed[ ] = "sprites/ledglow.spr";
  182. new const szShadowSpr[ ] = "sprites/shadow_circle.spr";
  183.  
  184. new const szCandyKnifeModel[ ] = "models/aio_winter/v_candycane.mdl";
  185. new const szCandyKnifeModelPlayer[ ] = "models/aio_winter/p_candycane.mdl";
  186.  
  187. new const szChristmasTreeSong[ ] = "aio_winter/merry_christmas.wav";
  188. new const szPickupArmorSound[ ] = "items/ammopickup2.wav";
  189. new const szHealthPickUpSound[ ] = "items/medshot4.wav";
  190. new const szBonusFragsPickupSound[ ] = "bullchicken/bc_bite1.wav";
  191. new const szInvisPickupSound[ ] = "barney/seeya.wav";
  192. new const szInvisDisabledSound[ ] = "barney/aintgoin.wav";
  193. new const szGlowPickupSound[ ] = "items/airtank1.wav";
  194. new const szDefuserPickupSound[ ] = "items/gunpickup3.wav";
  195. new const szCamouflagePickupSound[ ] = "items/weapondrop1.wav";
  196. new const szMoneyPickupSound[ ] = "barney/gladof38.wav";
  197.  
  198. new gCvarEnableGunSnowballs;
  199. new gCvarGunSnowballDuration;
  200. new gCvarEnableTrees;
  201. new gCvarEnableCustomBomb;
  202. new gCvarSantaHat;
  203. new gCvarSantaHatAdminOnly;
  204. new gCvarChristmasBombSounds;
  205. new gCvarUserWeatherMenu;
  206. new gCvarUserWeatherMenuDisplayTime;
  207. new gCvarEnableDarkness;
  208. new gCvarChangeSkyname;
  209. new gCvarEnablePresents;
  210. new gCvarBonusHealthAmount;
  211. new gCvarGiftArmor;
  212. new gCvarBonusFragAmount;
  213. new gCvarGiftInvisibilityDuration;
  214. new gCvarGiftMoney;
  215. new gCvarRainySupport;
  216. new gCvarEnableKnifeCandy;
  217. new gCvarChristmasGrenade;
  218. new gCvarChristmasGrenadeType;
  219.  
  220. new i;
  221. new gHudSync;
  222. new gMaxPlayers;
  223. new gTrailSprite;
  224. new gLedBombSprite;
  225. new gMessageScoreInfo;
  226. new gMessageShadowIdx;
  227. new gInfoTarget;
  228. new gShadowSpr;
  229.  
  230. new gEventsIndex[ sizeof gGunEvents ];
  231.  
  232. new gPlayerSantaHat[ MAX_PLAYERS + 1 ];
  233.  
  234. const m_pPlayer = 41;
  235. const m_LinuxDiff = 5;
  236. const m_bIsC4 = 385;
  237.  
  238. public plugin_init( )
  239. {
  240. register_plugin( "AIO: Winter Plugin", PLUGIN_VERSION, "tuty" );
  241. register_cvar( "aio_winter_version", PLUGIN_VERSION, FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED );
  242.  
  243. register_event( "DeathMsg", "EVENT_DeathMsg", "a" );
  244. register_event( "TextMsg", "EVENT_RoundStart", "a", "2&#Game_C", "2&#Game_w", "2&#Game_will_restart_in" );
  245. register_event( "BombDrop", "EVENT_OnBombDrop", "a", "4=1" );
  246.  
  247. register_logevent( "EVENT_RoundStart", 2, "1=Round_Start" );
  248. register_logevent( "LOGEvent_BombPlanted", 3, "2=Planted_The_Bomb" );
  249. register_logevent( "LOGEvent_BombDefused", 3, "2=Defused_The_Bomb" );
  250. register_logevent( "LOGEvent_BombExploded", 6, "3=Target_Bombed" );
  251.  
  252. RegisterHam( Ham_Spawn, "player", "bacon_PlayerSpawn", 1 );
  253. RegisterHam( Ham_Item_Deploy, "weapon_knife", "bacon_KnifeDeploy", 1 );
  254. RegisterHam( Ham_Think, "ambient_generic", "bacon_TreeThink", 1 );
  255.  
  256. for( i = 0; i < sizeof gGrenadeEntities; i++ )
  257. {
  258. RegisterHam( Ham_Item_Deploy, gGrenadeEntities[ i ], "bacon_GrenadeDeploy", 1 );
  259. }
  260.  
  261. register_forward( FM_SetModel, "forward_FM_SetModel", 1 );
  262. register_forward( FM_PlaybackEvent, "forward_FM_PlaybackEvent" );
  263.  
  264. register_think( szSnowBallClassname, "forward_SnowballThink" );
  265. register_think( szGiftClassname, "forward_GiftThink" );
  266.  
  267. register_touch( szGiftClassname, "player", "forward_TouchGift" );
  268.  
  269. register_message( SVC_TEMPENTITY, "Message_TempEntity" );
  270.  
  271. gCvarEnableGunSnowballs = register_cvar( "aio_winter_gun_snowball", "1" );
  272. gCvarGunSnowballDuration = register_cvar( "aio_winter_gun_snowball_duration", "5.0" );
  273. gCvarChangeSkyname = register_cvar( "aio_winter_changesky", "1" );
  274. gCvarEnableDarkness = register_cvar( "aio_winter_darkness", "1" );
  275. gCvarChristmasBombSounds = register_cvar( "aio_winter_bombsounds", "1" );
  276. gCvarUserWeatherMenu = register_cvar( "aio_winter_weathermenu", "1" );
  277. gCvarUserWeatherMenuDisplayTime = register_cvar( "aio_winter_weathermenu_time", "8.0" );
  278. gCvarEnableCustomBomb = register_cvar( "aio_winter_custombomb", "1" );
  279. gCvarEnableTrees = register_cvar( "aio_winter_tree", "1" );
  280. gCvarSantaHat = register_cvar( "aio_winter_hat", "1" );
  281. gCvarSantaHatAdminOnly = register_cvar( "aio_winter_hat_adminonly", "0" );
  282. gCvarEnablePresents = register_cvar( "aio_winter_presents", "1" );
  283. gCvarBonusHealthAmount = register_cvar( "aio_winter_bonus_health_amount", "50" );
  284. gCvarGiftArmor = register_cvar( "aio_winter_gift_armor", "100" );
  285. gCvarBonusFragAmount = register_cvar( "aio_bonus_frag", "2" );
  286. gCvarGiftInvisibilityDuration = register_cvar( "aio_winter_invis_duration", "15" );
  287. gCvarGiftMoney = register_cvar( "aio_winter_gift_money", "1500" );
  288. gCvarRainySupport = register_cvar( "aio_winter_rainymap_support", "1" );
  289. gCvarEnableKnifeCandy = register_cvar( "aio_winter_candyknife", "1" );
  290. gCvarChristmasGrenade = register_cvar( "aio_winter_grenade", "1" );
  291. gCvarChristmasGrenadeType = register_cvar( "aio_winter_grenade_type", "0" );
  292.  
  293. gHudSync = CreateHudSyncObj( );
  294. gMaxPlayers = get_maxplayers( );
  295.  
  296. gMessageScoreInfo = get_user_msgid( "ScoreInfo" );
  297. gMessageShadowIdx = get_user_msgid( "ShadowIdx" );
  298.  
  299. gInfoTarget = engfunc( EngFunc_AllocString, "info_target" );
  300. }
  301.  
  302. public plugin_cfg( )
  303. {
  304. if( get_pcvar_num( gCvarEnableDarkness ) != 0 )
  305. {
  306. set_lights( "d" );
  307. server_cmd( "mp_flashlight 1" );
  308. }
  309.  
  310. if( get_pcvar_num( gCvarChangeSkyname ) != 0 )
  311. {
  312. server_cmd( "sv_skyname ^"space^"" );
  313. }
  314.  
  315. if( get_pcvar_num( gCvarEnableTrees ) != 0 )
  316. {
  317. UTIL_FindSpawnPoints( );
  318. }
  319.  
  320. if( get_pcvar_num( gCvarRainySupport ) != 0 )
  321. {
  322. new szMapName[ MAX_PLAYERS ], iEntity = FM_NULLENT;
  323. get_mapname( szMapName, charsmax( szMapName ) );
  324.  
  325. while( ( iEntity = find_ent_by_class( iEntity, "env_rain" ) ) )
  326. {
  327. if( pev_valid( iEntity ) )
  328. {
  329. UTIL_RemoveEntities( "env_rain" );
  330.  
  331. server_print( "%s Found a map that has rain built in: '%s'. Support for rainy maps is enabled, so the map has been patched", szPluginTag, szMapName );
  332. log_amx( "%s Found a map that has rain built in: '%s'. Support for rainy maps is enabled, so the map has been patched", szPluginTag, szMapName );
  333. }
  334. }
  335. }
  336.  
  337. new szConfigsDir[ MAX_PLAYERS ], szFile[ 256 ];
  338.  
  339. get_configsdir( szConfigsDir, charsmax( szConfigsDir ) );
  340. formatex( szFile, charsmax( szFile ), "%s/%s", szConfigsDir, szConfigFileName );
  341.  
  342. if( file_exists( szFile ) )
  343. {
  344. server_cmd( "exec %s", szFile );
  345.  
  346. log_amx( "%s Configuration file '%s' loaded successfully!", szPluginTag, szConfigFileName );
  347. server_print( "%s Configuration file '%s' loaded successfully!", szPluginTag, szConfigFileName );
  348. }
  349.  
  350. else
  351. {
  352. log_amx( "%s Configuration file '%s' not found! Loading default Cvars...", szPluginTag, szConfigFileName );
  353. server_print( "%s Configuration file '%s' not found! Loading default Cvars...", szPluginTag, szConfigFileName );
  354. }
  355. }
  356.  
  357. public plugin_precache( )
  358. {
  359. engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "env_snow" ) );
  360.  
  361. for( i = 0 ; i < sizeof gGunEvents; i++ )
  362. {
  363. gEventsIndex[ i ] = engfunc( EngFunc_PrecacheEvent, 1, gGunEvents[ i ] );
  364. }
  365.  
  366. gTrailSprite = precache_model( szTrailSprite );
  367. gLedBombSprite = precache_model( szGlowSpriteLed );
  368. gShadowSpr = precache_model( szShadowSpr );
  369.  
  370. precache_model( szCandyKnifeModelPlayer );
  371. precache_model( szSnowballModel );
  372. precache_model( szCandyKnifeModel );
  373.  
  374. for( i = 0; i < iGrenadeModels; i++ )
  375. {
  376. precache_model( szGrenadeModels[ i ] );
  377. }
  378.  
  379. for( i = 0; i < iBombEvents; i++ )
  380. {
  381. precache_sound( gBombSounds[ i ] );
  382. }
  383.  
  384. for( i = 0; i < sizeof gGiftModels; i++ )
  385. {
  386. precache_model( gGiftModels[ i ] );
  387. }
  388.  
  389. for( i = 0; i < sizeof gSantaHatModels; i++ )
  390. {
  391. precache_model( gSantaHatModels[ i ] );
  392. }
  393.  
  394. for( i = 0; i < sizeof szChristmasTreeModels; i++ )
  395. {
  396. precache_model( szChristmasTreeModels[ i ] );
  397. }
  398.  
  399. for( i = 0; i < sizeof szFrostBombModels; i++ )
  400. {
  401. precache_model( szFrostBombModels[ i ] );
  402. }
  403.  
  404. precache_sound( szChristmasTreeSong );
  405. precache_sound( szPickupArmorSound );
  406. precache_sound( szHealthPickUpSound );
  407. precache_sound( szBonusFragsPickupSound );
  408. precache_sound( szInvisPickupSound );
  409. precache_sound( szInvisDisabledSound );
  410. precache_sound( szGlowPickupSound );
  411. precache_sound( szDefuserPickupSound );
  412. precache_sound( szCamouflagePickupSound );
  413. precache_sound( szMoneyPickupSound );
  414. }
  415.  
  416. public client_connect( id )
  417. {
  418. if( gPlayerSantaHat[ id ] > 0 )
  419. {
  420. engfunc( EngFunc_RemoveEntity, gPlayerSantaHat[ id ] );
  421. }
  422.  
  423. gPlayerSantaHat[ id ] = 0;
  424. }
  425.  
  426. public client_disconnect( id )
  427. {
  428. if( gPlayerSantaHat[ id ] > 0 )
  429. {
  430. engfunc( EngFunc_RemoveEntity, gPlayerSantaHat[ id ] );
  431. }
  432.  
  433. remove_task( id + TASKID_INVIS );
  434.  
  435. gPlayerSantaHat[ id ] = 0;
  436. }
  437.  
  438. public client_putinserver( id )
  439. {
  440. if( get_pcvar_num( gCvarUserWeatherMenu ) != 0 )
  441. {
  442. set_task( get_pcvar_float( gCvarUserWeatherMenuDisplayTime ), "DisplayWeather_Menu", id );
  443. }
  444. }
  445.  
  446. public DisplayWeather_Menu( id )
  447. {
  448. if( is_user_connected( id ) )
  449. {
  450. new szName[ 32 ];
  451. get_user_name( id, szName, charsmax( szName ) );
  452.  
  453. new szFormatMenuTitle[ 350 ];
  454. formatex( szFormatMenuTitle, charsmax( szFormatMenuTitle ), "\wHi\r %s\w, in order to enjoy the best \rChirstmas Environment\w on this server, we recommend the following action:^n* Set the \r^"cl_weather^"\w to \y1\w/\y2\w/\y3\w in console to enable the \ySnow \weffect!^nWould you like to set this up for you?^n^n", szName );
  455.  
  456. new iMenu = menu_create( szFormatMenuTitle, "menu_Handler" );
  457.  
  458. menu_additem( iMenu, "Yes, enable weather for me!", "1", 0 );
  459. menu_additem( iMenu, "No, thanks.", "2", 0 );
  460.  
  461. menu_setprop( iMenu, MPROP_EXIT, MEXIT_NEVER );
  462. menu_display( id, iMenu, 0 );
  463. }
  464. }
  465.  
  466. public menu_Handler( id, menu, item )
  467. {
  468. switch( item )
  469. {
  470. case 0:
  471. {
  472. client_cmd( id, "speak ^"items/suitchargeok1.wav^"" );
  473. client_cmd( id, "wait; cl_weather 3" );
  474.  
  475. client_print( id, print_chat, "%s Plugin enabled Snow effects to your client, with your permission.", szPluginTag );
  476. menu_destroy( menu );
  477.  
  478. return PLUGIN_HANDLED;
  479. }
  480.  
  481. case 1:
  482. {
  483. client_cmd( id, "speak ^"items/cliprelease1.wav^"" );
  484.  
  485. client_print( id, print_chat, "%s Please make sure that you enable ^"cl_weather^" in to your game console, to experience the Christmas Environment!", szPluginTag );
  486. menu_destroy( menu );
  487.  
  488. return PLUGIN_HANDLED;
  489. }
  490. }
  491.  
  492. menu_destroy( menu );
  493.  
  494. return PLUGIN_HANDLED;
  495. }
  496.  
  497. public LOGEvent_BombPlanted( )
  498. {
  499. if( get_pcvar_num( gCvarChristmasBombSounds ) != 0 )
  500. {
  501. emit_sound( 0, CHAN_AUTO, gBombSounds[ BOMB_PLANTED ], VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
  502. }
  503. }
  504.  
  505. public LOGEvent_BombDefused( )
  506. {
  507. if( get_pcvar_num( gCvarChristmasBombSounds ) != 0 )
  508. {
  509. emit_sound( 0, CHAN_AUTO, gBombSounds[ BOMB_DEFUSED ], VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
  510. }
  511. }
  512.  
  513. public LOGEvent_BombExploded( )
  514. {
  515. if( get_pcvar_num( gCvarChristmasBombSounds ) != 0 )
  516. {
  517. emit_sound( 0, CHAN_AUTO, gBombSounds[ BOMB_EXPLODED ], VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
  518. }
  519. }
  520.  
  521. public EVENT_RoundStart( )
  522. {
  523. new iPlayers[ MAX_PLAYERS ];
  524. new iPlayerCount, iPlayerId;
  525.  
  526. get_players( iPlayers, iPlayerCount, "c" );
  527.  
  528. for( i = 0; i < iPlayerCount; i++ )
  529. {
  530. iPlayerId = iPlayers[ i ];
  531.  
  532. set_user_rendering( iPlayerId );
  533. cs_reset_user_model( iPlayerId );
  534.  
  535. UTIL_ShadowStatus( iPlayerId, gShadowSpr );
  536. remove_task( iPlayerId + TASKID_INVIS );
  537. }
  538.  
  539. // --| Reset bomb_planted sound :p
  540. client_cmd( 0, "wait; speak ^"vox/_period.wav^"" );
  541.  
  542. UTIL_RemoveEntities( szGiftClassname );
  543. }
  544.  
  545. public bacon_GrenadeDeploy( iWeaponEntity )
  546. {
  547. if( get_pcvar_num( gCvarChristmasGrenade ) == 1 )
  548. {
  549. if( pev_valid( iWeaponEntity ) )
  550. {
  551. new id = get_pdata_cbase( iWeaponEntity, m_pPlayer, m_LinuxDiff );
  552.  
  553. if( is_user_alive( id ) )
  554. {
  555. set_pev( id, pev_viewmodel2, szGrenadeModels[ VIEW_MODEL ] );
  556. set_pev( id, pev_weaponmodel2, szGrenadeModels[ PLAYER_MODEL ] );
  557. }
  558. }
  559. }
  560. }
  561.  
  562. public bacon_KnifeDeploy( iWeaponEntity )
  563. {
  564. if( get_pcvar_num( gCvarEnableKnifeCandy ) != 0 )
  565. {
  566. if( pev_valid( iWeaponEntity ) )
  567. {
  568. new id = get_pdata_cbase( iWeaponEntity, m_pPlayer, m_LinuxDiff );
  569.  
  570. if( is_user_alive( id ) )
  571. {
  572. set_pev( id, pev_viewmodel2, szCandyKnifeModel );
  573. set_pev( id, pev_weaponmodel2, szCandyKnifeModelPlayer );
  574. }
  575. }
  576. }
  577. }
  578.  
  579. public Message_TempEntity( msg_id, msg_dest, msg_ent )
  580. {
  581. if( get_pcvar_num( gCvarEnableCustomBomb ) == 1 )
  582. {
  583. if( get_msg_arg_int( 1 ) == TE_GLOWSPRITE )
  584. {
  585. if( get_msg_arg_int( 5 ) == gLedBombSprite )
  586. {
  587. return PLUGIN_HANDLED;
  588. }
  589. }
  590. }
  591.  
  592. return PLUGIN_CONTINUE;
  593. }
  594.  
  595. public EVENT_DeathMsg( )
  596. {
  597. if( get_pcvar_num( gCvarEnablePresents ) == 0 )
  598. {
  599. return;
  600. }
  601.  
  602. new iKiller = read_data( 1 );
  603. new iVictim = read_data( 2 );
  604.  
  605. if( !IS_PLAYER( iVictim ) )
  606. {
  607. return;
  608. }
  609.  
  610. if( iVictim == iKiller )
  611. {
  612. UTIL_ShadowStatus( iVictim, gShadowSpr );
  613. remove_task( iVictim + TASKID_INVIS );
  614.  
  615. set_user_rendering( iVictim );
  616. cs_reset_user_model( iVictim );
  617.  
  618. return;
  619. }
  620.  
  621. UTIL_ShadowStatus( iVictim, gShadowSpr );
  622. remove_task( iVictim + TASKID_INVIS );
  623.  
  624. set_user_rendering( iVictim );
  625. cs_reset_user_model( iVictim );
  626.  
  627. new Float:flOrigin[ 3 ];
  628. pev( iVictim, pev_origin, flOrigin );
  629.  
  630. flOrigin[ 2 ] += -28.0;
  631.  
  632. new Float:flAngles[ 3 ];
  633. pev( iVictim, pev_angles, flAngles );
  634.  
  635. new iEntity = engfunc( EngFunc_CreateNamedEntity, gInfoTarget );
  636.  
  637. if( !pev_valid( iEntity ) )
  638. {
  639. return;
  640. }
  641.  
  642. set_pev( iEntity, pev_classname, szGiftClassname );
  643. set_pev( iEntity, pev_angles, flAngles );
  644.  
  645. engfunc( EngFunc_SetOrigin, iEntity, flOrigin );
  646. engfunc( EngFunc_SetModel, iEntity, gGiftModels[ random_num( 0, charsmax( gGiftModels ) ) ] );
  647.  
  648. ExecuteHam( Ham_Spawn, iEntity );
  649.  
  650. set_pev( iEntity, pev_solid, SOLID_BBOX );
  651. set_pev( iEntity, pev_movetype, MOVETYPE_NONE );
  652. set_pev( iEntity, pev_nextthink, get_gametime( ) + 2.0 );
  653.  
  654. engfunc( EngFunc_SetSize, iEntity, Float:{ -23.160000, -13.660000, -0.050000 }, Float:{ 11.470000, 12.780000, 6.720000 } );
  655. engfunc( EngFunc_DropToFloor, iEntity );
  656.  
  657. set_rendering( iEntity, kRenderFxGlowShell, random( 256 ), random( 256 ), random( 256 ), kRenderFxNone, 23 );
  658.  
  659. return;
  660. }
  661.  
  662. public forward_GiftThink( iEntity )
  663. {
  664. if( pev_valid( iEntity ) )
  665. {
  666. set_rendering( iEntity, kRenderFxGlowShell, random( 256 ), random( 256 ), random( 256 ), kRenderFxNone, random_num( 5, 20 ) );
  667. set_pev( iEntity, pev_nextthink, get_gametime( ) + 2.0 );
  668. }
  669. }
  670.  
  671. public forward_TouchGift( iEntity, id )
  672. {
  673. if( !pev_valid( iEntity )
  674. || !is_user_alive( id ) )
  675. {
  676. return PLUGIN_HANDLED;
  677. }
  678.  
  679. set_hudmessage( random( 256 ), random( 256 ), random( 256 ), -1.0, 0.72, 1, 6.0, 5.0 );
  680.  
  681. switch( random( iChristmasGifts ) )
  682. {
  683. case GIFT_ARMOR:
  684. {
  685. new iArmor = get_pcvar_num( gCvarGiftArmor );
  686. set_user_armor( id, iArmor );
  687.  
  688. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s (%d)", szPluginTag, szGiftNames[ GIFT_ARMOR ], iArmor );
  689. emit_sound( id, CHAN_ITEM, szPickupArmorSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  690. }
  691.  
  692. case GIFT_ARMOR_KEVLAR:
  693. {
  694. new iArmor = get_pcvar_num( gCvarGiftArmor );
  695. cs_set_user_armor( id, iArmor, CS_ARMOR_VESTHELM );
  696.  
  697. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s (%d)", szPluginTag, szGiftNames[ GIFT_ARMOR_KEVLAR ], iArmor );
  698. emit_sound( id, CHAN_ITEM, szPickupArmorSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  699. }
  700.  
  701. case GIFT_AMMO:
  702. {
  703. UTIL_GiveWeaponAmmo( id );
  704. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s", szPluginTag, szGiftNames[ GIFT_AMMO ] );
  705. }
  706.  
  707. case GIFT_BONUS_HEALTH:
  708. {
  709. new iBonusHealth = get_pcvar_num( gCvarBonusHealthAmount );
  710. set_user_health( id, get_user_health( id ) + iBonusHealth );
  711.  
  712. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s + (%d HP)", szPluginTag, szGiftNames[ GIFT_BONUS_HEALTH ], iBonusHealth );
  713. emit_sound( id, CHAN_ITEM, szHealthPickUpSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  714. }
  715.  
  716. case GIFT_RANDOM_GRENADE:
  717. {
  718. switch( random_num( 1, 3 ) )
  719. {
  720. case 1:
  721. {
  722. if( user_has_weapon( id, CSW_HEGRENADE ) )
  723. {
  724. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s^nYou already have this grenade (HE Grenade)!", szPluginTag, szGiftNames[ GIFT_BONUS_HEALTH ] );
  725. }
  726.  
  727. give_item( id, "weapon_hegrenade" );
  728. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s (HE Grenade)", szPluginTag, szGiftNames[ GIFT_RANDOM_GRENADE ] );
  729. }
  730.  
  731. case 2:
  732. {
  733. give_item( id, "weapon_flashbang" );
  734. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s (FB Grenade)", szPluginTag, szGiftNames[ GIFT_RANDOM_GRENADE ] );
  735. }
  736.  
  737. case 3:
  738. {
  739. if( user_has_weapon( id, CSW_SMOKEGRENADE ) )
  740. {
  741. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s^nYou already have this grenade (Smoke Grenade)!", szPluginTag, szGiftNames[ GIFT_BONUS_HEALTH ] );
  742. }
  743.  
  744. give_item( id, "weapon_smokegrenade" );
  745. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s (Smoke Grenade)", szPluginTag, szGiftNames[ GIFT_RANDOM_GRENADE ] );
  746. }
  747. }
  748.  
  749. emit_sound( id, CHAN_ITEM, szPickupArmorSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  750. }
  751.  
  752. case GIFT_FRAG:
  753. {
  754. new iBonusFrags = get_pcvar_num( gCvarBonusFragAmount );
  755.  
  756. set_user_frags( id, get_user_frags( id ) + iBonusFrags );
  757. UTIL_UpdateScoreboard( id );
  758.  
  759. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s (%d Frag%s)", szPluginTag, szGiftNames[ GIFT_FRAG ], iBonusFrags, ( iBonusFrags == 1 ? "" : "s" ) );
  760. emit_sound( id, CHAN_ITEM, szBonusFragsPickupSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  761. }
  762.  
  763. case GIFT_INVISIBILITY:
  764. {
  765. new iInvisDuration = get_pcvar_num( gCvarGiftInvisibilityDuration );
  766.  
  767. new iSantaHat = gPlayerSantaHat[ id ];
  768.  
  769. if( iSantaHat > 0 )
  770. {
  771. set_rendering( iSantaHat, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 0 );
  772. }
  773.  
  774. UTIL_ShadowStatus( id, 0 );
  775.  
  776. set_user_rendering( id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 0 );
  777. set_task( float( iInvisDuration ), "RemovePlayer_InvisGift", id + TASKID_INVIS );
  778.  
  779. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s (%d Second%s)", szPluginTag, szGiftNames[ GIFT_INVISIBILITY ], iInvisDuration, ( iInvisDuration == 1 ? "" : "s" ) );
  780. emit_sound( id, CHAN_ITEM, szInvisPickupSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  781. }
  782.  
  783. case GIFT_RANDOM_GLOW:
  784. {
  785. remove_task( id + TASKID_INVIS );
  786. set_user_rendering( id, kRenderFxGlowShell, random( 256 ), random( 256 ), random( 256 ), kRenderNormal, random( 256 ) );
  787.  
  788. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s", szPluginTag, szGiftNames[ GIFT_RANDOM_GLOW ] );
  789. emit_sound( id, CHAN_ITEM, szGlowPickupSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  790. }
  791.  
  792. case GIFT_RANDOM_HAT_GLOW_EFFECT:
  793. {
  794. new iSantaHat = gPlayerSantaHat[ id ];
  795.  
  796. if( iSantaHat > 0 )
  797. {
  798. set_rendering( iSantaHat, kRenderFxGlowShell, random( 256 ), random( 256 ), random( 256 ), kRenderNormal, 10 );
  799. }
  800.  
  801. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s", szPluginTag, szGiftNames[ GIFT_RANDOM_HAT_GLOW_EFFECT ] );
  802. emit_sound( id, CHAN_ITEM, szGlowPickupSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  803. }
  804.  
  805. case GIFT_DEFUSER:
  806. {
  807. if( get_user_team( id ) == 2 )
  808. {
  809. cs_set_user_defuse( id, 1 );
  810. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s", szPluginTag, szGiftNames[ GIFT_DEFUSER ] );
  811.  
  812. emit_sound( id, CHAN_ITEM, szDefuserPickupSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  813. }
  814.  
  815. else
  816. {
  817. ShowSyncHudMsg( id, gHudSync, "%s^nGift contained a Defuser Kit, but you are on Terrorist Force!", szPluginTag );
  818.  
  819. emit_sound( id, CHAN_ITEM, szDefuserPickupSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  820. }
  821. }
  822.  
  823. case GIFT_CAMOUFLAGE:
  824. {
  825. switch( get_user_team( id ) )
  826. {
  827. case 1:
  828. {
  829. cs_set_user_model( id, gCounterTerrModels[ random_num( 0, charsmax( gCounterTerrModels ) ) ] );
  830. }
  831.  
  832. case 2:
  833. {
  834. cs_set_user_model( id, gTerroristModels[ random_num( 0, charsmax( gTerroristModels ) ) ] );
  835. }
  836. }
  837.  
  838. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s", szPluginTag, szGiftNames[ GIFT_CAMOUFLAGE ] );
  839. emit_sound( id, CHAN_ITEM, szCamouflagePickupSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  840. }
  841.  
  842. case GIFT_MONEY:
  843. {
  844. new iMoney = cs_get_user_money( id );
  845. new iMoneyGift = get_pcvar_num( gCvarGiftMoney );
  846.  
  847. cs_set_user_money( id, ( iMoney >= 16000 ) ? 16000 : iMoney + iMoneyGift, 1 );
  848. ShowSyncHudMsg( id, gHudSync, "%s^nYou picked up:^n%s + ($%d)", szPluginTag, szGiftNames[ GIFT_MONEY ], iMoneyGift );
  849.  
  850. emit_sound( id, CHAN_ITEM, szMoneyPickupSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  851. }
  852. }
  853.  
  854. engfunc( EngFunc_RemoveEntity, iEntity );
  855.  
  856. return PLUGIN_CONTINUE;
  857. }
  858.  
  859. public RemovePlayer_InvisGift( iTaskid )
  860. {
  861. new id = iTaskid - TASKID_INVIS;
  862.  
  863. if( IS_PLAYER( id ) )
  864. {
  865. new iSantaHat = gPlayerSantaHat[ id ];
  866.  
  867. if( iSantaHat > 0 )
  868. {
  869. set_rendering( iSantaHat );
  870. }
  871.  
  872. set_hudmessage( random( 256 ), random( 256 ), random( 256 ), -1.0, 0.72, 1, 6.0, 5.0 );
  873. ShowSyncHudMsg( id, gHudSync, "Invisibility is no longer available" );
  874.  
  875. UTIL_ShadowStatus( id, gShadowSpr );
  876.  
  877. set_user_rendering( id );
  878. remove_task( id + TASKID_INVIS );
  879.  
  880. emit_sound( id, CHAN_ITEM, szInvisDisabledSound, VOL_NORM, ATTN_NORM, 0 , PITCH_NORM );
  881. }
  882. }
  883.  
  884. public forward_FM_PlaybackEvent( iFlags, id, eventIndex )
  885. {
  886. if( get_pcvar_num( gCvarEnableGunSnowballs ) == 0 )
  887. {
  888. return FMRES_IGNORED;
  889. }
  890.  
  891. new Float:flAimOrigin[ 3 ];
  892.  
  893. new iEntity = engfunc( EngFunc_CreateNamedEntity, gInfoTarget );
  894.  
  895. if( !pev_valid( iEntity ) )
  896. {
  897. return FMRES_IGNORED;
  898. }
  899.  
  900. for( i = 0 ; i < sizeof gGunEvents; i++ )
  901. {
  902. if( eventIndex == gEventsIndex[ i ] )
  903. {
  904. UTIL_GetAim_Origin( id, flAimOrigin );
  905.  
  906. if( engfunc( EngFunc_PointContents, flAimOrigin ) != CONTENTS_SKY )
  907. {
  908. set_pev( iEntity, pev_solid, SOLID_NOT );
  909. set_pev( iEntity, pev_movetype, MOVETYPE_NONE );
  910.  
  911. engfunc( EngFunc_SetModel, iEntity, szSnowballModel );
  912. set_pev( iEntity, pev_classname, szSnowBallClassname );
  913.  
  914. engfunc( EngFunc_SetOrigin, iEntity, flAimOrigin );
  915. set_rendering( iEntity, kRenderFxNoDissipation, 255, 255, 255, kRenderGlow, 255 );
  916.  
  917. set_pev( iEntity, pev_scale, random_float( 0.2, 0.5 ) );
  918. set_pev( iEntity, pev_flags, FL_ALWAYSTHINK );
  919. set_pev( iEntity, pev_nextthink, get_gametime( ) + get_pcvar_float( gCvarGunSnowballDuration ) );
  920.  
  921. return FMRES_IGNORED;
  922. }
  923. }
  924. }
  925.  
  926. return FMRES_IGNORED;
  927. }
  928.  
  929. public bacon_PlayerSpawn( id )
  930. {
  931. if( get_pcvar_num( gCvarSantaHat ) != 0 )
  932. {
  933. if( is_user_alive( id ) )
  934. {
  935. switch( get_pcvar_num( gCvarSantaHatAdminOnly ) )
  936. {
  937. case 0: UTIL_SetSantaHat( id );
  938. case 1:
  939. {
  940. if( get_user_flags( id ) & ADMIN_ACCESS_FLAG )
  941. {
  942. UTIL_SetSantaHat( id );
  943. }
  944. }
  945. }
  946. }
  947. }
  948. }
  949.  
  950. public EVENT_OnBombDrop( )
  951. {
  952. if( get_pcvar_num( gCvarEnableCustomBomb ) == 1 )
  953. {
  954. new Float:flAngles[ 3 ], iEntity = FM_NULLENT;
  955.  
  956. while( ( iEntity = find_ent_by_class( iEntity, "grenade" ) ) )
  957. {
  958. if( pev_valid( iEntity ) )
  959. {
  960. if( get_pdata_bool( iEntity, m_bIsC4 ) == true )
  961. {
  962. pev( iEntity, pev_angles, flAngles );
  963.  
  964. flAngles[ 1 ] += random_float( 1.0, 360.0 );
  965.  
  966. engfunc( EngFunc_SetModel, iEntity, szFrostBombModels[ random_num( 0, charsmax( szFrostBombModels ) ) ] );
  967.  
  968. set_pev( iEntity, pev_angles, flAngles );
  969. set_pev( iEntity, pev_effects, EF_DIMLIGHT );
  970.  
  971. set_rendering( iEntity, kRenderFxGlowShell, 255, 255, 255, kRenderNormal, 50 );
  972. }
  973. }
  974. }
  975. }
  976. }
  977.  
  978. public forward_FM_SetModel( iEntity, const szModel[ ] )
  979. {
  980. if( get_pcvar_num( gCvarChristmasGrenade ) == 1 )
  981. {
  982. if( szModel[ 0 ] == 'm'
  983. && szModel[ 7 ] == 'w'
  984. && szModel[ 8 ] == '_' )
  985. {
  986. new Float:flDmgTime;
  987. pev( iEntity, pev_dmgtime, flDmgTime );
  988.  
  989. if( flDmgTime == 0.0 )
  990. {
  991. return FMRES_IGNORED;
  992. }
  993.  
  994. static iGrenadeRGB[ iRGB ];
  995. static const NUMBER_NINE = 9;
  996.  
  997. switch( get_pcvar_num( gCvarChristmasGrenadeType ) )
  998. {
  999. case 0:
  1000. {
  1001. if( szModel[ NUMBER_NINE ] == 'h'
  1002. || szModel[ NUMBER_NINE ] == 'f'
  1003. || szModel[ NUMBER_NINE ] == 's' )
  1004. {
  1005. iGrenadeRGB[ iRed ] = 255;
  1006. iGrenadeRGB[ iGreen ] = 255;
  1007. iGrenadeRGB[ iBlue ] = 255;
  1008. }
  1009. }
  1010.  
  1011. case 1:
  1012. {
  1013. switch( szModel[ NUMBER_NINE ] )
  1014. {
  1015. case 'h':
  1016. {
  1017. iGrenadeRGB[ iRed ] = 255;
  1018. iGrenadeRGB[ iGreen ] = 10;
  1019. iGrenadeRGB[ iBlue ] = 10;
  1020. }
  1021.  
  1022. case 'f':
  1023. {
  1024. iGrenadeRGB[ iRed ] = 10;
  1025. iGrenadeRGB[ iGreen ] = 10;
  1026. iGrenadeRGB[ iBlue ] = 255;
  1027. }
  1028.  
  1029. case 's':
  1030. {
  1031. iGrenadeRGB[ iRed ] = 10;
  1032. iGrenadeRGB[ iGreen ] = 255;
  1033. iGrenadeRGB[ iBlue ] = 10;
  1034. }
  1035. }
  1036. }
  1037.  
  1038. case 2:
  1039. {
  1040. iGrenadeRGB[ iRed ] = random( 256 );
  1041. iGrenadeRGB[ iGreen ] = random( 256 );
  1042. iGrenadeRGB[ iBlue ] = random( 256 );
  1043. }
  1044. }
  1045.  
  1046. UTIL_Trail( iEntity, iGrenadeRGB[ iRed ], iGrenadeRGB[ iGreen ], iGrenadeRGB[ iBlue ], 200 );
  1047. set_rendering( iEntity, kRenderFxGlowShell, iGrenadeRGB[ iRed ], iGrenadeRGB[ iGreen ], iGrenadeRGB[ iBlue ], kRenderNormal, 120 );
  1048.  
  1049. engfunc( EngFunc_SetModel, iEntity, szGrenadeModels[ WORLD_MODEL ] );
  1050.  
  1051. }
  1052.  
  1053. return FMRES_SUPERCEDE;
  1054. }
  1055.  
  1056. return FMRES_IGNORED;
  1057. }
  1058.  
  1059. public bacon_TreeThink( iEntity )
  1060. {
  1061. if( pev_valid( iEntity ) )
  1062. {
  1063. set_pev( iEntity, pev_nextthink, get_gametime( ) + 0.8 );
  1064.  
  1065. new Float:flOrigin[ 3 ];
  1066. pev( iEntity, pev_origin, flOrigin );
  1067.  
  1068. UTIL_DynamicLight( flOrigin, random( 256 ), random( 256 ), random( 256 ), 255 );
  1069. set_rendering( iEntity, kRenderFxGlowShell, random( 256 ), random( 256 ), random( 256 ), kRenderNormal, random_num( 1, 50 ) );
  1070. }
  1071. }
  1072.  
  1073. public forward_SnowballThink( iEntity )
  1074. {
  1075. if( pev_valid( iEntity ) )
  1076. {
  1077. engfunc( EngFunc_RemoveEntity, iEntity );
  1078. }
  1079. }
  1080.  
  1081. UTIL_FindSpawnPoints( )
  1082. {
  1083. new iCounterTerroristSpawn = engfunc( EngFunc_FindEntityByString, FM_NULLENT, "classname", "info_player_start" );
  1084.  
  1085. if( !iCounterTerroristSpawn )
  1086. {
  1087. return;
  1088. }
  1089.  
  1090. new Float:flCounterTerroristOrigin[ 3 ];
  1091. pev( iCounterTerroristSpawn, pev_origin, flCounterTerroristOrigin );
  1092.  
  1093. UTIL_CreateChristmasTree( flCounterTerroristOrigin );
  1094.  
  1095. new iTerroristSpawn = engfunc( EngFunc_FindEntityByString, FM_NULLENT, "classname", "info_player_deathmatch" );
  1096.  
  1097. if( !iTerroristSpawn )
  1098. {
  1099. return;
  1100. }
  1101.  
  1102. new Float:flTerroristOrigin[ 3 ];
  1103. pev( iTerroristSpawn, pev_origin, flTerroristOrigin );
  1104.  
  1105. UTIL_CreateChristmasTree( flTerroristOrigin );
  1106. }
  1107.  
  1108. UTIL_CreateChristmasTree( Float:flOrigin[ 3 ] )
  1109. {
  1110. new iEntity = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "ambient_generic" ) );
  1111.  
  1112. if( !pev_valid( iEntity ) )
  1113. {
  1114. return;
  1115. }
  1116.  
  1117. new Float:flAngles[ 3 ];
  1118. flAngles[ 1 ] += random_float( 1.0, 360.0 );
  1119.  
  1120. set_pev( iEntity, pev_message, szChristmasTreeSong );
  1121. set_pev( iEntity, pev_spawnflags, AMBIENT_SOUND_LARGERADIUS );
  1122. set_pev( iEntity, pev_effects, EF_BRIGHTFIELD );
  1123. set_pev( iEntity, pev_origin, flOrigin );
  1124. set_pev( iEntity, pev_movetype, MOVETYPE_TOSS );
  1125. set_pev( iEntity, pev_health, 1.0 );
  1126. set_pev( iEntity, pev_angles, flAngles );
  1127. set_pev( iEntity, pev_nextthink, get_gametime( ) + 0.8 );
  1128.  
  1129. ExecuteHam( Ham_Spawn, iEntity );
  1130.  
  1131. engfunc( EngFunc_SetModel, iEntity, szChristmasTreeModels[ random_num( 0, charsmax( szChristmasTreeModels ) ) ] );
  1132. engfunc( EngFunc_DropToFloor, iEntity );
  1133. }
  1134.  
  1135. UTIL_RemoveEntities( const szClassname[ ] )
  1136. {
  1137. new iEntity = FM_NULLENT;
  1138.  
  1139. while( ( iEntity = engfunc( EngFunc_FindEntityByString, FM_NULLENT, "classname", szClassname ) ) )
  1140. {
  1141. engfunc( EngFunc_RemoveEntity, iEntity );
  1142. }
  1143. }
  1144.  
  1145. UTIL_SetSantaHat( id )
  1146. {
  1147. engfunc( EngFunc_RemoveEntity, gPlayerSantaHat[ id ] );
  1148.  
  1149. new iEntity = gPlayerSantaHat[ id ] = engfunc( EngFunc_CreateNamedEntity, gInfoTarget );
  1150.  
  1151. if( pev_valid( iEntity ) )
  1152. {
  1153. engfunc( EngFunc_SetModel, iEntity, gSantaHatModels[ random_num( 0, charsmax( gSantaHatModels ) ) ] );
  1154.  
  1155. set_pev( iEntity, pev_movetype, MOVETYPE_FOLLOW );
  1156. set_pev( iEntity, pev_aiment, id );
  1157. set_pev( iEntity, pev_owner, id );
  1158.  
  1159. set_rendering( iEntity );
  1160. }
  1161. }
  1162.  
  1163. UTIL_DynamicLight( Float:flOrigin[ 3 ], r, g, b, a )
  1164. {
  1165. engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, flOrigin );
  1166. write_byte( TE_DLIGHT );
  1167. engfunc( EngFunc_WriteCoord, flOrigin[ 0 ] );
  1168. engfunc( EngFunc_WriteCoord, flOrigin[ 1 ] );
  1169. engfunc( EngFunc_WriteCoord, flOrigin[ 2 ] );
  1170. write_byte( 30 );
  1171. write_byte( r );
  1172. write_byte( g );
  1173. write_byte( b );
  1174. write_byte( a );
  1175. write_byte( 40 );
  1176. message_end( );
  1177. }
  1178.  
  1179. UTIL_GetAim_Origin( index, Float:flOrigin[ 3 ] )
  1180. {
  1181. new Float:flStart[ 3 ], Float:flViewOfs[ 3 ];
  1182.  
  1183. pev( index, pev_origin, flStart );
  1184. pev( index, pev_view_ofs, flViewOfs );
  1185.  
  1186. xs_vec_add( flStart, flViewOfs, flStart );
  1187.  
  1188. new Float:flDest[ 3 ];
  1189. pev( index, pev_v_angle, flDest );
  1190.  
  1191. engfunc( EngFunc_MakeVectors, flDest );
  1192. global_get( glb_v_forward, flDest );
  1193.  
  1194. xs_vec_mul_scalar( flDest, 9999.0, flDest );
  1195. xs_vec_add( flStart, flDest, flDest );
  1196.  
  1197. engfunc( EngFunc_TraceLine, flStart, flDest, 0, index, 0 );
  1198. get_tr2( 0, TR_vecEndPos, flOrigin );
  1199.  
  1200. return 1;
  1201. }
  1202.  
  1203. UTIL_ShadowStatus( const id, iStatus )
  1204. {
  1205. message_begin( MSG_ONE_UNRELIABLE, gMessageShadowIdx, _, id );
  1206. write_long( iStatus );
  1207. message_end( );
  1208. }
  1209.  
  1210. UTIL_UpdateScoreboard( id )
  1211. {
  1212. message_begin( MSG_ALL, gMessageScoreInfo );
  1213. write_byte( id );
  1214. write_short( get_user_frags( id ) );
  1215. write_short( get_user_deaths(id ) );
  1216. write_short( 0 );
  1217. write_short( get_user_team( id ) );
  1218. message_end( );
  1219. }
  1220.  
  1221. UTIL_Trail( index, iR, iG, iB, iAlpha )
  1222. {
  1223. message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  1224. write_byte( TE_BEAMFOLLOW );
  1225. write_short( index );
  1226. write_short( gTrailSprite );
  1227. write_byte( 25 );
  1228. write_byte( 5 );
  1229. write_byte( iR );
  1230. write_byte( iG );
  1231. write_byte( iB );
  1232. write_byte( iAlpha );
  1233. message_end( );
  1234. }
  1235.  
  1236. UTIL_GiveWeaponAmmo( index )
  1237. {
  1238. new szCopyAmmoData[ 40 ];
  1239.  
  1240. switch( get_user_weapon( index ) )
  1241. {
  1242. case CSW_P228: copy( szCopyAmmoData, charsmax( szCopyAmmoData ), "ammo_357sig" );
  1243. case CSW_SCOUT, CSW_G3SG1, CSW_AK47: copy( szCopyAmmoData, charsmax( szCopyAmmoData ), "ammo_762nato" );
  1244. case CSW_XM1014, CSW_M3: copy( szCopyAmmoData, charsmax( szCopyAmmoData ), "ammo_buckshot" );
  1245. case CSW_MAC10, CSW_UMP45, CSW_USP: copy( szCopyAmmoData, charsmax( szCopyAmmoData ), "ammo_45acp" );
  1246. case CSW_SG550, CSW_GALIL, CSW_FAMAS, CSW_M4A1, CSW_SG552, CSW_AUG: copy( szCopyAmmoData, charsmax( szCopyAmmoData ), "ammo_556nato" );
  1247. case CSW_ELITE, CSW_GLOCK18, CSW_MP5NAVY, CSW_TMP: copy( szCopyAmmoData, charsmax( szCopyAmmoData ), "ammo_9mm" );
  1248. case CSW_AWP: copy( szCopyAmmoData, charsmax( szCopyAmmoData ), "ammo_338magnum" );
  1249. case CSW_M249: copy( szCopyAmmoData, charsmax( szCopyAmmoData ), "ammo_556natobox" );
  1250. case CSW_FIVESEVEN, CSW_P90: copy( szCopyAmmoData, charsmax( szCopyAmmoData ), "ammo_57mm" );
  1251. case CSW_DEAGLE: copy( szCopyAmmoData, charsmax( szCopyAmmoData ), "ammo_50ae" );
  1252. }
  1253.  
  1254. give_item( index, szCopyAmmoData );
  1255. give_item( index, szCopyAmmoData );
  1256. give_item( index, szCopyAmmoData );
  1257. }
  1258.  
  1259. #if AMXX_VERSION_NUM < 183
  1260. bool:get_pdata_bool( ent, charbased_offset, intbase_linuxdiff = 5 )
  1261. {
  1262. return !!( get_pdata_int( ent, charbased_offset / INT_BYTES, intbase_linuxdiff ) & ( 0xFF << ( ( charbased_offset % INT_BYTES ) * BYTE_BITS ) ) );
  1263. }
  1264. #endif
  1265.