Guest User

Untitled

a guest
Oct 18th, 2011
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #if defined _KFU_included
  4. #endinput
  5. #endif
  6. #define _KFU_included
  7.  
  8. /*******************************************************************************
  9. * Function: IsPlayerInWater(playerid)
  10. * Description: The IsPlayerInWater need to see if a player is swimming (so it does not work if you're in the water with a vehicle)
  11. *******************************************************************************/
  12.  
  13. stock IsPlayerInWater(playerid)
  14. {
  15. new index = GetPlayerAnimationIndex(playerid);
  16. return ((index >= 1538 && index <= 1541) || index == 1544);
  17. }
  18.  
  19. /*******************************************************************************
  20. * Function: GetPlayerID(name[])
  21. * Description: The GetPlayerID return the id of a player by name
  22. *******************************************************************************/
  23.  
  24. stock GetPlayerID(name[])
  25. {
  26. if (strlen(name) >= 24)
  27. return INVALID_PLAYER_ID;
  28. new Name[16];
  29. for(new i; i < MAX_PLAYERS; i++)
  30. {
  31. GetPlayerName(playerid, Name, sizeof Name);
  32. if(!strcmp(Name, name, true))
  33. return i;
  34. }
  35. return INVALID_PLAYER_ID;
  36. }
  37.  
  38. /*******************************************************************************
  39. * Function: GetPlayerFromIP(ip[])
  40. * Description: The GetPlayerIDFromIP return the id of a player through its ip
  41. *******************************************************************************/
  42.  
  43. stock GetPlayerIDFromIP(ip[])
  44. {
  45. if !( 7 <= strlen(ip) <= 15)
  46. return INVALID_PLAYER_ID;
  47. new IP[16];
  48. for(new i; i < MAX_PLAYERS; i++)
  49. {
  50. GetPlayerIp(playerid, IP, sizeof IP);
  51. if(!strcmp(IP, ip, true))
  52. return i;
  53. }
  54. return INVALID_PLAYER_ID;
  55. }
  56.  
  57. /*******************************************************************************
  58. * Function: ToUpperCase(string[])
  59. * Description: The toUpperCase transforms the characters of a string from lowercase to uppercase
  60. *******************************************************************************/
  61.  
  62. stock ToUpperCase(string[])
  63. {
  64. new
  65. Len = strlen(string);
  66. for(new i; i < Len; i++)
  67. if('a' <= string[i] <= 'z')
  68. string[i] -= 32;
  69. return string;
  70. }
  71.  
  72. /*******************************************************************************
  73. * Function: ToTiny(string[])
  74. * Description: The ToTiny has the inverse function of toUpperCase, transforms the characters of a string from upper to lower case
  75. *******************************************************************************/
  76.  
  77. stock ToTiny(string[])
  78. {
  79. new
  80. Len = strlen(string);
  81. for(new i; i < Len; i++)
  82. if('A' <= string[i] <= 'Z')
  83. string[i] += 32;
  84. return string;
  85. }
  86.  
  87. /*******************************************************************************
  88. * Function: IsPrimeNumber(number)
  89. * Description: The IsPrimeNumber see if a number is prime or not
  90. *******************************************************************************/
  91.  
  92. stock IsPrimeNumber(number)
  93. {
  94. switch(number)
  95. {
  96. case -1..1: return false;
  97. case 2, 3: return true;
  98. }
  99. if(!(number % 2) || !(number % 3) || !(number % 5))
  100. return false;
  101. new
  102. RoundSqrt = floatround(floatsqroot(number), floatround_floor);
  103. for(new i = 5; i < RoundSqrt; i++)
  104. if(!(number % i) && (number != i))
  105. return false;
  106. return true;
  107. }
  108.  
  109. /*******************************************************************************
  110. * Function: RandomBetweenNumbers(...)
  111. * Description: The RandomBetweenNumbers creates a random number between the brackets
  112. *******************************************************************************/
  113.  
  114. stock RandomBetweenNumbers(...)
  115. {
  116. if(!numargs())
  117. return -1;
  118. if(numargs() == 1)
  119. return getarg(0);
  120. new
  121. Num = numargs(),
  122. Random = random(Num);
  123. return getarg(Random);
  124. }
  125.  
  126. /*******************************************************************************
  127. * Function: RandomBetweenCharacters(...)
  128. * Description: The RandomBetweenCharacters creates a random one of the characters within the brackets
  129. *******************************************************************************/
  130.  
  131. stock RandomBetweenCharacters(...)
  132. {
  133. if(!numargs())
  134. return ' ';
  135. if(numargs() == 1)
  136. {
  137. switch(getarg(0))
  138. {
  139. case 33..126, 128..254: return getarg(0);
  140. default: return ' ';
  141. }
  142. }
  143. new
  144. Num = numargs(),
  145. RandomArgs = random(Num);
  146. return getarg(RandomArgs);
  147. }
  148.  
  149.  
  150.  
  151.  
  152.  
Advertisement
Add Comment
Please, Sign In to add comment