Jump to content
  • 0

[Request] Adding 2nd command symbol but as a string 'cmd '


Question

Posted (edited)

I know it sounds awkward, why would you add a word or a few letters instead of a single character, but I would like to clear my doubt and also learn how to do it.

What I basically wanted to do is add 'cmd ' as a secondary command symbol (Which would actually be a string in this case).

usage example:

cmd warp prontera 100 100

It would be the same as typing..

@warp prontera 100 100

The cmd has a space after it though, not sure if it's possible.

cmd+space+command

Edited by Noah

4 answers to this question

Recommended Posts

  • 0
Posted
Index: atcommand.c
===================================================================
--- atcommand.c (revision 14998)
+++ atcommand.c (working copy)
@@ -47,6 +47,7 @@

// extern variables
char atcommand_symbol = '@'; // first char of the commands
+char atcommand_string[] = "cmd";
char charcommand_symbol = '#';
char* msg_table[MAX_MSG]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others)

@@ -8948,7 +8949,7 @@
  message += 3;

 //Should display as a normal message
- if ( *message != atcommand_symbol && *message != charcommand_symbol )
+ if ( *message != atcommand_symbol && *message != charcommand_symbol && (strncmp(message, atcommand_string, strlen(atcommand_string)) != 0 || message[strlen(atcommand_string)] != ' '))
  return false;

 // type value 0 = server invoked: bypass restrictions
@@ -9012,6 +9013,12 @@
  //pass through the rest of the code compatible with both symbols
  sprintf(atcmd_msg, "%s", message);
 }
+
+ if (strncmp(message, atcommand_string, strlen(atcommand_string)) == 0) {
+  sprintf(atcmd_msg, "%s", message);
+  memmove(atcmd_msg, atcmd_msg+strlen(atcommand_string), strlen(atcmd_msg));
+  atcmd_msg[0] = atcommand_symbol;
+ }

 //Clearing these to be used once more.
 memset(command, '\0', sizeof(command));

command_string.diff

  • 0
Posted

Tested it already but didn't seem to work hmm...there was probably some stuff missing...

    if( message[0] == '|' && strlen(message) >= 4 && (message[3] == atcommand_symbol || message[3] == charcommand_symbol) )

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...