Quote:
Originally Posted by Liberated
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.";
}
}