Advertisement
Guest User

Untitled

a guest
Nov 18th, 2020 (edited)
23
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #if defined aB_Include
  2.     #endinput
  3. #endif
  4. #define aB_Include
  5.  
  6.  
  7.  
  8. #include <a_samp>
  9. #include <YSI_Data\y_foreach>
  10.  
  11.  
  12. #define AIRBREAK_DISTANCIA  105.0
  13. #define aB_Func:%0(%1)\
  14.         forward %0(%1);public %0(%1)
  15.  
  16. enum A_B
  17. {
  18.     aB_Aguardo,
  19.     Float:aB_Pos[3],
  20.     Float:aB_SetPos[3],
  21. };
  22.  
  23. new
  24.     aB_Info[MAX_PLAYERS][A_B]
  25.     ;
  26.  
  27. aB_Func: aB_Timer(){
  28.  
  29.     new
  30.         aB_SurfVehicle,
  31.         aB_SurfObject,
  32.         aB_State,
  33.         Float:aB_AtualPos[3],
  34.         Float:aB_Range
  35.     ;
  36.  
  37.     foreach(new aB_Player : Player){
  38.  
  39.  
  40.         GetPlayerPos(aB_Player, aB_AtualPos[0], aB_AtualPos[1], aB_AtualPos[2]);
  41.  
  42.         aB_SurfVehicle  = GetPlayerSurfingVehicleID(aB_Player);
  43.         aB_SurfObject   = GetPlayerSurfingObjectID(aB_Player);
  44.         aB_State        = GetPlayerState(aB_Player);
  45.         aB_Range        = AIRBREAK_DISTANCIA;
  46.  
  47.         if(aB_State == PLAYER_STATE_DRIVER || GetPlayerPing(aB_Player) > 500){
  48.  
  49.             aB_Range += 45.0;
  50.         }
  51.  
  52.         if(aB_SurfVehicle == INVALID_VEHICLE_ID && aB_SurfObject == INVALID_OBJECT_ID && (aB_State == 1 || aB_State == 2)){
  53.  
  54.             if(!IsPlayerInRangeOfPoint(aB_Player, aB_Range, aB_Info[aB_Player][aB_Pos][0], aB_Info[aB_Player][aB_Pos][1], aB_Info[aB_Player][aB_Pos][2])
  55.             && !IsPlayerInRangeOfPoint(aB_Player, 10.0, aB_Info[aB_Player][aB_SetPos][0], aB_Info[aB_Player][aB_SetPos][1], aB_Info[aB_Player][aB_SetPos][2])){
  56.  
  57.                 if(gettime() > aB_Info[aB_Player][aB_Aguardo])CallLocalFunction("OnPlayerAirBreak", "i", aB_Player);
  58.             }
  59.         }
  60.  
  61.         aB_SavePos(aB_Player, aB_AtualPos[0], aB_AtualPos[1], aB_AtualPos[2]);
  62.     }
  63. }
  64.  
  65. stock aB_SavePos(playerid, Float:x, Float:y, Float:z){
  66.  
  67.     aB_Info[playerid][aB_Pos][0] = x;
  68.     aB_Info[playerid][aB_Pos][1] = y;
  69.     aB_Info[playerid][aB_Pos][2] = z;
  70.  
  71.     aB_Info[playerid][aB_Aguardo] = gettime() + 2;
  72. }
  73.  
  74. aB_Func: aB_SetPlayerPos(playerid, Float:x, Float:y, Float:z){
  75.  
  76.     aB_SavePos(playerid, x, y, z);
  77.  
  78.     aB_Info[playerid][aB_SetPos][0] = x;
  79.     aB_Info[playerid][aB_SetPos][1] = y;
  80.     aB_Info[playerid][aB_SetPos][2] = z;
  81.  
  82.     return SetPlayerPos(playerid, x, y, z);
  83. }
  84.  
  85. aB_Func: aB_PutPlayerInVehicle(playerid, vehicleid, seatid){
  86.  
  87.     static
  88.         Float:aB_VehiclePos[3]
  89.     ;
  90.  
  91.     GetVehiclePos(vehicleid, aB_VehiclePos[0], aB_VehiclePos[1], aB_VehiclePos[2]);
  92.  
  93.     aB_SavePos(playerid, aB_VehiclePos[0], aB_VehiclePos[1], aB_VehiclePos[2]);
  94.  
  95.     aB_Info[playerid][aB_SetPos][0] = aB_VehiclePos[0];
  96.     aB_Info[playerid][aB_SetPos][1] = aB_VehiclePos[1];
  97.     aB_Info[playerid][aB_SetPos][2] = aB_VehiclePos[2];
  98.  
  99.     return PutPlayerInVehicle(playerid, vehicleid, seatid);
  100. }
  101.  
  102.  
  103.  
  104. public OnGameModeInit(){
  105.  
  106.     SetTimer("aB_Timer", 1000, 1);
  107.  
  108.     return CallLocalFunction("aB_OnGameModeInit", #);
  109. }
  110. forward aB_OnGameModeInit();
  111. #if defined _ALS_OnGameModeInit
  112.     #undef OnGameModeInit
  113. #else
  114.     #define _ALS_OnGameModeInit
  115. #endif
  116. #define OnGameModeInit aB_OnGameModeInit
  117.  
  118.  
  119.  
  120. public OnPlayerSpawn(playerid){
  121.  
  122.     aB_Info[playerid][aB_Aguardo] = gettime() + 4;
  123.  
  124.     return CallLocalFunction("aB_OnPlayerSpawn", "i", playerid);
  125. }
  126. forward aB_OnPlayerSpawn(playerid);
  127. #if defined _ALS_OnPlayerSpawn
  128.     #undef OnPlayerSpawn
  129. #else
  130.     #define _ALS_OnPlayerSpawn
  131. #endif
  132. #define OnPlayerSpawn aB_OnPlayerSpawn
  133.  
  134.  
  135. #if defined _ALS_SetPlayerPos
  136.     #undef SetPlayerPos
  137. #else
  138.     #define _ALS_SetPlayerPos
  139. #endif
  140.  
  141. #if defined _ALS_PutPlayerInVehicle
  142.     #undef PutPlayerInVehicle
  143. #else
  144.     #define _ALS_PutPlayerInVehicle
  145. #endif
  146.  
  147. #define SetPlayerPos            aB_SetPlayerPos
  148. #define PutPlayerInVehicle      aB_PutPlayerInVehicle
  149.  
  150. forward OnPlayerAirBreak(playerid);
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement