HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4.  
  5. #define PLUGIN_NAME "FPS Kijelzo"
  6. #define PLUGIN_VERSION "1.0"
  7. #define PLUGIN_AUTHOR "Extreme"
  8.  
  9. #pragma semicolon 1
  10.  
  11. #define DELAY_COUNT 1.0
  12. #define DELAY_COMMAND 5.0 //Késleltetés a parancs haszálatai között.
  13. #define COLOR 0x04 //Prefix Szín: 0x01 Normál, 0x04 Zöld, 0x03 Csapat szín.
  14. #define MAX_PLAYERS 32 + 1
  15.  
  16. new g_iUserFPS[MAX_PLAYERS];
  17.  
  18. new g_irFPS;
  19. new g_irFPSAll;
  20. new g_irFPSVisual;
  21.  
  22. new const C_Prefix[] = "FPS"; //Chat Prefix
  23.  
  24. public plugin_init()
  25. {
  26. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
  27. register_cvar(PLUGIN_NAME, PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY);
  28.  
  29. g_irFPS = register_cvar("cfps", "1");
  30. g_irFPSAll = register_cvar("cfpsall", "1");
  31. g_irFPSVisual = register_cvar("cfpsvisual", "1");
  32.  
  33. register_forward(FM_PlayerPreThink, "fwdPlayerPreThink");
  34.  
  35. register_clcmd("say", "sayHandle");
  36. register_clcmd("say /fps", "cmdAboutrFPS");
  37. register_clcmd("say_team /fps", "cmdAboutrFPS");
  38. }
  39.  
  40. public fwdPlayerPreThink(id)
  41. {
  42. if ( !get_pcvar_num(g_irFPS) )
  43. return FMRES_IGNORED;
  44.  
  45. static Float:fGameTime, Float:fCountNext[MAX_PLAYERS], iCountFrames[MAX_PLAYERS];
  46.  
  47. if ( fCountNext[id] >= (fGameTime = get_gametime()) )
  48. {
  49. iCountFrames[id]++;
  50.  
  51. return FMRES_IGNORED;
  52. }
  53.  
  54. g_iUserFPS[id] = iCountFrames[id];
  55. iCountFrames[id] = 0;
  56.  
  57. fCountNext[id] = fGameTime + DELAY_COUNT;
  58.  
  59. return FMRES_IGNORED;
  60. }
  61.  
  62. public sayHandle(id)
  63. {
  64. if ( !get_pcvar_num(g_irFPS) )
  65. return PLUGIN_CONTINUE;
  66.  
  67. new szArgs[64];
  68. read_args(szArgs, charsmax(szArgs));
  69. remove_quotes(szArgs);
  70. trim(szArgs);
  71.  
  72. if ( !szArgs[0] )
  73. return PLUGIN_HANDLED;
  74.  
  75. if ( szArgs[0] != '/' )
  76. return PLUGIN_CONTINUE;
  77.  
  78.  
  79. //Command
  80. new szTarget[32];
  81.  
  82. parse(szArgs,\
  83. szArgs, charsmax(szArgs),\
  84. szTarget, charsmax(szTarget));
  85.  
  86. if ( !equali(szArgs, "/fps", 4) )
  87. return PLUGIN_CONTINUE;
  88. //Command
  89.  
  90.  
  91. //Delay
  92. new Float:fCommandDelay = DELAY_COMMAND;
  93.  
  94. static Float:fCommandUsed[MAX_PLAYERS];
  95.  
  96. if ( fCommandUsed[id] > get_gametime() )
  97. {
  98. printMessage(id, id, "^x01Kérlek várj^x04 %.0f^x03 másodpercet^x01 a parancsok között!", fCommandDelay);
  99. return PLUGIN_HANDLED;
  100. }
  101. //Delay
  102.  
  103.  
  104. //Display
  105. trim(szTarget);
  106.  
  107. if ( !szTarget[0] )
  108. fCommandUsed[id] = displayFPS(id, id, fCommandDelay);
  109. else {
  110. new targetId = cmd_target(id, szTarget, 2);
  111.  
  112. if ( targetId )
  113. fCommandUsed[id] = displayFPS(id, targetId, fCommandDelay);
  114. else {
  115. printMessage(id, id, "Nem található vagy túl sok játékos található ezzel a névvel: ^x04 %s", szTarget);
  116. return PLUGIN_HANDLED;
  117. }
  118. }
  119. //Display
  120.  
  121.  
  122. return get_pcvar_num(g_irFPSVisual) ? PLUGIN_CONTINUE : PLUGIN_HANDLED;
  123. }
  124.  
  125. Float:displayFPS(id, targetId, Float:fCommandDelay)
  126. {
  127. new szName[32];
  128. get_user_name(targetId, szName, charsmax(szName));
  129.  
  130. new szMsg[192];
  131. formatex(szMsg, charsmax(szMsg), "^x03%s^x01 FPS-e:^x04 %d", szName, g_iUserFPS[targetId]);
  132.  
  133. printMessage(id, get_pcvar_num(g_irFPSAll) ? 0 : id, szMsg);
  134.  
  135. return get_gametime() + fCommandDelay;
  136. }
  137.  
  138. printMessage(id, targetId, const sMsg[], any:...)
  139. {
  140. new szMessage[192];
  141.  
  142. vformat(szMessage, charsmax(szMessage), sMsg, 4);
  143. format(szMessage, charsmax(szMessage), "%c[%s] %s", COLOR, C_Prefix, szMessage);
  144.  
  145. static iSayText;
  146.  
  147. if ( !iSayText )
  148. iSayText = get_user_msgid("SayText");
  149.  
  150. message_begin(targetId ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, iSayText, {0, 0, 0}, targetId);
  151. write_byte(id);
  152. write_string(szMessage);
  153. message_end();
  154. }
  155. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  156. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
  157. */
  158.