Thread: Randomizing?
View Single Post
  #2  
Old 07-17-2012, 05:24 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Your code doesn't make any sense. this.chat isn't a function. How would it know that what you really want is to append the random number to "this.chat" and read the value of that variable?

The best way is to just make an array.

PHP Code:
function onPlayerTouchsMe() {
  
temp.chats = {
    
"Hey",
    
"Hi",
    
"How",
    
"Are",
    
"You",
    
"To",
    
"Day?"
  
};
  
  
this.chat temp.chats[int(random(0temp.chats.size()))];

Somebody will probably post below me and point out that you can sort of use randomString, so let me say preemptively to avoid that; it's not intended for arrays and has some pretty big issues when used with them.
__________________
Reply With Quote