Skip to forum content

You are not logged in. Please login or register.


forums.pvpgn.pro → [EN] The Source Code → /clan create "help please"

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 7

1

Topic: /clan create "help please"

I could correct the code please

    else if (acc &&(strstart(text,"create")==0 || strstart(text,"c")==0))
    {
        t_packet     * rpacket;
        t_connection     * dest_c;
        t_account        * friend_acc,*account;
        t_server_friendslistreply_status status;
        t_game * game;
        t_channel * channel;
        char stat;
        t_clanmember *member;
        int i,j;
        char const *tag,*clanname, *mem[4];
        int created, clantag;
        t_clan *clan;
        const int CLANMEM=4;

        tag = skip_command(text);
        clanname = skip_command(tag);
        mem[0]=skip_command(clanname);
        mem[1]=skip_command(mem[0]);
        mem[2]=skip_command(mem[1]);
        mem[3]=skip_command(mem[2]);



        if (tag[0] == '\0' || clanname[0] == '\0')
        {
            message_send_text(c,message_type_info,c,"usage: /c create <Nick clan> <Canal clan> <ID-1> <ID-2> <ID-3> <ID-4>");
            return 0;
        }
        for(i=0;i<CLANMEM;i++)
        {
            if(mem[i][0] ==0)
            {
                message_send_text(c,message_type_info,c,"usage: /c create <Nick clan> <Canal clan> <ID-1> <ID-2> <ID-3> <ID-4>");
                return 0;
            }
        }
        if(strlen(tag)!=4)
        {
            message_send_text(c,message_type_error,c,"Clan Nick es una palabra de cuatro letras con las letras y los números");
            return 0;
        }
        for(i=0;i<4;i++)
        {
            j=0;
            if(tag[i]>='a'&&tag[i]<='z')
                j=1;
            if(!j&&tag[i]>='A'&&tag[i]<='Z')
                j=1;
            if(!j&&tag[i]>='0'&&tag[i]<='9')
                j=1;
            if(j==0)break;
        }
        if(i!=4)
        {
            message_send_text(c,message_type_error,c,"Clan Nick es una palabra de cuatro letras con las letras y los números");
            return 0;
        }
        clantag=str_to_clantag(tag);
        if(clanlist_find_clan_by_clantag(clantag)!=NULL)
        {
            message_send_text(c,message_type_error,c,"Nick Del clan que ya existe.");
            return 0;
        }
        if(clanlist_find_clan_by_clanname(clanname)!=NULL)
        {
            message_send_text(c,message_type_error,c,"Canal Del Clan ya está presente.");
            return 0;
        }
        if ((account = conn_get_account(c)) && (account_get_clan(account) != NULL))
        {
            message_send_text(c,message_type_error,c,"Es un miembro de este clan.");
            return 0;
        }
        for (i=0;i<CLANMEM;i++)
        {
            if (!(friend_acc = accountlist_find_account(mem[i]))) {
                sprintf(msgtemp,"%dUna segunda entrada %s El usuario no existe",i+1,mem[i]);
                message_send_text(c,message_type_error,c,msgtemp);
                return 0;
            }
            if(conn_get_account(c)==friend_acc)
            {
                message_send_text(c,message_type_error,c,"Mismos no pueden registrarse como miembro del Clan");
                return 0;
            }
            if(account_get_numattr(friend_acc,"BNET\\joinclan")!=clantag)
            {
                sprintf(msgtemp, "%sNo estaba de acuerdo con. (¿ aceptar : /clan join Nick clan)", mem[i]);
                message_send_text(c,message_type_error,c,msgtemp);
                return 0;
            }
            for(j=i+1;j<CLANMEM;j++)
            {
                if(0==strcasecmp(mem[i],mem[j]))
                {
                    message_send_text(c,message_type_error,c,"Existe Duplicado ID.");
                    return 0;
                }
            }
        }
        if(clanlist_find_clan_by_clantag(clantag)!=NULL)
        {
            message_send_text(c,message_type_error,c,"Nick de clan que ya existe.");
            return 0;
        }
        if (!(clan = clan_create(account, clantag, clanname, NULL))) {
            message_send_text(c,message_type_error,c,"Clan del error generado(1)");
            return 0;
        }
        if (clanlist_add_clan(clan)==-1) {
            message_send_text(c,message_type_error,c,"Clan del error generado(2)");
            return 0;
        }
        clan_set_created(clan,120);
        //clanlog(clan_get_clantag(clan),"CI",clanname,0);
        //clanlog(clan_get_clantag(clan),"MI",account_get_name(acc),1);
        for (i=0;i<CLANMEM;i++)
        {
            clan_add_member(clan, accountlist_find_account(mem[i]), CLAN_NEW);
            //clanlog(clan_get_clantag(clan),"MI",mem[i],0);
        }
        message_send_text(c,message_type_info,c,"Clan ha sido creado.");
        return 0;
    }
 errror if(clanlist_find_clan_by_clanname(clanname)!=NULL) identifier not found 

2 (edited by Zeloit 21.06.2013 13:26)

Re: /clan create "help please"

Dante wrote:
 errror if(clanlist_find_clan_by_clanname(clanname)!=NULL) identifier not found 

-_-
Not indentifier? first, create code clanlist_find_clan_by_clanname   -_-


This is code on clan.cpp:

extern t_clan *clanlist_find_clan_by_clanname(char const * clanname)
{
    t_entry *curr;
    t_clan *clan;

    if (clanname == 0)
        return NULL;
    if (clanlist_head_name)
    {
        HASHTABLE_TRAVERSE_MATCHING(clanlist_head_name, curr,clan_hash(clanname))
        {
            if (!(clan = (t_clan*)entry_get_data(curr)))
            {
                eventlog(eventlog_level_error, __FUNCTION__, "found NULL entry in list");
                continue;
            }
            if (clan->created && (strcasecmp(clan->clanname,clanname)==0))
                return clan;
        }

    }

    return NULL;
}

this is code on clan.h:

extern t_clan *clanlist_find_clan_by_clanname(char const * clanname);

3

Re: /clan create "help please"

Zeloit wrote:
Dante wrote:
 errror if(clanlist_find_clan_by_clanname(clanname)!=NULL) identifier not found 

-_-
Not indentifier? first, create code clanlist_find_clan_by_clanname   -_-


This is code on clan.cpp:

extern t_clan *clanlist_find_clan_by_clanname(char const * clanname)
{
    t_entry *curr;
    t_clan *clan;

    if (clanname == 0)
        return NULL;
    if (clanlist_head_name)
    {
        HASHTABLE_TRAVERSE_MATCHING(clanlist_head_name, curr,clan_hash(clanname))
        {
            if (!(clan = (t_clan*)entry_get_data(curr)))
            {
                eventlog(eventlog_level_error, __FUNCTION__, "found NULL entry in list");
                continue;
            }
            if (clan->created && (strcasecmp(clan->clanname,clanname)==0))
                return clan;
        }

    }

    return NULL;
}

this is code on clan.h:

extern t_clan *clanlist_find_clan_by_clanname(char const * clanname);

sorry if I do not explain, this is my code

else if (acc &&(strstart(text,"join")==0 || strstart(text,"j")==0))
    {
        t_packet     * rpacket;
        t_connection     * dest_c;
        t_account        * friend_acc;
        t_server_friendslistreply_status status;
        t_game * game;
        t_channel * channel;
        char stat;
        t_clanmember *member;
        int i,j;
        char tag[4];

        text = skip_command(text);

        if (text[0] == '\0') {
            j=account_get_numattr(acc,"BNET\\joinclan");
            if(j)
            {
                sprintf(msgtemp,"Nick aceptó unirse a clanes ahora : '%c$c$c$c'",(j>>24)&0xff,(j>>16)&0xff,(j>>8)&0xff,(j)&0xff);
                message_send_text(c,message_type_info,c,"usage: /c join <Nick clan>");
            }
            message_send_text(c,message_type_info,c,"usage: /c join <Nick clan>");
            return 0;
        }
        if(strlen(text)!=4)
        {
            message_send_text(c,message_type_info,c,"Clan Nick es una palabra de cuatro letras con las letras y los números");
            return 0;
        }
        for(i=0;i<4;i++)
        {
            tag[i]=text[i];
            j=0;
            if(tag[i]>='a'&&tag[i]<='z')
            {
                j=1;
            }
            if(!j&&tag[i]>='A'&&tag[i]<='Z')
                j=1;
            if(!j&&tag[i]>='0'&&tag[i]<='9')
                j=1;
            if(j==0)break;
        }
        if(i!=4)
        {
            message_send_text(c,message_type_info,c,"Clan Nick es una palabra de cuatro letras con las letras y los números");
            return 0;
        }
        account_set_numattr(acc,"BNET\\joinclan",str_to_clantag(tag));
        message_send_text(c,message_type_info,c,"está listo para ser invitado a un clan");
    }
    else if (acc &&(strstart(text,"create")==0 || strstart(text,"c")==0))
    {
        t_packet     * rpacket;
        t_connection     * dest_c;
        t_account        * friend_acc,*account;
        t_server_friendslistreply_status status;
        t_game * game;
        t_channel * channel;
        char stat;
        t_clanmember *member;
        int i,j;
        char const *tag,*clanname, *mem[4];
        int created, clantag;
        t_clan *clan;
        const int CLANMEM=4;

        tag = skip_command(text);
        clanname = skip_command(tag);
        mem[0]=skip_command(clanname);
        mem[1]=skip_command(mem[0]);
        mem[2]=skip_command(mem[1]);
        mem[3]=skip_command(mem[2]);



        if (tag[0] == '\0' || clanname[0] == '\0')
        {
            message_send_text(c,message_type_info,c,"usage: /c create <Nick clan> <Canal clan> <ID-1> <ID-2> <ID-3> <ID-4>");
            return 0;
        }
        for(i=0;i<CLANMEM;i++)
        {
            if(mem[i][0] ==0)
            {
                message_send_text(c,message_type_info,c,"usage: /c create <Nick clan> <Canal clan> <ID-1> <ID-2> <ID-3> <ID-4>");
                return 0;
            }
        }
        if(strlen(tag)!=4)
        {
            message_send_text(c,message_type_error,c,"Clan Nick es una palabra de cuatro letras con las letras y los números");
            return 0;
        }
        for(i=0;i<4;i++)
        {
            j=0;
            if(tag[i]>='a'&&tag[i]<='z')
                j=1;
            if(!j&&tag[i]>='A'&&tag[i]<='Z')
                j=1;
            if(!j&&tag[i]>='0'&&tag[i]<='9')
                j=1;
            if(j==0)break;
        }
        if(i!=4)
        {
            message_send_text(c,message_type_error,c,"Clan Nick es una palabra de cuatro letras con las letras y los números");
            return 0;
        }
        clantag=str_to_clantag(tag);
        if(clanlist_find_clan_by_clantag(clantag)!=NULL)
        {
            message_send_text(c,message_type_error,c,"Nick Del clan que ya existe.");
            return 0;
        }
        if(clanlist_find_clan_by_clanname(clanname)!=NULL)
        {
            message_send_text(c,message_type_error,c,"Canal Del Clan ya está presente.");
            return 0;
        }
        if ((account = conn_get_account(c)) && (account_get_clan(account) != NULL))
        {
            message_send_text(c,message_type_error,c,"Es un miembro de este clan.");
            return 0;
        }
        for (i=0;i<CLANMEM;i++)
        {
            if (!(friend_acc = accountlist_find_account(mem[i]))) {
                sprintf(msgtemp,"%dUna segunda entrada %s El usuario no existe",i+1,mem[i]);
                message_send_text(c,message_type_error,c,msgtemp);
                return 0;
            }
            if(conn_get_account(c)==friend_acc)
            {
                message_send_text(c,message_type_error,c,"Mismos no pueden registrarse como miembro del Clan");
                return 0;
            }
            if(account_get_numattr(friend_acc,"BNET\\joinclan")!=clantag)
            {
                sprintf(msgtemp, "%sNo estaba de acuerdo con. (¿ aceptar : /clan join Nick clan)", mem[i]);
                message_send_text(c,message_type_error,c,msgtemp);
                return 0;
            }
            for(j=i+1;j<CLANMEM;j++)
            {
                if(0==strcasecmp(mem[i],mem[j]))
                {
                    message_send_text(c,message_type_error,c,"Existe Duplicado ID.");
                    return 0;
                }
            }
        }
        if(clanlist_find_clan_by_clantag(clantag)!=NULL)
        {
            message_send_text(c,message_type_error,c,"Nick de clan que ya existe.");
            return 0;
        }
        if (!(clan = clan_create(account, clantag, clanname, NULL))) {
            message_send_text(c,message_type_error,c,"Clan del error generado(1)");
            return 0;
        }
        if (clanlist_add_clan(clan)==-1) {
            message_send_text(c,message_type_error,c,"Clan del error generado(2)");
            return 0;
        }
        clan_set_created(clan,120);
        //clanlog(clan_get_clantag(clan),"CI",clanname,0);
        //clanlog(clan_get_clantag(clan),"MI",account_get_name(acc),1);
        for (i=0;i<CLANMEM;i++)
        {
            clan_add_member(clan, accountlist_find_account(mem[i]), CLAN_NEW);
            //clanlog(clan_get_clantag(clan),"MI",mem[i],0);
        }
        message_send_text(c,message_type_info,c,"Clan ha sido creado.");
        return 0;
    }
    else if (acc &&(strstart(text,"check")==0))
    {
        t_packet     * rpacket;
        t_connection     * dest_c;
        t_account        * friend_acc,*account;
        t_server_friendslistreply_status status;
        t_game * game;
        t_channel * channel;
        char stat;
        t_clanmember *member;
        int i,j;
        char const *tag;
        int created, clantag;
        t_clan *clan;

        tag = skip_command(text);

        if (tag[0] == '\0')

4

Re: /clan create "help please"

sad

5

Re: /clan create "help please"

Zeloit wrote:

sad

thanks

6

Re: /clan create "help please"

Zeloit wrote:
Dante wrote:
 errror if(clanlist_find_clan_by_clanname(clanname)!=NULL) identifier not found 

-_-
Not indentifier? first, create code clanlist_find_clan_by_clanname   -_-


This is code on clan.cpp:

extern t_clan *clanlist_find_clan_by_clanname(char const * clanname)
{
    t_entry *curr;
    t_clan *clan;

    if (clanname == 0)
        return NULL;
    if (clanlist_head_name)
    {
        HASHTABLE_TRAVERSE_MATCHING(clanlist_head_name, curr,clan_hash(clanname))
        {
            if (!(clan = (t_clan*)entry_get_data(curr)))
            {
                eventlog(eventlog_level_error, __FUNCTION__, "found NULL entry in list");
                continue;
            }
            if (clan->created && (strcasecmp(clan->clanname,clanname)==0))
                return clan;
        }

    }

    return NULL;
}

3>..\..\..\source\src\bnetd\clan.cpp(844): error C2065: 'clanlist_head_name' : undeclared identifier
3>..\..\..\source\src\bnetd\clan.cpp(846): error C2065: 'clanlist_head_name' : undeclared identifier
3>..\..\..\source\src\bnetd\clan.cpp(847): error C2143: syntax error : missing ';' before '{'
3>..\..\..\source\src\bnetd\clan.cpp(846): error C3861: 'HASHTABLE_TRAVERSE_MATCHING': identifier not found
3>..\..\..\source\src\bnetd\clan.cpp(846): error C3861: 'clan_hash': identifier not found
3>..\..\..\source\src\bnetd\clan.cpp(848): error C3861: 'entry_get_data': identifier not found
3>..\..\..\source\src\bnetd\clan.cpp(851): error C2044: illegal continue


this is code on clan.h:

extern t_clan *clanlist_find_clan_by_clanname(char const * clanname);

7 (edited by Dante 27.06.2013 17:10)

Re: /clan create "help please"

ADD

in clan.cpp
add

static t_list *clanlist_name = NULL;
static t_list *clanlist_head_name = NULL;

extern t_clan *clanlist_find_clan_by_clanname(char const * clanname)
{
    t_elem *curr;
    t_clan *clan;

    if (clanname == 0)
        return NULL;
    if (clanlist_head_name)
    {
        LIST_TRAVERSE(clanlist_head_name, curr)
        {
            if (!(clan = (t_clan*)elem_get_data(curr)))
            {
                eventlog(eventlog_level_error, __FUNCTION__, "found NULL entry in list");
                continue;
            }
            if (clan->created && (strcasecmp(clan->clanname,clanname)==0))
                return clan;
        }

    }

    return NULL;
}

how to use the command?

Posts: 7

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 → /clan create "help please"