Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #if defined _KFU_included
- #endinput
- #endif
- #define _KFU_included
- /*******************************************************************************
- * Function: IsPlayerInWater(playerid)
- * 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)
- *******************************************************************************/
- stock IsPlayerInWater(playerid)
- {
- new index = GetPlayerAnimationIndex(playerid);
- return ((index >= 1538 && index <= 1541) || index == 1544);
- }
- /*******************************************************************************
- * Function: GetPlayerID(name[])
- * Description: The GetPlayerID return the id of a player by name
- *******************************************************************************/
- stock GetPlayerID(name[])
- {
- if (strlen(name) >= 24)
- return INVALID_PLAYER_ID;
- new Name[16];
- for(new i; i < MAX_PLAYERS; i++)
- {
- GetPlayerName(playerid, Name, sizeof Name);
- if(!strcmp(Name, name, true))
- return i;
- }
- return INVALID_PLAYER_ID;
- }
- /*******************************************************************************
- * Function: GetPlayerFromIP(ip[])
- * Description: The GetPlayerIDFromIP return the id of a player through its ip
- *******************************************************************************/
- stock GetPlayerIDFromIP(ip[])
- {
- if !( 7 <= strlen(ip) <= 15)
- return INVALID_PLAYER_ID;
- new IP[16];
- for(new i; i < MAX_PLAYERS; i++)
- {
- GetPlayerIp(playerid, IP, sizeof IP);
- if(!strcmp(IP, ip, true))
- return i;
- }
- return INVALID_PLAYER_ID;
- }
- /*******************************************************************************
- * Function: ToUpperCase(string[])
- * Description: The toUpperCase transforms the characters of a string from lowercase to uppercase
- *******************************************************************************/
- stock ToUpperCase(string[])
- {
- new
- Len = strlen(string);
- for(new i; i < Len; i++)
- if('a' <= string[i] <= 'z')
- string[i] -= 32;
- return string;
- }
- /*******************************************************************************
- * Function: ToTiny(string[])
- * Description: The ToTiny has the inverse function of toUpperCase, transforms the characters of a string from upper to lower case
- *******************************************************************************/
- stock ToTiny(string[])
- {
- new
- Len = strlen(string);
- for(new i; i < Len; i++)
- if('A' <= string[i] <= 'Z')
- string[i] += 32;
- return string;
- }
- /*******************************************************************************
- * Function: IsPrimeNumber(number)
- * Description: The IsPrimeNumber see if a number is prime or not
- *******************************************************************************/
- stock IsPrimeNumber(number)
- {
- switch(number)
- {
- case -1..1: return false;
- case 2, 3: return true;
- }
- if(!(number % 2) || !(number % 3) || !(number % 5))
- return false;
- new
- RoundSqrt = floatround(floatsqroot(number), floatround_floor);
- for(new i = 5; i < RoundSqrt; i++)
- if(!(number % i) && (number != i))
- return false;
- return true;
- }
- /*******************************************************************************
- * Function: RandomBetweenNumbers(...)
- * Description: The RandomBetweenNumbers creates a random number between the brackets
- *******************************************************************************/
- stock RandomBetweenNumbers(...)
- {
- if(!numargs())
- return -1;
- if(numargs() == 1)
- return getarg(0);
- new
- Num = numargs(),
- Random = random(Num);
- return getarg(Random);
- }
- /*******************************************************************************
- * Function: RandomBetweenCharacters(...)
- * Description: The RandomBetweenCharacters creates a random one of the characters within the brackets
- *******************************************************************************/
- stock RandomBetweenCharacters(...)
- {
- if(!numargs())
- return ' ';
- if(numargs() == 1)
- {
- switch(getarg(0))
- {
- case 33..126, 128..254: return getarg(0);
- default: return ' ';
- }
- }
- new
- Num = numargs(),
- RandomArgs = random(Num);
- return getarg(RandomArgs);
- }
Advertisement
Add Comment
Please, Sign In to add comment