HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <cstrike>
  3. #include <fakemeta>
  4.  
  5. new const PLUGIN[] = "No Shield"
  6. #define VERSION "0.2.1"
  7. new const AUTHOR[] = "ConnorMcLeod"
  8.  
  9. new const shield[] = "shield"
  10.  
  11. new g_iTextMsg
  12.  
  13. const m_iMenuCode = 205
  14.  
  15. #define cs_get_user_menu(%0) get_pdata_int(%0, m_iMenuCode)
  16. #define cs_set_user_menu(%0,%1) set_pdata_int(%0, m_iMenuCode, %1)
  17. #define Menu_BuyItem 10
  18.  
  19. public plugin_precache()
  20. {
  21. if( !CheckGamePlayerEquip() )
  22. {
  23. register_plugin(PLUGIN, VERSION, AUTHOR)
  24. register_forward(FM_PrecacheModel, "PrecacheModel")
  25. }
  26. else
  27. {
  28. register_plugin("No Shield (Auto-Disabled)", VERSION, AUTHOR)
  29. pause("a")
  30. }
  31. }
  32.  
  33. public plugin_init()
  34. {
  35. g_iTextMsg = get_user_msgid("TextMsg")
  36.  
  37. register_clcmd("menuselect 8", "ClCmd_MenuSelect_8")
  38. }
  39.  
  40. public plugin_cfg()
  41. {
  42. server_cmd("amx_pausecfg add %s", PLUGIN)
  43. }
  44.  
  45. CheckGamePlayerEquip()
  46. {
  47. new szMapFile[64]
  48. get_mapname(szMapFile, charsmax(szMapFile))
  49. format(szMapFile, charsmax(szMapFile), "maps/%s.bsp", szMapFile)
  50.  
  51. new szBuffer[64], szKey[16], szValue[32]
  52. new bool:bInEntityDatas, bool:bIsPlayerEquip, bool:bHasShield
  53. new fp = fopen(szMapFile, "rb")
  54. if( !fp )
  55. {
  56. return 0 // default map oO
  57. }
  58.  
  59. new iOffset, iLength, iMaxPos
  60. fseek(fp, 4, SEEK_SET)
  61. fread(fp, iOffset, BLOCK_INT)
  62. fread(fp, iLength, BLOCK_INT)
  63. iMaxPos = iOffset + iLength
  64. fseek(fp, iOffset, SEEK_SET)
  65.  
  66. while( ftell(fp) < iMaxPos )
  67. {
  68. fgets(fp, szBuffer, charsmax(szBuffer))
  69. trim(szBuffer)
  70.  
  71. if( bInEntityDatas )
  72. {
  73. if( szBuffer[0] == '}' )
  74. {
  75. if( bIsPlayerEquip && bHasShield )
  76. {
  77. break
  78. }
  79. }
  80. else
  81. {
  82. parse(szBuffer, szKey, charsmax(szKey), szValue, charsmax(szValue))
  83. if( equal(szKey, "classname") )
  84. {
  85. bIsPlayerEquip = !!equal(szValue, "game_player_equip")
  86. }
  87. else if( equal(szKey, "weapon_shield") )
  88. {
  89. bHasShield = !!equal(szValue, "1")
  90. }
  91. }
  92. }
  93. else if( szBuffer[0] == '{' )
  94. {
  95. bInEntityDatas = true
  96. bIsPlayerEquip = false
  97. bHasShield = false
  98. }
  99. }
  100. fclose(fp)
  101.  
  102. return ( bIsPlayerEquip && bHasShield )
  103. }
  104.  
  105. public PrecacheModel(const szModel[])
  106. {
  107. if( containi(szModel, shield) != -1 )
  108. {
  109. forward_return(FMV_CELL, 0)
  110. return FMRES_SUPERCEDE
  111. }
  112. return FMRES_IGNORED
  113. }
  114.  
  115. public ClCmd_MenuSelect_8( id )
  116. {
  117. if( is_user_alive(id) && cs_get_user_menu(id) == Menu_BuyItem && cs_get_user_team(id) == CS_TEAM_CT )
  118. {
  119. new iOldMenu, iNewMenu
  120. player_menu_info(id, iOldMenu, iNewMenu)
  121. if( iNewMenu != -1 || iOldMenu > 0 ) // no check against BuyMenus because amxx menu system is too global.
  122. {
  123. cs_set_user_menu(id, 0)
  124. }
  125. else
  126. {
  127. Message_No_Shield(id)
  128. return PLUGIN_HANDLED
  129. }
  130. }
  131. return PLUGIN_CONTINUE
  132. }
  133.  
  134. public client_command(id)
  135. {
  136. static szCommand[8] // shield
  137.  
  138. if( read_argv(0, szCommand, charsmax(szCommand)) == 6 && equali(szCommand, shield) )
  139. {
  140. Message_No_Shield(id)
  141. return PLUGIN_HANDLED
  142. }
  143. return PLUGIN_CONTINUE
  144. }
  145.  
  146. public CS_InternalCommand(id, const szCommand[])
  147. {
  148. if( equali(szCommand, shield) )
  149. {
  150. Message_No_Shield(id)
  151. return PLUGIN_HANDLED
  152. }
  153. return PLUGIN_CONTINUE
  154. }
  155.  
  156. Message_No_Shield(id)
  157. {
  158. message_begin(MSG_ONE_UNRELIABLE, g_iTextMsg, .player=id)
  159. write_byte( print_center )
  160. write_string( "#Weapon_Not_Available" )
  161. write_string( "#TactShield" )
  162. message_end()
  163. }