Author Topic: how do I make it so when I type in something in the chat, something happens  (Read 3458 times)

And
don't forget that %client.name is deprecated and %client.getPlayerName() should be used instead

Oh, my bad. I better go back and edit it to avoid some plausible confusion. Should have known better.
« Last Edit: August 17, 2015, 02:50:01 PM by Dannu »

You seem to be much too stuck so I wrote the entire command from the start. What I want you to do, is to tell us what you think each part does, and if needed, we'll correct you.

Code: [Select]
function serverCmdFling(%client, %target)
{
if(%client.isAdmin)
{
%target = findClientByName(%target);
%player = %target.player;
if(isObject(%player))
{
%player.setVelocity("0 0 250");
talk(%client.getPlayerName() SPC "has flung" SPC %target.getPlayerName() @ ".");
}
else
{
messageClient(%client, 0, "Player associated to client not found!");
}
}
else
{
messageClient(%client, 0, "You must be an admin to use this command!");
}
}
All right I should try my best
Code: [Select]
function serverCmdFling(%client, %target)
{
if(%client.isAdmin) // if the player is admin
{
%target = findClientByName(%target); // finds each client name and sets it as %target
%player = %target.player; // if the player is trageted
if(isObject(%player)) // if the player is an objet
{
%player.setVelocity("0 0 250"); //set the Velocity to 250
talk(%client.getPlayerName() SPC "has flung" SPC %target.getPlayerName() @ "."); //says out loud which admin flung which player
}
else
{
messageClient(%client, 0, "Player associated to client not found!"); // if not player not found, say this
}
}
else
{
messageClient(%client, 0, "You must be an admin to use this command!"); // if not admin, say this
}
}

Code: [Select]
%target = findClientByName(%target); // finds each client name and sets it as %target
This actually takes the input, cycles through all the clients in the server and then returns the closest match to the input you gave it.
Code: [Select]
%player = %target.player; // if the player is targeted
No if statement here. This is just making a new local variable, taking the client you just found, and then assigning the client's player object to the local variable.
Code: [Select]
if(isObject(%player)) // if the player is an object
This is making sure that the client's player object exists. A client is like a person's soul; their connection in the server. A player is just the body that the soul is put into. The player can die. But if the client dies then that person is no longer connected to the server. Here we're making sure that the soul's body is still alive.

This actually takes the input, cycles through all the clients in the server and then returns the closest match to the input you gave it.No if statement here. This is just making a new local variable, taking the client you just found, and then assigning the client's player object to the local variable.This is making sure that the client's player object exists. A client is like a person's soul; their connection in the server. A player is just the body that the soul is put into. The player can die. But if the client dies then that person is no longer connected to the server. Here we're making sure that the soul's body is still alive.
Ahh, thanks! for the info, you guys are really helpful! :)