krishhna

FPS

May 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3. #include <sscanf2>
  4. #include <foreach>
  5.  
  6.  
  7. new pDrunkLevelLast[MAX_PLAYERS];
  8. new pFPS[MAX_PLAYERS];
  9.  
  10. public OnPlayerConnect(playerid)
  11. {
  12. pDrunkLevelLast[playerid] = 0;
  13. pFPS[playerid] = 0;
  14. return 1;
  15. }
  16.  
  17. public OnPlayerCommandText(playerid, cmdtext[])
  18. {
  19. new index,cmd[20];
  20. cmd = strtok(cmdtext, index);
  21.  
  22. if (strcmp(cmd, "/getfps", true) == 0)
  23. {
  24. new tmp[20],str[256],pName[256];
  25. tmp = strtok(cmdtext, index);
  26. if(!strlen(tmp)) return SendClientMessage(playerid, -1, "{ED0C0C}Usage : {FFFFFF}/getfps [ID]");
  27. if(!IsPlayerConnected(strval(tmp))) return SendClientMessage(playerid, -1, "Player not found.");
  28. GetPlayerName(strval(tmp),pName,25);
  29. format(str,256,"{FF0000}Fps of %s(%d) is : {FFFFFF}%d",pName,strval(tmp),pFPS[strval(tmp)]);
  30. SendClientMessage(playerid,-1,str);
  31. return 1;
  32. }
  33. return 0;
  34. }
  35.  
  36. public OnPlayerUpdate(playerid)
  37. {
  38. new drunknew;
  39. drunknew = GetPlayerDrunkLevel(playerid);
  40.  
  41. if (drunknew < 100)
  42. {
  43. SetPlayerDrunkLevel(playerid, 2000);
  44. }
  45. else
  46. {
  47. if (pDrunkLevelLast[playerid] != drunknew)
  48. {
  49. new wfps = pDrunkLevelLast[playerid] - drunknew;
  50. if ((wfps > 0) && (wfps < 200))
  51. pFPS[playerid] = wfps;
  52. pDrunkLevelLast[playerid] = drunknew;
  53. }
  54.  
  55. }
  56. return 1;
  57. }
  58.  
  59. strtok(const string[], &index)
  60. {
  61. new length = strlen(string);
  62. while ((index < length) && (string[index] <= ' '))
  63. {
  64. index++;
  65. }
  66.  
  67. new offset = index;
  68. new result[20];
  69. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  70. {
  71. result[index - offset] = string[index];
  72. index++;
  73. }
  74. result[index - offset] = EOS;
  75. return result;
  76. }
Add Comment
Please, Sign In to add comment