Advertisement
Guest User

wifi.pwn

a guest
May 5th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.33 KB | None | 0 0
  1. //Made by lokii.
  2.  
  3. //credits to adri1 for his text draw editor, pottus - for optimising the script and gammix for helping with text draw.
  4.  
  5. #include <a_samp> //credits to sa-mp team
  6.  
  7. #define PING_LEVEL_UPDATE -1
  8. #define PING_LEVEL_1 0
  9. #define PING_LEVEL_2 1
  10. #define PING_LEVEL_3 2
  11. #define PING_LEVEL_4 3
  12. #define PING_LEVEL_5 4
  13.  
  14. static PingLevel[MAX_PLAYERS] = { -1, ...};
  15.  
  16. static Text:WifiBox;
  17. static Text:Bar1;
  18. static Text:Bar2;
  19. static Text:Bar3;
  20. static Text:Bar4;
  21. static Text:Bar5;
  22. static timer;
  23.  
  24. static PingLevelColors[][5] = {
  25. { 0x00DD00FF, 0x00DD00FF, 0x00DD00FF, 0x00DD00FF, 0x00DD00FF },
  26. { 0x00DD00FF, 0x00DD00FF, 0x00DD00FF, 0x00DD00FF, 0xC0C0C0FF },
  27. { 0xFDEB11FF, 0xFDEB11FF, 0xFDEB11FF, 0xC0C0C0FF , 0xC0C0C0FF },
  28. { 0xFF5959FF, 0xFF5959FF, 0xC0C0C0FF , 0xC0C0C0FF , 0xC0C0C0FF },
  29. { 0xFF0000FF, 0xC0C0C0FF , 0xC0C0C0FF , 0xC0C0C0FF , 0xC0C0C0FF }
  30. };
  31.  
  32. public OnFilterScriptInit()
  33. {
  34. timer = SetTimer("WifiCheck", 1000, true);
  35. WifiBox = TextDrawCreate(5.333310, 421.941436, "box");
  36. TextDrawLetterSize(WifiBox, 0.000000, 2.248336);
  37. TextDrawTextSize(WifiBox, 24.349935, 0.000000);
  38. TextDrawAlignment(WifiBox, 1);
  39. TextDrawColor(WifiBox, -1);
  40. TextDrawUseBox(WifiBox, 1);
  41. TextDrawBoxColor(WifiBox, 102);
  42. TextDrawSetShadow(WifiBox, 0);
  43. TextDrawBackgroundColor(WifiBox, 255);
  44. TextDrawFont(WifiBox, 1);
  45. TextDrawSetProportional(WifiBox, 1);
  46. Bar1 = TextDrawCreate(9.466705, 437.567565, "box");
  47. TextDrawLetterSize(Bar1, 0.000000, 0.358998);
  48. TextDrawTextSize(Bar1, 4.729997, 0.000000);
  49. TextDrawAlignment(Bar1, 1);
  50. TextDrawColor(Bar1, -1061109505);
  51. TextDrawUseBox(Bar1, 1);
  52. TextDrawBoxColor(Bar1, -1061109505);
  53. TextDrawSetShadow(Bar1, 0);
  54. TextDrawBackgroundColor(Bar1, 255);
  55. TextDrawFont(Bar1, 1);
  56. TextDrawSetProportional(Bar1, 1);
  57. Bar2 = TextDrawCreate(13.066704, 435.167541, "box");
  58. TextDrawLetterSize(Bar2, 0.000000, 0.637996);
  59. TextDrawTextSize(Bar2, 8.329997, 0.000000);
  60. TextDrawAlignment(Bar2, 1);
  61. TextDrawColor(Bar2, -1061109505);
  62. TextDrawUseBox(Bar2, 1);
  63. TextDrawBoxColor(Bar2, -1061109505);
  64. TextDrawSetShadow(Bar2, 0);
  65. TextDrawBackgroundColor(Bar2, 255);
  66. TextDrawFont(Bar2, 1);
  67. TextDrawSetProportional(Bar2, 1);
  68. Bar3 = TextDrawCreate(17.066711, 433.267425, "box");
  69. TextDrawLetterSize(Bar3, 0.000000, 0.885999);
  70. TextDrawTextSize(Bar3, 12.329998, 0.000000);
  71. TextDrawAlignment(Bar3, 1);
  72. TextDrawColor(Bar3, -1061109505);
  73. TextDrawUseBox(Bar3, 1);
  74. TextDrawBoxColor(Bar3, -1061109505);
  75. TextDrawSetShadow(Bar3, 0);
  76. TextDrawBackgroundColor(Bar3, 255);
  77. TextDrawFont(Bar3, 1);
  78. TextDrawSetProportional(Bar3, 1);
  79. Bar4 = TextDrawCreate(20.966726, 430.467254, "box");
  80. TextDrawLetterSize(Bar4, 0.000000, 1.195999);
  81. TextDrawTextSize(Bar4, 16.230014, 0.000000);
  82. TextDrawAlignment(Bar4, 1);
  83. TextDrawColor(Bar4, -1061109505);
  84. TextDrawUseBox(Bar4, 1);
  85. TextDrawBoxColor(Bar4, -1061109505);
  86. TextDrawSetShadow(Bar4, 0);
  87. TextDrawBackgroundColor(Bar4, 255);
  88. TextDrawFont(Bar4, 1);
  89. TextDrawSetProportional(Bar4, 1);
  90. Bar5 = TextDrawCreate(24.966741, 428.567138, "box");
  91. TextDrawLetterSize(Bar5, 0.000000, 1.443999);
  92. TextDrawTextSize(Bar5, 20.230030, 0.000000);
  93. TextDrawAlignment(Bar5, 1);
  94. TextDrawColor(Bar5, -1061109505);
  95. TextDrawUseBox(Bar5, 1);
  96. TextDrawBoxColor(Bar5, -1061109505);
  97. TextDrawSetShadow(Bar5, 0);
  98. TextDrawBackgroundColor(Bar5, 255);
  99. TextDrawFont(Bar5, 1);
  100. TextDrawSetProportional(Bar5, 1);
  101. for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
  102. {
  103. if(!IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
  104. TextDrawShowForPlayer(i, WifiBox);
  105. }
  106. return 1;
  107. }
  108.  
  109. public OnPlayerConnect(playerid)
  110. {
  111. TextDrawShowForPlayer(playerid, WifiBox);
  112. return 1;
  113. }
  114.  
  115. public OnFilterScriptExit()
  116. {
  117. KillTimer(timer);
  118. TextDrawDestroy(WifiBox);
  119. TextDrawDestroy(Bar1);
  120. TextDrawDestroy(Bar2);
  121. TextDrawDestroy(Bar3);
  122. TextDrawDestroy(Bar4);
  123. TextDrawDestroy(Bar5);
  124. return 1;
  125. }
  126.  
  127. public OnPlayerDisconnect(playerid)
  128. {
  129. PingLevel[playerid] = PING_LEVEL_UPDATE;
  130. return 1;
  131. }
  132.  
  133. forward WifiCheck();
  134.  
  135. public WifiCheck()
  136. {
  137. for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
  138. {
  139. if(!IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
  140.  
  141. else if(GetPlayerPing(i) >= 0 && GetPlayerPing(i) < 201 && PingLevel[i] != PING_LEVEL_1)
  142. {
  143. PingLevel[i] = PING_LEVEL_1;
  144.  
  145. UpdateConnectionStatus(i, PING_LEVEL_1);
  146. }
  147. else if(GetPlayerPing(i) >= 201 && GetPlayerPing(i) < 401 && PingLevel[i] != PING_LEVEL_2)
  148. {
  149. PingLevel[i] = PING_LEVEL_2;
  150. UpdateConnectionStatus(i, PING_LEVEL_2);
  151. }
  152.  
  153. else if(GetPlayerPing(i) >= 401 && GetPlayerPing(i) < 551 && PingLevel[i] != PING_LEVEL_3)
  154. {
  155. PingLevel[i] = PING_LEVEL_3;
  156. UpdateConnectionStatus(i, PING_LEVEL_3);
  157. }
  158. else if(GetPlayerPing(i) >= 551 && GetPlayerPing(i) < 701 && PingLevel[i] != PING_LEVEL_4)
  159. {
  160. PingLevel[i] = PING_LEVEL_4;
  161. UpdateConnectionStatus(i, PING_LEVEL_4);
  162. }
  163. else if(GetPlayerPing(i) > 700 && PingLevel[i] != PING_LEVEL_5)
  164. {
  165. PingLevel[i] = PING_LEVEL_5;
  166. UpdateConnectionStatus(i, PING_LEVEL_5);
  167. }
  168. }
  169. return 1;
  170. }
  171.  
  172. static UpdateConnectionStatus(playerid, level)
  173. {
  174.  
  175. TextDrawHideForPlayer(playerid, Bar1);
  176. TextDrawHideForPlayer(playerid, Bar2);
  177. TextDrawHideForPlayer(playerid, Bar3);
  178. TextDrawHideForPlayer(playerid, Bar4);
  179. TextDrawHideForPlayer(playerid, Bar5);
  180. TextDrawBoxColor(Bar1, PingLevelColors[level][0]);
  181. TextDrawBoxColor(Bar2, PingLevelColors[level][1]);
  182. TextDrawBoxColor(Bar3, PingLevelColors[level][2]);
  183. TextDrawBoxColor(Bar4, PingLevelColors[level][3]);
  184. TextDrawBoxColor(Bar5, PingLevelColors[level][4]);
  185. TextDrawShowForPlayer(playerid, Bar1);
  186. TextDrawShowForPlayer(playerid, Bar2);
  187. TextDrawShowForPlayer(playerid, Bar3);
  188. TextDrawShowForPlayer(playerid, Bar4);
  189. TextDrawShowForPlayer(playerid, Bar5);
  190. return 1;
  191. }
  192.  
  193.  
  194. //EOF.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement