Skip to forum content

You are not logged in. Please login or register.


forums.pvpgn.pro → [EN] The Source Code → [solved] please helpe me new command for /getclan

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 6

1 (edited by lolipop 05.11.2014 22:34)

Topic: [solved] please helpe me new command for /getclan

Please help me to solved this code , i alr compile  success but when , i type /getclan my server disconnect huhuhu  sad

static int _handle_getclan_command(t_connection * c, char const *text)
{
  char           dest[MAX_USERNAME_LEN];
  unsigned int   i,j;
  t_account *    account;
  t_connection * conn;
  char const *   ip;
  char *         tok;
  t_clanmember * clanmemb;
  
    std::time_t      then;
    struct std::tm * tmthen;

  for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip command */
  for (; text[i]==' '; i++);
  for (j=0; text[i]!=' ' && text[i]!='\0'; i++) /* get dest */
    if (j<sizeof(dest)-1) dest[j++] = text[i];
  dest[j] = '\0';
  for (; text[i]==' '; i++);

  if (dest[0]=='\0')
  {
    message_send_text(c,message_type_info,c,"usage: /getclan <account>");
    return 0;
  }

  if (!(account = accountlist_find_account(dest)))
    {
      message_send_text(c,message_type_error,c,"Invalid user.");
      return 0;
    }
    
    then = account_get_ll_ctime(account);
     tmthen = std::localtime(&then); /* FIXME: determine user's timezone */

  
if ((clan = clanmember_get_clan(clanmemb)))
{
snprintf(msgtemp, sizeof(msgtemp), "Clan : %.4s", clan_get_clantag(clan));

message_send_text(c, message_type_whisper, c, msgtemp);


  std::strncpy(msgtemp,account_get_desc(account),sizeof(msgtemp));
  msgtemp[sizeof(msgtemp)-1] = '\0';
  for (tok=std::strtok(msgtemp,"\r\n"); tok; tok=std::strtok(NULL,"\r\n"))
    message_send_text(c,message_type_info,c,tok);
  message_send_text(c,message_type_info,c,"");

  return 0;
}

2 (edited by HarpyWar 06.11.2014 15:51)

Re: [solved] please helpe me new command for /getclan

Variable "clan" is undefined - how can it be compiled?
Also, variable "clanmemb" used without initialized

Proper code to get clantag string:

char         clantag_str_tmp[5];
t_clantag clantag = clan_get_clantag(clan);
snprintf(clantag_str_tmp, sizeof(clantag_str_tmp), "Clan : %c%c%c%c", clantag & 0xff, (clantag >> 8) & 0xff, (clantag >> 16) & 0xff, clantag >> 24);
Do not ask for support in PM.

3

Re: [solved] please helpe me new command for /getclan

when i  put like this the code , error when icompile

tatic int _handle_getclan_command(t_connection * c, char const *text)
{
  char           dest[MAX_USERNAME_LEN];
  unsigned int   i,j;
  t_account *    account;
  t_connection * conn;
  char const *   ip;
  t_clanmember * clanmemb;
  t_clan *clan;
  char         clantag_str_tmp[5];
  t_clantag clantag = clan_get_clantag(clan);


  for (i=0; text[i]!=' ' && text[i]!='\0'; i++); /* skip command */
  for (; text[i]==' '; i++);
  for (j=0; text[i]!=' ' && text[i]!='\0'; i++) /* get dest */
    if (j<sizeof(dest)-1) dest[j++] = text[i];
  dest[j] = '\0';
  for (; text[i]==' '; i++);

  if (dest[0]=='\0')
  {
    message_send_text(c,message_type_info,c,"usage: /getclan <account>");
    return 0;
  }

  if (!(account = accountlist_find_account(dest)))
    {
      message_send_text(c,message_type_error,c,"Invalid user.");
      return 0;
    }
  snprintf(clantag_str_tmp, sizeof(clantag_str_tmp), "Clan : %c%c%c%c", clantag & 0xff, (clantag >> 8) & 0xff, (clantag >> 16) & 0xff, clantag >> 24);
 
 std::strncpy(msgtemp,account_get_desc(account),sizeof(msgtemp));
  msgtemp[sizeof(msgtemp)-1] = '\0';
  for (tok=std::strtok(msgtemp,"\r\n"); tok; tok=std::strtok(NULL,"\r\n"))
    message_send_text(c,message_type_info,c,tok);
  message_send_text(c,message_type_info,c,"");

  return 0;
}

Can you give me full source harpy ? i mean , make it correct my code thanks before

4

Re: [solved] please helpe me new command for /getclan

No. But I can help you with instruction how you can catch a crash by yourself.

You have to download Visual Studio and PvPGN Dev Kit. Follow instruction in description to Dev Kit how to run your PvPGN source with debugging.
Also, please translate this article (section with debugging example).

Do not ask for support in PM.

5

Re: [solved] please helpe me new command for /getclan

HarpyWar wrote:

No. But I can help you with instruction how you can catch a crash by yourself.

You have to download Visual Studio and PvPGN Dev Kit. Follow instruction in description to Dev Kit how to run your PvPGN source with debugging.
Also, please translate this article (section with debugging example).

But i using linux , need to make into windows firts ??

6

Re: [solved] please helpe me new command for /getclan

Sure, you can develop/debug server on your desktop machine on Windows and then patch your server on Linux.

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 → [solved] please helpe me new command for /getclan



Generated in 0.090 seconds (74% PHP - 26% DB) with 20 queries