Author Topic: Could someone explain what %empty.myvariable does?  (Read 560 times)

I have wondered and wondered why is there a %client. And %this. At the beggining of some variables I would like to know what they do

Variable names don't matter. You just name variables certain things to help you remember what information is or should be stored in it.

A client is the person's connection to the server. It's like their soul.

You can store variables onto objects, like %client.name. %client.player is just a variable on the client that stores the ID of their body(or player object). So when you do %client.player.kill(); you're just using their soul(client) to find their body(player object). Whenever you die the ID of your body(player object) will no longer exist and the variable will be reassigned a new ID when you respawn.

In server commands the first argument is always going to be the client(soul) of the person who called the command. As you can name variables whatever you want you could name it %cowSlappingAMonkeyInTheFace if you really wanted to. All the rest of the arguments in server commands will be input from the client. So if I said /doStuff I really like dogs in the chat, it'd call serverCmdDoStuff(%client, %a, %b, %c, d). %client would be my soul. %a would be "I". %b would be "really". %c would be "like". And %d would be "dogs". You can name these variables whatever you want, but their values will be the same.

In functions called on objects the first argument will always be the object it was called on. So %client.player.kill(); will call Player::kill(%variable). As .kill(); was called on a player, the first variable will be the ID of the player. But remember, we can name this variable whatever we want to. People would typically either name it %this(meaning that it's the object stated before the function name, or %player(because it's someone's player object).

So if we made a function on a client called doStuff like this:
Code: [Select]
function gameConnection::doStuff(%client, %arg1, %arg2, %arg3, %arg4)
{
   echo("We're doing stuff!");
}
(We're using gameConnection because that's the class name of a person's soul(or client).)
Then we'd call it by %someClientOfSomePerson.doStuff("Ham", "tastes", "kind", "of", "good");
Notice that %arg1 would be "Ham", %arg2 would be "tastes", %arg3 would be "kind", %arg4 would be "of", and we wouldn't receive the word "good" unless we added another argument to the function.

We could also just do %aClient.doStuff("Ham tastes kind of good"); Then %arg1 would be "Ham tastes kind of good" and the rest of the arguments would be blank.

Hope this helps.
« Last Edit: April 28, 2015, 09:55:46 AM by jes00 »

Variable names don't matter. You just name variables certain things to help you remember what information is or should be stored in it.

A client is the person's connection to the server. It's like their soul.

You can store variables onto objects, like %client.name. %client.player is just a variable on the client that stores the ID of their body(or player object). So when you do %client.player.kill(); you're just using their soul(client) to find their body(player object). Whenever you die the ID of your body(player object) will no longer exist and the variable will be reassigned a new ID when you respawn.

In server commands the first argument is always going to be the client(soul) of the person who called the command. As you can name variables whatever you want you could name it %cowSlappingAMonkeyInTheFace if you really wanted to. All the rest of the arguments in server commands will be input from the client. So if I said /doStuff I really like dogs in the chat, it'd call serverCmdDoStuff(%client, %a, %b, %c, d). %client would be my soul. %a would be "I". %b would be "really". %c would be "like". And %d would be "dogs". You can name these variables whatever you want, but their values will be the same.

In functions called on objects the first argument will always be the object it was called on. So %client.player.kill(); will call Player::kill(%variable). As .kill(); was called on a player, the first variable will be the ID of the player. But remember, we can name this variable whatever we want to. People would typically either name it %this(meaning that it's the object stated before the function name, or %player(because it's someone's player object).

So if we made a function on a client called doStuff like this:
Code: [Select]
function gameConnection::doStuff(%client, %arg1, %arg2, %arg3, %arg4)
{
   echo("We're doing stuff!");
}
(We're using gameConnection because that's the class name of a person's soul(or client).)
Then we'd call it by %someClientOfSomePerson.doStuff("Ham", "tastes", "kind", "of", "good");
Notice that %arg1 would be "Ham", %arg2 would be "tastes", %arg3 would be "kind", %arg4 would be "of", and we wouldn't receive the word "good" unless we added another argument to the function.

We could also just do %aClient.doStuff("Ham tastes kind of good"); Then %arg1 would be "Ham tastes kind of good" and the rest of the arguments would be blank.

Hope this helps.
thanks helped a lot