Help with this simple command

Started by GangstaRas, May 14, 2015, 05:59 PM

Previous topic - Next topic

GangstaRas

So I was studying the code of other scripts and I managed to figure out some things today regarding printing out stuff in the console when the script is loaded. But when I try to get something printed ingame, the headaches are back.

I'm trying to print this simple line:
function onPlayerJoin( player )
{
MessagePlayer("Welcome to the server!");
}

But all I get is an error saying its the wrong number of parameters. ???

Murdock

The function MessagePlayer indeed takes 2 arguments and you are only passing it one.
Aside from the message you have to tell the function to which player the message has to be sent to.
Eventually your code would look like this:

function onPlayerJoin( player )
{
  MessagePlayer( "Welcome to the server!", player );
}

Hope this helps.

Thijn

See people. This is how a simple question should be posted.
1. I'm trying to do this
2. I've tried this piece of code
3. I get this error.

Murdock gives an excellent answer why his code isn't working, and an example of how his script should look like.

Bravo! Let this be an example for many other people who encounters errors in their scripts.