Guest User

SantaHat.sma

a guest
May 15th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. #include < amxmodx >
  2. #include < engine >
  3. #include < cstrike >
  4. #include < hamsandwich >
  5.  
  6. new const g_szHatModel[ CsTeams ][ ] = {
  7. "",
  8. "models/devil2.mdl",
  9. "models/angel2.mdl",
  10. ""
  11. };
  12.  
  13. new g_iHats[ 33 ];
  14.  
  15. public plugin_init( ) {
  16. register_plugin( "Santa Hat + Snow", "1.3", "xPaw" );
  17.  
  18. register_cvar( "santa_hat", "1.3", FCVAR_SERVER );
  19.  
  20. register_event( "TeamInfo", "EventTeamInfo", "a" );
  21.  
  22. RegisterHam( Ham_Spawn, "player", "FwdHamPlayerSpawn", 1 );
  23. }
  24.  
  25. public plugin_precache( ) {
  26. // create_entity( "env_snow" );
  27.  
  28. precache_model( g_szHatModel[ CS_TEAM_T ] );
  29. precache_model( g_szHatModel[ CS_TEAM_CT ] );
  30. }
  31.  
  32. public client_disconnect( id )
  33. if( is_valid_ent( g_iHats[ id ] ) )
  34. remove_entity( g_iHats[ id ] );
  35.  
  36. public FwdHamPlayerSpawn( const id ) {
  37. if(get_user_flags(id) & ADMIN_LEVEL_A) {
  38. if( is_user_alive( id ) ) {
  39. new iEntity = g_iHats[ id ];
  40.  
  41. if( !is_valid_ent( iEntity ) ) {
  42. if( !( iEntity = g_iHats[ id ] = create_entity( "info_target" ) ) )
  43. return;
  44.  
  45. new CsTeams:iTeam = cs_get_user_team( id );
  46.  
  47. if( iTeam != CS_TEAM_T && iTeam != CS_TEAM_CT )
  48. iTeam = CS_TEAM_T;
  49.  
  50. entity_set_model( iEntity, g_szHatModel[ iTeam ] );
  51. entity_set_int( iEntity, EV_INT_movetype, MOVETYPE_FOLLOW );
  52. entity_set_edict( iEntity, EV_ENT_aiment, id );
  53. }
  54. }
  55. }
  56. }
  57.  
  58. public EventTeamInfo( ) {
  59. new id = read_data( 1 ), iEntity = g_iHats[ id ];
  60.  
  61. if( !is_valid_ent( iEntity ) ) {
  62. if( iEntity > 0 )
  63. g_iHats[ id ] = 0;
  64.  
  65. return;
  66. }
  67.  
  68. new szTeam[ 2 ];
  69. read_data( 2, szTeam, 1 );
  70.  
  71. if( szTeam[ 0 ] == 'C' )
  72. entity_set_model( iEntity, g_szHatModel[ CS_TEAM_CT ] );
  73. else
  74. entity_set_model( iEntity, g_szHatModel[ CS_TEAM_T ] );
  75. }
Advertisement
Add Comment
Please, Sign In to add comment