16.07.2014, 16:31
(
Last edited by codectile; 24/07/2014 at 02:20 PM.
Reason: v1.2
)
Add - On Library
This is an add-on library include for pawn coding, I have seen that pawn lacks few string and recreational mathematical library functions, which may or may not be important ,but as per my way of thinking, they are a bit important.
This include is just an add-on, if you are using other string libraries (westie's, oscar broman) instead of pawn's default/user or sa-mp team created library, I would like to suggest you to use this add-on along with them/it, as this add-on gives scripters freedom of various string manipulating and recreational mathematical functions, this include is mainly for string manipulation. If you have any suggestions ,please post in this thread.
Important: v1.2 Update, please go through the functions list once again.
Function Lists:
ToPalindrome(input[]): Converts a string to a palindrome string.
IsPalindrome(input[]): Checks whether a string is palindrome or not.
IsArmstrong(value): Recreational mathematical function.Useful for reaction tests. Checks whether the number is armstrong or not.WikipediaReturns boolean type.
IsNeon(value):Checks for Neon number example: 9 (is a neon number) = 9*9=81 , 8+1=9. These type of numbers are known as neon numbers.Returns boolean type.
IsPerfect(value) : WikipediaReturns boolean type.
IsEvenOrOdd(value): Checks if the number given is even or odd.Returns boolean type.
IsPrime(value): Checks for prime numbers.Returns boolean type.
IsMagic(value): Magic number example: 55 (is a magic number) = 5+5=10, 1+0=1.
289(is a magic number) = 2+8+9=19, 1+9=10, 1+0=1
Returns boolean type.
MaxDigit(value): Returns the maximum digit present in a sequence of a number. Example: 46789 ,Max=9
Returns boolean type.
MinDigit(value): Returns the minimum digit present in a sequence of a number. Example: 46789 ,Min=4
FirstIndexOf(string[],character[]): Returns the first index of a character present in a string.
LastIndexOf(string[],character[]): Returns the last index of a character present in a string.
Truncate(Float:value): Removes the fractional part of a floating data type. Example: 5.98 ,Return 5
IsSpace(character[]): Checks whether a character is a space or not.Returns boolean type.
IsUnderscore(character[]): Checks whether a character is an underscore or not.Returns boolean type.
IsDigit(character[]): Checks whether a character is a digit or not.Returns boolean type.
IsLetter(character[]): Checks whether a character is a letter or not.Returns boolean type.
IsUpperCase(character[]): Checks whether a character is an uppercase letter or not.Returns boolean type.
IsLowerCase(character[]): Checks whether a character is an lowercase letter or not.Returns boolean type.
Reverse(string[]): Reverses a given string.
Compare(string1[],string2[]): Compare lengths of two strings
Retrurns 0 If both string's length are same.
Returns 1 If length of string1 is greater than string2
Returns -1 If length of string2 is greater than string1
CharAt(string[],index): Returns a character present in the given index of a string.
ReplaceChar(string[],character[],replacewith[]): Replace a character in a given string.
Example: ReplaceChar("codectile","c","z");
Output: "zodeztile"
IsSpecial(character[]): Returns 1 if a character is neither a digit or a letter.Returns boolean type.
Substring(string[],firstindex,lastindex): Substrings the string.
Example: Substring("codectile",2,5)
Returns "dect"
Concat(string1[],string2[]): Concatenates two strings.
Example: Concat("codec","tile");
Returns: "codectile"
ExtStr(string[]): Extract string type characters
Example: ExtStr("c874o10d74e1c9t0i14l98e");
Returns : "codectile"
Frequency(string[],character[]): Returns the frequency of a character present in a string.
Example: Frequency("codectile","c");
Returns: 2
Equals(string1[],string2[]): Checks whether two strings are similar or not.Note: Case Sensitive
Example: Equals("codec","tile");
Returns: false
Example: Equals("codectile","codectile");
Returns: true
DigitFreq(value,digit): Returns the frequency of a digit in a sequence of numbers
Example: Digit(46667,6);
Returns: 3
ToPositive(Float:value): Converts a negative integer to a positive integer.
ToNegitive(Float:value): Converts a positive integer to a negative integer.
Download:
Mediafire v1.2 Update
SolidFiles v1.2 Update
Credits:
Y_Less : For suggesting functions name for MaxDigit/MinDigit
Sa-Mp Team: For samp client.
And God : For world.