Skip to forum content

You are not logged in. Please login or register.


forums.pvpgn.pro → [EN] The Source Code → how to make ann

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 6

1 (edited by ./root-system 29.05.2013 13:51)

Topic: how to make ann

Example :
Grade of Venomous- is Pro

so how can i make announcement like this

Announcement from Pro Venomous-: Test

this is my source code

static int _handle_announce_command(t_connection * c, char const *text)
{
  unsigned int i;
  t_message *  message;

  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: /announce <announcement>");
    return 0;
  }

  snprintf(msgtemp, sizeof(msgtemp), "Announcement from %.14 %.64s: %.128s",account_get_grade(account),conn_get_username(c),&text[i]);
  if (!(message = message_create(message_type_broadcast,c,msgtemp)))
    message_send_text(c,message_type_info,c,"Could not broadcast message.");
  else
    {
      if (message_send_all(message)<0)
    message_send_text(c,message_type_info,c,"Could not broadcast message.");
      message_destroy(message);
    }

  return 0;
}

but that code is error
anyone can help me?

2

Re: how to make ann

What's the error?

Do not ask for support in PM.

3

Re: how to make ann

oh I'm sorry i forget

this is the error

17>..\..\..\source\src\bnetd\command.cpp(776): warning C4146: unary minus operator applied to unsigned type, result still unsigned
17>..\..\..\source\src\bnetd\command.cpp(1754): error C2065: 'account' : undeclared identifier

4

Re: how to make ann

First you have to get account from the current connection.

Example: https://github.com/HarpyWar/pvpgn/blob/ … d.cpp#L559

t_account * account;

  if (!(account  = conn_get_account(c))){
      ERROR0("got NULL account");
  }
Do not ask for support in PM.

5 (edited by ./root-system 29.05.2013 14:46)

Re: how to make ann

I'm sorry i don't know what do you mean  neutral
do you mean like this?

static int _handle_announce_command(t_connection * c, char const *text)
{
  unsigned int i;
  t_message *  message;
  t_account * acc;

  if (!(acc = account_get_grade(c))){
      ERROR0("got NULL account");
  }

  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: /announce <announcement>");
    return 0;
  }

  snprintf(msgtemp, sizeof(msgtemp), "Announcement from %.14 %.64s: %.128s",account_get_grade(c),conn_get_username(c),&text[i]);
  if (!(message = message_create(message_type_broadcast,c,msgtemp)))
    message_send_text(c,message_type_info,c,"Could not broadcast message.");
  else
    {
      if (message_send_all(message)<0)
    message_send_text(c,message_type_info,c,"Could not broadcast message.");
      message_destroy(message);
    }

  return 0;
}

but when i try this code
i found error

17>..\..\..\source\src\bnetd\command.cpp(776): warning C4146: unary minus operator applied to unsigned type, result still unsigned
17>..\..\..\source\src\bnetd\command.cpp(1736): warning C4101: 'i' : unreferenced local variable
17>..\..\..\source\src\bnetd\command.cpp(2435): error C2664: 'pvpgn::bnetd::account_get_grade' : cannot convert parameter 1 from 'pvpgn::bnetd::t_connection *' to 'pvpgn::bnetd::t_account *'
17>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
17>..\..\..\source\src\bnetd\command.cpp(2448): error C2664: 'pvpgn::bnetd::account_get_grade' : cannot convert parameter 1 from 'pvpgn::bnetd::t_connection *' to 'pvpgn::bnetd::t_account *'
17>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

i'm sorry because i'm newbie and my english is bad
and i always ask a question  smile

6

Re: how to make ann

./root-system wrote:

if (!(acc = account_get_grade(c))){

Why did you do this? I have given you an example.

Look at the error "cannot convert parameter 1 from 'pvpgn::bnetd::t_connection *' to 'pvpgn::bnetd::t_account".
It means that function account_get_grade takes argument type of t_account, but you invoke it with argument type of t_connection ("c").

Please, learn basics of c++ before making suchlike source modifications.

Do not ask for support in PM.

Posts: 6

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 → how to make ann