Guest User

Random Functions V1 by King_Hual

a guest
Jul 2nd, 2012
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.89 KB | None | 0 0
  1. #if defined _hfunc_included
  2.         #endinput
  3. #endif
  4. #define _hfunc_included
  5.  
  6. #if !defined _samp_included
  7.         #tryinclude <a_samp>
  8.         #if !defined _samp_included
  9.                 #error could not locate a_samp.inc file, please check your server includes
  10.         #endif
  11. #endif
  12.  
  13. #define MAX_CELLS 256
  14.  
  15. stock bool:IsPlayerSwimming(playerid)
  16. {
  17.     new animlib[1], animname[32];
  18.     if(GetPlayerAnimationIndex(playerid))
  19.     {
  20.         GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,0,animname,32);
  21.         if(!strcmp(animname, "SWIM_CRAWL") || !strcmp(animname, "SWIM_BREAST") || !strcmp(animname, "SWIM_GLIDE") || !strcmp(animname, "SWIM_DIVE_UNDER") || !strcmp(animname, "SWIM_UNDER"))
  22.         {
  23.             return true;
  24.         }
  25.         return false;
  26.     }
  27.     return false;
  28. }
  29. stock bool:IsPlayerFalling(playerid)
  30. {
  31.     new animlib[1], animname[32];
  32.     if(GetPlayerAnimationIndex(playerid))
  33.     {
  34.         GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,0,animname,32);
  35.         if(!strcmp(animname, "FALL_FALL") || !strcmp(animname, "FALL_GLIDE"))
  36.         {
  37.             return true;
  38.         }
  39.         return false;
  40.     }
  41.     return false;
  42. }
  43. stock strrev(string[], len)
  44. {
  45.     new str[MAX_CELLS];
  46.     for(new i=strlen(string); i>=0; i--)
  47.     {
  48.         format(str, len+2, "%s%c", str, string[i]);
  49.     }
  50.     return str;
  51. }
  52. stock substr(string[], index, len)
  53. {
  54.     new str[MAX_CELLS];
  55.     for(new i=index; i<=index+len; i++)
  56.     {
  57.         format(str, len+1, "%s%c", str, string[i]);
  58.     }
  59.     return str;
  60. }
  61. stock RandomEx(min, max)
  62. {
  63.     return random(max-min)+min;
  64. }
  65. stock Float:fRandom(Float:max)
  66. {
  67.     return max*random(32768)/32768.0;
  68. }
  69. stock Float:fRandomEx(Float:min, Float:max)
  70. {
  71.     return min+(max - min)*random(32768)/32768.0;
  72. }
  73. stock Float:RotationToPoint(playerid, Float:x, Float:y)
  74. {
  75.         new Float:pX, Float:pY, Float:pZ;
  76.         GetPlayerPos(playerid, pX, pY, pZ);
  77.         return atan2((x+3000) - (pX+3000), (y+3000) - (pY+3000))*-1;
  78. }
  79. stock Float:RotationToPlayer(playerid, tplayerid)
  80. {
  81.         new Float:pX, Float:pY, Float:pX1, Float:pY1, Float:Useless;
  82.         GetPlayerPos(playerid, pX, pY, Useless);
  83.         GetPlayerPos(tplayerid, pX1, pY1, Useless);
  84.         return atan2((pX1+3000) - (pX+3000), (pY1+3000) - (pY+3000))*-1;
  85. }
  86. stock Float:RotationToVehicle(playerid, vehicleid)
  87. {
  88.         new Float:pX, Float:pY, Float:vX, Float:vY, Float:Useless;
  89.         GetPlayerPos(playerid, pX, pY, Useless);
  90.         GetVehiclePos(vehicleid, vX, vY, Useless);
  91.         return atan2((vX+3000) - (pX+3000), (vY+3000) - (pY+3000))*-1;
  92. }
  93. stock FormatInt(number, delimiter)
  94. {
  95.     new num[12], count = -1, result[16];
  96.     format(num, sizeof(num), "%i", number);
  97.     for(new x = strlen(num)-1; x >= 0; x--) {
  98.         if(count == 2) {
  99.                 format(result, sizeof(result), "%c%c%s", num[x], delimiter, result);
  100.                 count = 0;
  101.         }
  102.         else {
  103.             format(result, sizeof(result), "%c%s", num[x], result);
  104.             count++;
  105.         }
  106.     }
  107.     return result;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment