Advertisement
Shanidzee

Untitled

Feb 7th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. /// es unda chavardes satamasho modshi!
  2. forward OnPlayerFinishDownloading(playerid, datamb);
  3. public OnPlayerFinishDownloading(playerid, datamb)
  4. {
  5. /*SendClientMessage(playerid, 1, "{00FF33}You have completely downloaded all files.");
  6. new String[256];
  7. format(String, 256, "{FFFFFF}Downloaded: {00FF33}%0.2f {FFFFFF}MBs of Data.", datamb);
  8. SendClientMessage(playerid, 1, String);*/
  9. // Put whatever you want
  10. return 1;
  11. }
  12.  
  13. //////////////////////////////////////////////////////////////////////////////////
  14.  
  15. #include <a_samp>
  16.  
  17. new Downloaded[MAX_PLAYERS];
  18. new PlayerTick[MAX_PLAYERS];
  19.  
  20. stock GetTickDiff(newtick, oldtick)
  21. {
  22. if (oldtick < 0 && newtick >= 0) {
  23. return newtick - oldtick;
  24. } else if (oldtick >= 0 && newtick < 0 || oldtick > newtick) {
  25. return (cellmax - oldtick + 1) - (cellmin - newtick);
  26. }
  27. return newtick - oldtick;
  28. }
  29.  
  30. public OnFilterScriptInit()
  31. {
  32. print("\n--------------------------------------");
  33. print(" Download Meter SA-MP 0.3.DL");
  34. print("--------------------------------------\n");
  35. return 1;
  36. }
  37.  
  38. public OnPlayerConnect(playerid)
  39. {
  40. Downloaded[playerid] = 0;
  41. PlayerTick[playerid] = GetTickCount();
  42. return 1;
  43. }
  44.  
  45. public OnPlayerFinishedDownloading(playerid, virtualworld)
  46. {
  47. if(Downloaded[playerid] == 1) return 1;
  48. if(GetTickDiff(GetTickCount(), PlayerTick[playerid]) > 1000)
  49. {
  50. Downloaded[playerid] = 1;
  51. new Float: bytesOfPlayer = NetStats_BytesSent(playerid);
  52. new Float: Megabytes = bytesOfPlayer / 1024 / 1024;
  53. CallRemoteFunction("OnPlayerFinishDownloading", "df", playerid, Megabytes);
  54. }
  55. else
  56. {
  57. Downloaded[playerid] = 1;
  58. // Player changed virtual worlds
  59. }
  60. return 1;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement