Thread: my first code
View Single Post
  #2  
Old 07-13-2009, 09:26 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
Quote:
Originally Posted by Liberated View Post
I hope this is the right place to post this, but i'm getting into Gscript2, and want to make sure i do everything correct, i was just wondering if i scripted this correctly, and what i could different and/or better.

PHP Code:
function onCreated () 
{
setimg ("door.png");
}

//#CLIENTSIDE

function onPlayerchats () 
{
 if (
player.chat == "hello")
 {
 
this.chat "hi There";
 }
   else  
 if (
player.chat == "you're dumb")
 {
  
this.chat "I do NOT wish to talk to you sir.";
 }

yeah i know it's a talking door.
You did a couple things wrong. Here's how it should be written (see comments):

PHP Code:
function onCreated() // events should not have spaces before the paranthesis 
{
  
setimg("door.png"); // always indent two spaces (press TAB if using RC) and functions should not have a space before the parameters
}

//#CLIENTSIDE

function onPlayerchats()  // remember the parenthesis
{
  if (
player.chat == "hello")
  {
    
this.chat "hi There"// remember to indent two spaces
  
}
  else if (
player.chat == "you're dumb"// most people will put the else and if on the same line, but it doesn't really matter - people do it both ways
  
{
    
this.chat "I do NOT wish to talk to you sir.";
  }

__________________

Last edited by Tigairius; 07-14-2009 at 03:16 AM..
Reply With Quote