Advertisement
zGabriel_Aguiar

[INCLUDE]mobile.inc

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