Advertisement
Guest User

In-Game FPS Textdraw

a guest
Feb 6th, 2015
1,760
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1.  
  2. #include <a_samp>
  3.  
  4. new fpsON[MAX_PLAYERS];
  5. new TimerFPS;
  6. new pDrunkLevelLast[MAX_PLAYERS];
  7. new pFPS[MAX_PLAYERS];
  8. new Text:FPS[MAX_PLAYERS];
  9. forward RefreshFPS(playerid);
  10.  
  11. public OnFilterScriptInit()
  12. {
  13. print("In-Game FPS by SkillNasr");
  14. return 1;
  15. }
  16.  
  17. public OnFilterScriptExit()
  18. {
  19. return 1;
  20. }
  21.  
  22. public OnPlayerConnect(playerid)
  23. {
  24. /* Crea la TextDraw */
  25. FPS[playerid] = TextDrawCreate(596.000000, 0.000000, "_");
  26. TextDrawBackgroundColor(FPS[playerid], 255);
  27. TextDrawFont(FPS[playerid], 3);
  28. TextDrawLetterSize(FPS[playerid], 0.669999, 1.900000);
  29. TextDrawColor(FPS[playerid], -65281);
  30. TextDrawSetOutline(FPS[playerid], 0);
  31. TextDrawSetProportional(FPS[playerid], 1);
  32. TextDrawSetShadow(FPS[playerid], 1);
  33. fpsON[playerid] = 0;
  34. /**/
  35. return 1;
  36. }
  37.  
  38. public OnPlayerDisconnect(playerid, reason)
  39. {
  40. fpsON[playerid] = 0;
  41. return 1;
  42. }
  43.  
  44. public OnPlayerCommandText(playerid, cmdtext[])
  45. {
  46. if(!strcmp(cmdtext, "/fps", true))
  47. {
  48. if(fpsON[playerid] == 0)
  49. {
  50. PlayerPlaySound(playerid,1054,0.0,0.0,0.0),
  51. TimerFPS = SetTimerEx("RefreshFPS", 500, true, "i",playerid);
  52. fpsON[playerid] = 1;
  53. }
  54. else if(fpsON[playerid] == 1)
  55. {
  56. PlayerPlaySound(playerid,1054,0.0,0.0,0.0),
  57. KillTimer(TimerFPS);
  58. fpsON[playerid] = 0;
  59. TextDrawHideForPlayer(playerid, FPS[playerid]);
  60. }
  61. return 1;
  62. }
  63. return 0;
  64. }
  65.  
  66. public OnPlayerUpdate(playerid)
  67. {
  68.  
  69. new drunknew;
  70. drunknew = GetPlayerDrunkLevel(playerid);
  71.  
  72. if (drunknew < 100) {
  73. SetPlayerDrunkLevel(playerid, 2000);
  74. } else {
  75.  
  76. if (pDrunkLevelLast[playerid] != drunknew) {
  77.  
  78. new wfps = pDrunkLevelLast[playerid] - drunknew;
  79.  
  80. if ((wfps > 0) && (wfps < 200))
  81. pFPS[playerid] = wfps;
  82.  
  83. pDrunkLevelLast[playerid] = drunknew;
  84. }
  85.  
  86. }
  87. return 1;
  88. }
  89.  
  90. public RefreshFPS(playerid)
  91. {
  92. new string[128];
  93. format(string, sizeof(string), "%i",pFPS[playerid]);
  94. TextDrawSetString(FPS[playerid], string);
  95. TextDrawShowForPlayer(playerid, FPS[playerid]);
  96. return 1;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement