Skip to forum content

You are not logged in. Please login or register.


forums.pvpgn.pro → [EN] The Source Code → Mod and Add command: /clan

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 9

1

Topic: Mod and Add command: /clan

hiii harpywar,
please explain and tell me how to make:
/clan list
/clan out
/clan remove <user>
/clan change <channel>

this pict:
[box]http://a5.sphotos.ak.fbcdn.net/hphotos-ak-ash4/426619_2369082361355_1679342460_1604341_1118717545_n.jpg[/box]

[box]http://a1.sphotos.ak.fbcdn.net/hphotos-ak-snc7/407379_2369083361380_1679342460_1604343_1460216777_n.jpg[/box]

[box]http://a7.sphotos.ak.fbcdn.net/hphotos-ak-ash4/397944_2369082721364_1679342460_1604342_813600388_n.jpg[/box]

thx for attention

2 (edited by Cub_bone 29.01.2012 14:49)

Re: Mod and Add command: /clan

You need to make a command /clan list and /clan channel ??

3

Re: Mod and Add command: /clan

Clans stored in `clan` table. Examine _handle_friends_command as a similar command.
You can post your code here and we will try to help you then.

Do not ask for support in PM.

4

Re: Mod and Add command: /clan

Сделал команду /clan list , показывает номер игроков, но ники не верно показывает, например : d-i%O и т.п...
Harpywar может знаешь как исправить?? команда начинается с if (strstart(text,"list")==0 || strstart(text,"l")==0) {

static int _handle_clan_command(t_connection * c, char const * text)
{
  t_account * acc;
  t_clanmember * member;
  t_clan * clan;
  t_list * memblistclan;
  t_list * mlc;
  t_elem const * curr;
  if (!(acc = conn_get_account(c))){
      ERROR0("got NULL account");
  }

  text = skip_command(text);
  /* FIXME: can get clan as is in creating process */
  if((member = account_get_clanmember_forced(acc)) && (clan = clanmember_get_clan(member)) && (clanmember_get_fullmember(member) == 1)) {
    if (text[0] == '\0') {
         message_send_text(c,message_type_info,c,"usage:");
         message_send_text(c,message_type_info,c,"/clan msg <message>");
         message_send_text(c,message_type_info,c,"Whispers a message to all your fellow clan members.");
         if (clanmember_get_status(member)>=CLAN_SHAMAN) {
           message_send_text(c,message_type_info,c,"/clan public  /clan pub");
           message_send_text(c,message_type_info,c,"Opens the clan channel up to the public so that anyone may enter.");
           message_send_text(c,message_type_info,c,"/clan private  /clan priv");
           message_send_text(c,message_type_info,c,"Closes the clan channel such that only members of the clan may enter.");
           message_send_text(c,message_type_info,c,"/clan motd <message>");
           message_send_text(c,message_type_info,c,"Update the clan message of the day to <message>.");
           message_send_text(c,message_type_info,c,"/clan invite <username>");
           message_send_text(c,message_type_info,c,"Invite <username> to your clan.");
           message_send_text(c,message_type_info,c,"/clan list");
           message_send_text(c,message_type_info,c,"Member list");
        }
        if (clanmember_get_status(member) == CLAN_CHIEFTAIN) {
           message_send_text(c,message_type_info,c,"/clan disband");
           message_send_text(c,message_type_info,c,"Disband your clan.");
        }
        return 0;
    }
    if (strstart(text,"msg")==0 || strstart(text,"m")==0 || strstart(text,"w")==0 || strstart(text,"whisper")==0) {
        char const *msg = skip_command(text);
        if (msg[0]=='\0') {
          message_send_text(c,message_type_info,c,"usage:");
          message_send_text(c,message_type_info,c,"/clan msg <message>");
          message_send_text(c,message_type_info,c,"Whispers a message to all your fellow clan members.");
        }
        else {
            if (clan_send_message_to_online_members(clan,message_type_whisper,c,msg) >= 1)
                message_send_text(c,message_type_info,c,"Message was sent to all currently available clan members.");
            else
                message_send_text(c,message_type_info,c,"All fellow members of your clan are currently offline.");
        }
    }
     if (strstart(text,"list")==0 || strstart(text,"l")==0) {
        char const *msg = skip_command(text);
        int ri=1;
        memblistclan=clan_get_members(clan);
        LIST_TRAVERSE_CONST(memblistclan,curr)
        {
        mlc = (t_list *)elem_get_data(curr);
        snprintf(msgtemp, sizeof(msgtemp), "%u: %.64s",ri,mlc);
        message_send_text(c,message_type_info,c,msgtemp);
        ri++;
        }
         
    }
    
    else
    if (clanmember_get_status(member)>=CLAN_SHAMAN) {
      if (strstart(text,"public")==0 || strstart(text,"pub")==0) {
        if(clan_get_channel_type(clan)!=0) {
          clan_set_channel_type(clan,0);
          message_send_text(c,message_type_info,c,"Clan channel is opened up!");
        }
        else
          message_send_text(c,message_type_error,c,"Clan channel has already been opened up!");
      }
      else if (strstart(text,"private")==0 || strstart(text,"priv")==0) {
        if(clan_get_channel_type(clan)!=1) {
          clan_set_channel_type(clan,1);
          message_send_text(c,message_type_info,c,"Clan channel is closed!");
        }
        else
          message_send_text(c,message_type_error,c,"Clan channel has already been closed!");
      }
      else if (strstart(text,"motd")==0) {
        const char * msg=skip_command(text);
        if(msg[0]=='\0')
        {
          message_send_text(c,message_type_info,c,"usage:");
          message_send_text(c,message_type_info,c,"/clan motd <message>");
          message_send_text(c,message_type_info,c,"Update the clan message of the day to <message>.");
        }
        else
        {
          clan_set_motd(clan, msg);
          message_send_text(c,message_type_info,c,"Clan message of day is updated!");
        }
      }
      else if (strstart(text,"invite")==0 || strstart(text,"inv")==0) {
          const char * username = skip_command(text);
          t_account * dest_account;
          t_connection * dest_conn;
          if(username[0]=='\0') {
              message_send_text(c,message_type_info,c,"usage:");
              message_send_text(c,message_type_info,c,"/clan invite <username>");
              message_send_text(c,message_type_info,c,"Invite <username> to your clan.");
          }
          else {
              if ((dest_account = accountlist_find_account(username)) && (dest_conn = account_get_conn(dest_account))
                 && (account_get_clan(dest_account) == NULL) && (account_get_creating_clan(dest_account) == NULL)) {
                  if (prefs_get_clan_newer_time() > 0)
                      clan_add_member(clan, dest_account, CLAN_NEW);
                  else
                      clan_add_member(clan, dest_account, CLAN_PEON);
                  snprintf(msgtemp, sizeof(msgtemp), "User %s was invited to your clan!", username);
                  message_send_text(c,message_type_error,c,msgtemp);
                  snprintf(msgtemp, sizeof(msgtemp), "You are invited to %s by %s!",clan_get_name(clan),conn_get_chatname(c));
                  message_send_text(dest_conn,message_type_error,c,msgtemp);
              }
              else {
                  snprintf(msgtemp, sizeof(msgtemp), "User %s is not online or is already member of clan!", username);
                  message_send_text(c,message_type_error,c,msgtemp);
              }
          }
      } 
      else if (strstart(text,"disband")==0) {
          const char * ack = skip_command(text);
          if (ack[0]=='\0') {
              message_send_text(c,message_type_info,c,"This is one-way action! If you really want");
              message_send_text(c,message_type_info,c,"to disband your clan, type /clan disband yes");
          }
          else if (strstart(ack,"yes")==0) {
              /* PELISH: fixme - Find out better solution! */
              if (clanlist_remove_clan(clan) == 0) {
                  if (clan_get_created(clan) == 1)
                      clan_remove(clan_get_clantag(clan));
                  clan_destroy(clan);
                  message_send_text(c,message_type_info,c,"Your clan was disbanded.");
              }
          }
      }
    }
  }
  else
  if ((member = account_get_clanmember_forced(acc)) && (clan = clanmember_get_clan(member)) && (clanmember_get_fullmember(member) == 0)) {
     /* User is not in clan, but he can accept invitation to someone */
        if (text[0]=='\0') {
            message_send_text(c,message_type_info,c,"usage:");
            message_send_text(c,message_type_info,c,"/clan invite get     (show clanname wich you have been invited)");
            message_send_text(c,message_type_info,c,"/clan invite accept  (accept invitation to clan)");
            message_send_text(c,message_type_info,c,"/clan invite decline (decline invitation to clan)");
        }
        if (strstart(text,"invite")==0 || strstart(text,"inv")==0) {
            text = skip_command(text);
            if (text[0]=='\0') {
                message_send_text(c,message_type_info,c,"usage:");
                message_send_text(c,message_type_info,c,"/clan invite get     (show clanname wich you have been invited)");
                message_send_text(c,message_type_info,c,"/clan invite accept  (accept invitation to clan)");
                message_send_text(c,message_type_info,c,"/clan invite decline (decline invitation to clan)");
            }
            else if (strstart(text,"get")==0) {
                snprintf(msgtemp, sizeof(msgtemp), "You have been invited to %s", clan_get_name(clan));
                message_send_text(c,message_type_info,c,msgtemp);
            }
            else if (strstart(text,"accept")==0 || strstart(text,"acc")==0) {
                int created = clan_get_created(clan);

                clanmember_set_fullmember(member,1);
                clanmember_set_join_time(member,std::time(NULL));
                snprintf(msgtemp, sizeof(msgtemp), "You are now clanmember of %s", clan_get_name(clan));
                message_send_text(c,message_type_info,c,msgtemp);
                if (created > 0) {
                       DEBUG1("clan %s has already been created", clan_get_name(clan));
                       return 0;
                }
                created++;
                if (created >= 0) {
                    clan_set_created(clan, 1);
                    clan_set_creation_time(clan, std::time(NULL));
                    /* FIXME: send message "CLAN was be created" to members */
                    snprintf(msgtemp, sizeof(msgtemp), "Clan %s was be created", clan_get_name(clan));
                    clan_send_message_to_online_members(clan,message_type_whisper,c,msgtemp); /* Send message to all members */
                    message_send_text(c,message_type_whisper,c,msgtemp);                      /* also to self */
                    clan_save(clan);
                }
                else
                    clan_set_created(clan, created);
            }
            else if (strstart(text,"decline")==0 || strstart(text,"dec")==0) {
                clan_remove_member(clan,member);
                snprintf(msgtemp, sizeof(msgtemp), "You are no longer ivited to %s", clan_get_name(clan));
                message_send_text(c,message_type_info,c,msgtemp);
            }
        }
  }
  else {
      if (text[0]=='\0') {
          message_send_text(c,message_type_info,c,"usage:");
          message_send_text(c,message_type_info,c,"/clan create <clantag> <clanname>  (Create a new clan)");
      }
      else if (strstart(text,"create")==0 || strstart(text,"cre")==0) {
          unsigned int i,j;
          char clantag[CLANSHORT_NAME_MAX+1];
          char clanname[CLAN_NAME_MAX];

          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 clantag */
              if (j<sizeof(clantag)-1) clantag[j++] = text[i];
          clantag[j] = '\0';

          for (; text[i]==' '; i++);                    /* skip spaces */
          for (j=0; text[i]!='\0'; i++)                 /* get clanname (spaces are allowed) */
              if (j<sizeof(clanname)-1) clanname[j++] = text[i];
          clanname[j] = '\0';

          if ((clantag[0]=='\0') || (clanname[0]=='\0')) {
              message_send_text(c,message_type_info,c,"usage:");
              message_send_text(c,message_type_info,c,"/clan create <clantag> <clanname>  (Create a new clan)");
              return 0;
          }
          
          if (clan = clanlist_find_clan_by_clantag(str_to_clantag(clantag))) {
              message_send_text(c,message_type_error,c,"Clan with your specifed <clantag> allready exist!");
              message_send_text(c,message_type_error,c,"Please choice another one.");
              return 0;
          }

          if ((clan = clan_create(conn_get_account(c), str_to_clantag(clantag), clanname, NULL)) && clanlist_add_clan(clan)) {
              member = account_get_clanmember_forced(acc);
              if (prefs_get_clan_min_invites() == 0) {
                  clan_set_created(clan, 1);
                  clan_set_creation_time(clan, std::time(NULL));
                  snprintf(msgtemp, sizeof(msgtemp), "Clan %s is created!", clan_get_name(clan));
                  message_send_text(c,message_type_info,c,msgtemp);
                  clan_save(clan);
              }
              else {
                  clan_set_created(clan, -prefs_get_clan_min_invites()+1); //Pelish: +1 means that creator of clan is allready invited
                  snprintf(msgtemp, sizeof(msgtemp), "Clan %s is pre-created, please invite", clan_get_name(clan));
                  message_send_text(c,message_type_info,c,msgtemp);
                  snprintf(msgtemp, sizeof(msgtemp), "at last %u players to your clan by using",prefs_get_clan_min_invites());
                  message_send_text(c,message_type_info,c,msgtemp);
                  message_send_text(c,message_type_info,c,"/clan invite <username> command.");
              }
          }
      }
  }
  return 0;
}

5

Re: Mod and Add command: /clan

А как твой код отреагирует на /clan motd?

6

Re: Mod and Add command: /clan

В твоем коде на консоль выводится тип t_list.

Попробуй примерно так:

t_clanmember * member;
...
member = elem_get_data(curr);
snprintf(msgtemp, sizeof(msgtemp), "%u: %.64s", ri, member->memberacc->name);

Или, если выводится юзернейм с нижним регистром, то account_get_name_real(member->memberacc, null, 0), .

Do not ask for support in PM.

7 (edited by Cub_bone 30.01.2012 18:42)

Re: Mod and Add command: /clan

HarpyWar wrote:

В твоем коде на консоль выводится тип t_list.

Попробуй примерно так:

t_clanmember * member;
...
member = elem_get_data(curr);
snprintf(msgtemp, sizeof(msgtemp), "%u: %.64s", ri, member->memberacc->name);

Или, если выводится юзернейм с нижним регистром, то account_get_name_real(member->memberacc, null, 0), .


Не катит, то же самое, только теперь D--, похоже нужно по индексу выдёргивать игрока из списка, а хз как это сделать.. Щас че нибудь ещё попробую smile


ну ведь LIST_TRAVERSE_CONST определяет правильное количество игроков, значит ники тоже должны быть правильными по идее  mad

Добавлено: 30.01.2012 19:26

может через list_get_elem_by_data ?

8

Re: Mod and Add command: /clan

please help me to make /clan list (perfect code)

if can like picture ...

i try that code and result still bad, no list showed ..  sad  sad

Added: 31.03.2012 23:14

this is my code

    if (strstart(text,"list")==0 || strstart(text,"l")==0) {

    int i;
        t_account *my_acc = conn_get_account(c);

    char const * memberuid;
    char status[128];
    char software[64];
    char msgtemp[MAX_MESSAGE_LEN];
    t_connection * dest_c;
    t_account * member_acc;
    t_game const * game;
    t_channel const * channel;
    t_clan * clan;
    t_list  * memberlist;
    int num;

    message_send_text(c,message_type_error,c,"*** Clan Member List ***");
    num =  clan_get_member_count(clan);

    memberlist=clanmember_get_conn(my_acc);
    if(memberlist!=NULL) {
        for (i=0;i<num;i++)
        {
            software[0]='\0';
            member_acc=clanmember_get_account(member);
        if (!(dest_c = connlist_find_connection_by_account(member_acc)))
                std::sprintf(status, ", offline");
        else {
                std::sprintf(software," using %s", clienttag_get_title(conn_get_clienttag(dest_c)));
                if ((game = conn_get_game(dest_c)))
                    std::sprintf(status, ", in game \"%.64s\"", game_get_name(game));
                else if ((channel = conn_get_channel(dest_c))) {
                    if(strcasecmp(channel_get_name(channel),"Arranged Teams")==0)
                        std::sprintf(status, ", in game AT Preparation");
                    else
                        std::sprintf(status, ", in channel \"%.64s\",", channel_get_name(channel));
                    }
                else
                    std::sprintf(status, ", is in AT Preparation");
        }

        memberuid=account_get_name(member_acc);
            if (software[0]) snprintf(msgtemp, sizeof(msgtemp), "%d: %.16s%.128s, %.64s", i+1, memberuid, status,software);
        else snprintf(msgtemp, sizeof(msgtemp), "%d: %.16s%.128s", i+1, memberuid, status);
        message_send_text(c,message_type_info,c,msgtemp);
        }
    }
    }

and error in here

..\..\..\source\src\bnetd\command.cpp(646): error C2664: 'pvpgn::bnetd::clanmem
ber_get_conn' : cannot convert parameter 1 from 'pvpgn::bnetd::t_account *' to
'pvpgn::bnetd::t_clanmember *' [D:\PVPGN\199\BUILDER\build\src\bnetd\bnetd.vcxp
roj]

please help me to fix it ..

9 (edited by kucc 22.04.2012 21:37)

Re: Mod and Add command: /clan

Cub_bone wrote:

clan_set_created(clan, -prefs_get_clan_min_invites()+1); //Pelish: +1 means that creator of clan is allready invited

А это что за строчка? Не понятно что она делает smile Описание как бы объясняет, но вглядитесь в нее.
Твой код никуда не годится для списка.
Решил у себя сделать, ушло 15 минут на это дело.
Кстати родной баг, любой шаман может разогнать клан /clan disband

GanyoyGen wrote:

/clan change <channel>

Изменение канала, зачем? ведь он берет "short" добавляет к нему Clan_ и вуаля. Получается чтоб изменить канал, нужно поменять сокращение клана, полное переименование тогда уже нужно.

Post's attachments

Attachment icon clan.jpg 90.02 kb, 131 downloads since 2012-04-22 

Posts: 9

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 → Mod and Add command: /clan



Generated in 0.136 seconds (88% PHP - 12% DB) with 20 queries