Jump to content

[HELP] math.random question


Recommended Posts

Hi Before I get started let it be known this is going to be the first script and I appreciate any help I can get..

ok i know what math.random does and I have it currenty set to generate #'s 1-100

I have Also set a commandHandler to activate it e.g callrandom

What i need help with is how to display said random number in a local chatbox

e.g player hits /callrandom and then a number 1-100 appears on the screen.

i'm not asking for someone to just give me a script as i am trying to learn i'm just looking for someone to point me in the right place to look Thanks again

Link to comment
number = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} 
  
numbers = number [ math.random ( #number ) ] 
  
function randomnum 
    outputChatBox ( " The random number is ".. numbers ..". " ) 
end 
  
addCommandHandler ( "callrandom", randomnum ) 

Not sure at all whether it will work, its my first time trying to help. :oops:

Link to comment
number = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} 
numbers = number [ math.random ( #number ) ] 
function randomnum 
    outputChatBox ( " The random number is ".. numbers ..". " ) 
end 
addCommandHandler ( "callrandom", randomnum ) 

This will not work correctly.

try this.

function randomnum(player) 
local numbers = tostring(math.random(1,100)) 
    outputChatBox ( " The random number is ".. numbers ..". ", player ) 
end 
addCommandHandler ( "callrandom", randomnum) 

Link to comment
  • 9 years later...
...

try this:

number = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} 

function randomnum()
    numbers = number [ math.random ( #number ) ] 
    outputChatBox ( " The random number is ".. numbers ..". " ) 
end 
addCommandHandler ( "callrandom", randomnum )

 

Edited by NiNja1382
Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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