Jump to content
  • 0

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


Sneaky

Question


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  392
  • Reputation:   47
  • Joined:  11/18/11
  • Last Seen:  

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
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  67
  • Reputation:   23
  • Joined:  11/14/11
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  392
  • Reputation:   47
  • Joined:  11/18/11
  • Last Seen:  

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) )

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  34
  • Reputation:   4
  • Joined:  11/09/11
  • Last Seen:  

I've tested it and it works.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  392
  • Reputation:   47
  • Joined:  11/18/11
  • Last Seen:  

Oh I got it, figured I editted something while adding the code xd, thanks!

Link to comment
Share on other sites

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.

×
×
  • Create New...