Jump to content

[Script] Calculate Pi


PartyMTA

Recommended Posts

hi,i made this little script with the method of Archimedes to calculate the Pi.

  
function getPi(commandName,number) 
    calc = number*math.sin(0.5/number) 
  
    outputChatBox(calc) 
end 
addCommandHandler("pi",getPi) 
  

Command:

/pi (number) 

change (number) to the wished number. Without ()!

its actually easy to make this. i just was bored

Link to comment
function getPi(commandName,number) 
number = tonumber ( number )  
if number then -- if we converted it into a number then lets proceed ..... 
    calc = number*math.sin(0.5/number) 
    outputChatBox(calc) 
      end 
end 
addCommandHandler("pi",getPi) 
  

Well good luck. Your efforts are always appreciated. :D

Link to comment

I'm confused. What's the point of this script? Why calculate pi? How are you going to calculate pi by passing a number to the command?

print( math.pi ); 
-- or if accuracy isn't that important to you: 
print( 22/7 ); 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...