Skip to forum content

You are not logged in. Please login or register.


forums.pvpgn.pro → [EN] The Source Code → [ask]how to make a command

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 4

1

Topic: [ask]how to make a command

hello
i want to ask how to make a command like /ann ?
if /ann, it will broadcast to all user.
but if /ann1, it will message to a person

i use command: /ann1 Hello.. How are you ?
you whisper to BOT: Hello.. How are you ?

this is my code

static int _handle_ann1_command(t_connection * c, char const *text)
{
  unsigned int i;
  for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip command */
  for (; text[i]==' '; i++);

if (text[i]=='\0')
  {
    message_send_text(c,message_type_info,c,"usage: /ann1 <text>");
    return 0;
  }

    snprintf(msgtemp, sizeof(msgtemp), "BOT");
    do_whisper(c,msgtemp,"%.128s",&text[i]);
    return 0;
    }

but when i use like this..
it will says "

1>..\..\..\src\bnetd\command.cpp(616) : error C2660: 'pvpgn::bnetd::do_whisper' : function does not take 4 arguments

1>..\..\..\src\bnetd\command.cpp(840) : warning C4146: unary minus operator applied to unsigned type, result still unsigned

please correct my code smile

Thanks~

2

Re: [ask]how to make a command

Jimmy_Aquarius wrote:

hello
i want to ask how to make a command like /ann ?
if /ann, it will broadcast to all user.
but if /ann1, it will message to a person

i use command: /ann1 Hello.. How are you ?
you whisper to BOT: Hello.. How are you ?

this is my code

static int _handle_ann1_command(t_connection * c, char const *text)
{
  unsigned int i;
  for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip command */
  for (; text[i]==' '; i++);

if (text[i]=='\0')
  {
    message_send_text(c,message_type_info,c,"usage: /ann1 <text>");
    return 0;
  }

    snprintf(msgtemp, sizeof(msgtemp), "BOT");
    do_whisper(c,msgtemp,"%.128s",&text[i]);
    return 0;
    }

but when i use like this..
it will says "

1>..\..\..\src\bnetd\command.cpp(616) : error C2660: 'pvpgn::bnetd::do_whisper' : function does not take 4 arguments

1>..\..\..\src\bnetd\command.cpp(840) : warning C4146: unary minus operator applied to unsigned type, result still unsigned

please correct my code smile

Thanks~

std::sprintf(bot,"Zeloit");

3 (edited by Jimmy_Aquarius 07.01.2013 15:28)

Re: [ask]how to make a command

Zeloit wrote:
Jimmy_Aquarius wrote:

hello
i want to ask how to make a command like /ann ?
if /ann, it will broadcast to all user.
but if /ann1, it will message to a person

i use command: /ann1 Hello.. How are you ?
you whisper to BOT: Hello.. How are you ?

this is my code

static int _handle_ann1_command(t_connection * c, char const *text)
{
  unsigned int i;
  for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip command */
  for (; text[i]==' '; i++);

if (text[i]=='\0')
  {
    message_send_text(c,message_type_info,c,"usage: /ann1 <text>");
    return 0;
  }

    snprintf(msgtemp, sizeof(msgtemp), "BOT");
    do_whisper(c,msgtemp,"%.128s",&text[i]);
    return 0;
    }

but when i use like this..
it will says "

1>..\..\..\src\bnetd\command.cpp(616) : error C2660: 'pvpgn::bnetd::do_whisper' : function does not take 4 arguments

1>..\..\..\src\bnetd\command.cpp(840) : warning C4146: unary minus operator applied to unsigned type, result still unsigned

please correct my code smile

Thanks~

std::sprintf(bot,"Zeloit");

still error

change

snprintf(msgtemp, sizeof(msgtemp), "BOT");

to

std::sprintf(bot,"BOT");

?

4

Re: [ask]how to make a command

Let's see on do_whisper function declaration

static void do_whisper(t_connection * user_c, char const * dest, char const * text);

1 argument is a user connection who send whisper message
2 argument is a destination user connection who will recieve this message
3 argument is a message text

So why are you trying to pass 4 arguments?
Look into function _handle_reply_command for true example (command.cpp).

Do not ask for support in PM.

Posts: 4

Pages 1

You must login or register to post a reply

Who now at forum

Currently view post: 1 guest, 0 registered users

forums.pvpgn.pro → [EN] The Source Code → [ask]how to make a command



Generated in 0.095 seconds (75% PHP - 25% DB) with 20 queries