Y_Commands | Explanation Please.
#1

I know how to use Y_Commands, But i don't know what is "Help" and how to use it.

Example:

pawn Код:
#include <YSI\y_commands>

YCMD:pkill(playerid, params[], help) // <-- "Help"
{
   new id;
   if(sscanf(params,"d",id)) {
      SendClientMessage(playerid, COLOR_WHITE, "Usage: /pkill [playerid]");
      return 1;
   }
   
   if(IsPlayerConnected(id)) {

      SetPlayerHealth(id, -1);

      new string[128];

      if(id == playerid) format(string,128,"(ADMIN) %s has killed himself",PlayerName(playerid));
      else format(string,128,"(ADMIN) %s has killed %s",PlayerName(playerid),PlayerName(id));
      SendClientMessageToAll(COLOR_YELLOW, string);
      return 1;
   }else return SendClientMessage(playerid, COLOR_RED, "Player is not connected");
}
any one explain me what is or how to use "Help" ?
Reply
#2

I am not sure.
But, all i know is.
It uses to explain how the command works.

Example

pawn Код:
if(help)
{
GameTextForPlayer(playerid, "~r~Test ~w~Command", 3500, 3);
}
When the command is use. The GameText will appear.
Not sure.
Reply
#3

Well anyway, its in ****** topic https://sampforum.blast.hk/showthread.php?tid=169029
Reply
#4

Quote:
Originally Posted by _Jake_
Посмотреть сообщение
I am not sure.
But, all i know is.
It uses to explain how the command works.

Example

pawn Код:
if(help)
{
GameTextForPlayer(playerid, "~r~Test ~w~Command", 3500, 3);
}
When the command is use. The GameText will appear.
Not sure.
Hmmmm, You mean when player use this command then gametext will appears?
Reply
#5

^
No. It is just example.

I recommended you to read y_commands topic.
Reply
#6

Quote:
Originally Posted by _Jake_
Посмотреть сообщение
^
No. It is just example.

I recommended you to read y_commands topic.
I didn't understood from his topic.

It is better you guys explain me in easy words.

EDIT: If i don't put that 'Help' in that command than what will happen?
Reply
#7

Quote:
Originally Posted by dr.lozer
Посмотреть сообщение
I didn't understood from his topic.

It is better you guys explain me in easy words.
The tutorial topic DOES explain it in easy words.

Quote:
Originally Posted by dr.lozer
Посмотреть сообщение
EDIT: If i don't put that 'Help' in that command than what will happen?
Nothing.

The help parameter is something you can provide to have a command-description system (or something similar).
****** provides an example on how to use it in the y_commands include topic.

Quote:
Originally Posted by ******
Посмотреть сообщение
[*]Help - The command system, as shown above, has inbuilt support for a help system. You define the help for a command with that command, making managing your script VASTLY easier. To use this feature from your help command simply do something like:

pawn Код:
YCMD:help(playerid, params[], help)
{
    if (help)
    {
        SendClientMessage(playerid, 0xFF0000AA, "Displays help about your mode.");
    }
    else
    {
        if (isnull(params))
        {
            new
                str[128];
            SendClientMessage(playerid, 0xFF0000AA, "Welcome to my mode.");
            format(str, sizeof (str), "Type \"/%s [command]\" for more help on a command", Command_GetDisplayNamed("help", playerid));
            SendClientMessage(playerid, 0xFF0000AA, str);
        }
        else
        {
            Command_ReProcess(playerid, params, true);
        }
    }
    return 1;
}
The part you have to notice is the Command_ReProcess function. What this does is simply calling a command (just like if the player typed it in the chat). By using 'true' as the last argument, the help parameter will be set to true. Notice that if help is set to true, he sends a client message describing the command.

In this example he has a /help command, where you can do /help command_name to get the description of the named command.

Here's a tiny example I just made:

pawn Код:
YCMD:help(playerid, params[], help)
{
    Command_ReProcess( playerid, params, true )

    /* You should add more to this command, but it's not entirely necessary.
     * What this does, as I explained above, is simply calling the command (params) with the
     * Help parameter set to true. If I'd do /help me, I'd call the /me command with help set to true */


YCMD:me(playerid, params[], help)
{
    if( help ) // If help is set to true - which it will be if we do /help me
    {
        SendClientMessage( playerid, -1, "This command X does Y" );
    }
    else
    {
        //Process the command, like normal
    }
    return true;
}
If you STILL can't understand this, then I can't help you, I'm afraid. Also, my example is pretty much identical to ******', the difference is just simply that I tried to comment explanations, which I just realised was stupid as I just could've done the same with his example, BUT NEVERTHELESS: You should understand now - if not you should just probably give it up (i.e. don't use the help parameter)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)