Advertisement
Larceny

waterlib.inc

Jan 4th, 2012
993
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.22 KB | None | 0 0
  1. /**************************************************************
  2. *                      -= WaterLIB INCLUDE =-                 *
  3. *                      Is Player In Water?                    *
  4. *                                                             *
  5. *   Author:                                                   *
  6. *           Synchro                                           *
  7. *   Version:                                                  *
  8. *           1.0                                               *
  9. *   ChangeLOG:                                                *
  10. *          04/01/12:                                          *
  11. *               First version.                                *
  12. *   Description:                                              *
  13. *           This .inc includes functions to check if a player *
  14. *           is in water.                                      *
  15. ***************************************************************/
  16.  
  17. #if defined _ipiw_included
  18.     #endinput
  19. #endif
  20. #define _ipiw_included
  21.  
  22. #include a_samp
  23.  
  24. stock
  25.     IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY)
  26.     {
  27.         new Float:X, Float:Y, Float:Z;
  28.         GetPlayerPos(playerid, X, Y, Z);
  29.         if(X >= MinX && X <= MaxX && Y >= MinY && Y <= MaxY) {
  30.             return 1;
  31.         }
  32.         return 0;
  33.     }
  34.  
  35. stock
  36.     IsPlayerInWaterLocation(playerid)
  37.     {
  38.         new Float:null[2], Float:MaxZ;
  39.         GetPlayerPos(playerid, null[0], null[1], MaxZ);
  40.         /* Las Venturas */
  41.         if(IsPlayerInArea(playerid, 2044.6, 1206.358, 2192.984, 1376.552) && MaxZ < 0xA)
  42.             return 1;
  43.         else if(IsPlayerInArea(playerid, 2048.504, 1063.239, 2185.174, 1202.49) && MaxZ < 0xA)
  44.             return 1;
  45.         else if(IsPlayerInArea(playerid, 2204.698, 1426.837, 2204.698, 1430.705) && MaxZ < 0xA)
  46.             return 1;
  47.         else if(IsPlayerInArea(playerid, 2032.885, 1852.325, 2114.887, 1991.575) && MaxZ < 0xC)
  48.             return 1;
  49.         else if(IsPlayerInArea(playerid, 2517.086, 2316.493, 2606.897, 2420.93) && MaxZ < 0x16)
  50.             return 1;
  51.         else if(IsPlayerInArea(playerid, 2554.5996, 1548.6178, 2507.7683, 1588.9154) && MaxZ < 0xF)
  52.             return 1;
  53.         /* San Fierro */
  54.         else if(IsPlayerInArea(playerid, -2043.628, -980.9415, -1973.561, -724.0283) && MaxZ < 0x20)
  55.             return 1;
  56.         else if(IsPlayerInArea(playerid, -2753.912, -522.3632, -2665.071, -380.3444) && MaxZ < 0x05)
  57.             return 1;
  58.         /* Los Santos */
  59.         else if(IsPlayerInArea(playerid, 1219.864, -2435.881, 1292.118, -2325.344) && MaxZ < 0xF)
  60.             return 1;
  61.         else if(IsPlayerInArea(playerid, 1923.388, -1223.924, 2010.854, -1168.656) && MaxZ < 0x16)
  62.             return 1;
  63.         else if(IsPlayerInArea(playerid, 1269.301, -837.0452, 1314.935, -781.7769) && MaxZ < 0x5A)
  64.             return 1;
  65.         else if(IsPlayerInArea(playerid, 1087.3953, -682.6734, 1102.3138, -663.0043) && MaxZ < 0x71)
  66.             return 1;
  67.         else if(IsPlayerInArea(playerid, 1268.6118, -784.2910, 1291.8774, -764.6104) && MaxZ < 0x43D)
  68.             return 1;
  69.         /* Bounds */
  70.         else if(MaxZ < 0xF)
  71.             return 1;
  72.         return 0;
  73.     }
  74.    
  75. stock
  76.     IsPlayerUsingSwimAnim(playerid)
  77.     {
  78.         if(IsPlayerInAnyVehicle(playerid) || GetPlayerState(playerid) != PLAYER_STATE_ONFOOT)
  79.             return 0;
  80.         new
  81.             animlib[32],
  82.             animname[32];
  83.         GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
  84.         if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_GLIDE", true))
  85.             return 1;
  86.         else if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_BREAST", true))
  87.             return 1;
  88.         else if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_CRAWL", true))
  89.             return 1;
  90.         else if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_DIVE_UNDER", true))
  91.             return 1;
  92.         else if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_DIVE_GLIDE", true))
  93.             return 1;
  94.         else if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_UNDER", true))
  95.             return 1;
  96.         else if(!strcmp(animlib, "SWIM", true) && !strcmp(animname, "SWIM_TREAD", true))
  97.             return 1;
  98.         return 0;
  99.     }
  100.    
  101. stock
  102.     IsPlayerInWater(playerid)
  103.     {
  104.         if(IsPlayerInWaterLocation(playerid) && IsPlayerUsingSwimAnim(playerid))
  105.             return 1;
  106.         return 0;
  107.     }
  108.    
  109. /*
  110. native IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY)
  111. native IsPlayerInWaterLocation(playerid)
  112. native IsPlayerUsingSwimAnim(playerid)
  113. native IsPlayerInWater(playerid)
  114. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement