Advertisement
Guest User

mobile.inc

a guest
Mar 13th, 2021
3,014
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. //Mobile include by Jekmant
  2.  
  3. /*
  4. ATTENTION! Include require "Pawn.RakNet" plugin version "1.4.1" or higher!
  5.  
  6. Functions:
  7. bool:IsPlayerMobile(playerid) - check player platform type. Returns "true" if founded mobile platform
  8. bool:IsPlayerHaveAutoaim(playerid) - check player autoaiming. Returns "true" if autoaming enabled
  9. */
  10.  
  11. #if defined _mobile_included
  12. #endinput
  13. #endif
  14. #define _mobile_included
  15.  
  16. #tryinclude <a_samp>
  17. #include <Pawn.RakNet>
  18.  
  19. #if !defined gpci
  20. native gpci(playerid, buffer[], size = sizeof(buffer));
  21. #endif
  22.  
  23. #define MIN_PACKET_SIZE 3
  24. #define MOBILE_AUTH_KEY "ED40ED0E8089CC44C08EE9580F4C8C44EE8EE990"
  25. const ID_CUSTOM_SYNC = 221;
  26. const RPC_INIT_MOBILE = 0x10;
  27.  
  28. enum pMobileInfo
  29. {
  30. bool:isMobile,
  31. bool:isHaveAutoaim
  32. }
  33. new PlayerMobileInfo[[MAX_PLAYERS][pMobileInfo];
  34.  
  35. public OnPlayerConnect(playerid)
  36. {
  37. new gpciStr[64];
  38. gpci(playerid, gpciStr, sizeof gpciStr);
  39. if(!strcmp(gpciStr, MOBILE_AUTH_KEY)) // system for older version, will be deprecated
  40. PlayerMobileInfo[playerid][isMobile] = true;
  41. else
  42. PlayerMobileInfo[playerid][isMobile] = false;
  43.  
  44. #if defined mob_OnPlayerConnect
  45. return mob_OnPlayerConnect(playerid);
  46. #else
  47. return 1;
  48. #endif
  49. }
  50. #if defined _ALS_OnPlayerConnect
  51. #undef OnPlayerConnect
  52. #else
  53. #define _ALS_OnPlayerConnect
  54. #endif
  55. #define OnPlayerConnect mob_OnPlayerConnect
  56. #if defined mob_OnPlayerConnect
  57. forward mob_OnPlayerConnect(playerid);
  58. #endif
  59.  
  60. public OnPlayerDisconnect(playerid, reason)
  61. {
  62. PlayerMobileInfo[playerid][isMobile] = false;
  63. PlayerMobileInfo[playerid][[isHaveAutoaim] = false;
  64.  
  65. #if defined mob_OnPlayerDisconnect
  66. return mob_OnPlayerDisconnect(playerid, reason);
  67. #else
  68. return 1;
  69. #endif
  70. }
  71. #if defined _ALS_OnPlayerDisconnect
  72. #undef OnPlayerDisconnect
  73. #else
  74. #define _ALS_OnPlayerDisconnect
  75. #endif
  76. #define OnPlayerDisconnect mob_OnPlayerDisconnect
  77. #if defined mob_OnPlayerDisconnect
  78. forward mob_OnPlayerDisconnect(playerid, reason);
  79. #endif
  80.  
  81. IRawPacket:ID_CUSTOM_SYNC(playerid, BitStream:bs)
  82. {
  83. new bytes, rpcid;
  84. BS_GetNumberOfBytesUsed(bs, bytes);
  85. if(bytes < MIN_PACKET_SIZE) return 0;
  86.  
  87. BS_ReadValue(bs,
  88. PR_IGNORE_BITS, 8,
  89. PR_UINT8, rpcid);
  90.  
  91. if(rpcid == RPC_INIT_MOBILE)
  92. {
  93. new autoaim;
  94. BS_ReadValue(bs, PR_UINT8, autoaim);
  95.  
  96. PlayerMobileInfo[playerid][isMobile] = true; // system for newer version
  97. PlayerMobileInfo[playerid][isHaveAutoaim] = bool:autoaim;
  98. }
  99. return 1;
  100. }
  101.  
  102. stock bool:IsPlayerMobile(playerid)
  103. {
  104. return PlayerMobileInfo[playerid][isMobile];
  105. }
  106.  
  107. stock bool:IsPlayerHaveAutoaim(playerid)
  108. {
  109. return PlayerMobileInfo[playerid][isHaveAutoaim];
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement