oddeven()
The first one checks to see weither the input number is even or odd. The scripts name should be oddeven to make the next script work.
As you can see, it returns 0 for an odd number and 1 for an even number.//argument0 = Number to check
//Returns:
// 0 = Odd
// 1 = Even
if argument0 mod 2 = 0
return 1;
else
return 0;
is_prime()
This one checks weither the input number is a prime number or not. I called this script is_prime.
Note: This scripts will not work if the above script is not called oddeven
//argument0 = Number to check
//Returns:
// 0 = Not prime
// 1 = Prime
if argument0 = 2
return true;
if oddeven(argument0) = 1
return false;
for (i = 3; i*i <= argument0; i += 2)
{if (argument0 mod i == 0)
return false;}
return true;
root()
This script is basic, but yea, in GM you have a function called sqrt() which is 2root, but what would happen if for some reason you wanted to use 3root? or 4root?
You would use this script, called root.
//argument0 = The number that should be rooted
//argument1 = The number with what argument0 should be rooted with.
//Returns: The number after the nroot.
return power(argument0,1/argument1);
add_percentage()
Congratulations! Your Maximum HP has increased by 10 percent!
How would you do this? Yep you would use an easy formula n * (100 +%) / 100
//argument0 = The number to add the % to.
//argument1 = The percentage to add.
//Returns: An amount with a givin amount of %.
n = argument0
p = argument1
return n * (100 + p) / 100;
subtract_percentage()
You have not been working good, I am cutting your salary with 10%!
//argument0 = The number to remove the % to.
//argument1 = The percentage to remove.
//Returns: An amount subtracted with a givin amount of %.
n = argument0
p = argument1
return n * (100 - p) / 100;
divisible()
Is 2452987265 divisible by 7?
Why you would want to know this information I have no clue XD
BUT according to my script, no its not
//argument0 = Number that should be divided.
//argument1 = Number to divide with.
//Returns: Weither the number is divisible or not.
if argument0 mod argument1 = 0
return true;
else
return false;
Well thats all from me
Maby one or two scripts could help someone, don't know.
Best of luck with your projects.
-zappy



Find content
Not Telling


