added help command

This commit is contained in:
Václav Šmejkal 2024-04-19 16:08:54 +02:00
parent 1fc78a2a30
commit e023207261
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
3 changed files with 13 additions and 1 deletions

View File

@ -42,6 +42,7 @@ extern "C" {
//COMMANDS
#define WHY2_CHAT_COMMAND_PREFIX "!" //the little thingy you write before the command names to make the program recognise them boy. You know? Like in minecraft you use /kill... Also, are you dumb?
#define WHY2_CHAT_COMMAND_EXIT "exit" //QUIT THE PROGRAM CMD
#define WHY2_CHAT_COMMAND_HELP "help" //PRINT ALL COMMANDS
//SHORTCUTS CAUSE I'M LAZY BITCH
#define WHY2_CHAT_CODE_SSQC WHY2_CHAT_CODE_SERVER_SIDE_QUIT_COMMUNICATION

View File

@ -116,6 +116,17 @@ int main(void)
why2_send_socket(exit_cmd, NULL, listen_socket);
why2_deallocate(exit_cmd);
} else if (strcmp(line, WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_HELP "\n") == 0)
{
printf
(
"\nCommands:\n---------\n%s\n\n>>> ",
WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_EXIT "\tExits the program.\n"
WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_HELP "\tPrints out all the commands. :)"
);
fflush(stdout);
} else
{
why2_send_socket(line, NULL, listen_socket); //NULL IS SENT BECAUSE IT IS USELESS TO SEND USER FROM CLIENT - SERVER WON'T USE IT

View File

@ -830,7 +830,7 @@ void *why2_listen_server(void *socket)
fflush(stdout);
} else if (strcmp(message, WHY2_CHAT_CODE_INVALID_COMMAND) == 0) //INVALID CMD
{
printf("\nInvalid command!\n\n");
printf("\nInvalid command! Use \"" WHY2_CHAT_COMMAND_PREFIX WHY2_CHAT_COMMAND_HELP "\" for list of commands.\n\n");
fflush(stdout);
}
} else if (!continuing)