viewing paste topic/4446- offline_guildjoin_0.1 | Athena

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
/*
create table guild_invite (
id int(11) unsigned primary key auto_increment,
char_id int(11) unsigned,
guild_id int(11) unsigned,
key (char_id),
key (guild_id),
unique (char_id,guild_id)
) engine = innodb;
*/
 
-       script  kjhlkjgsdfds    -1,{
OnInit:
        bindatcmd "guildinvite", strnpcinfo(0)+"::OnInvite", 0,100;
        bindatcmd "guildaccept", strnpcinfo(0)+"::OnAccept", 0,100;
        bindatcmd "guildreject", strnpcinfo(0)+"::OnReject", 0,100;
        bindatcmd "invitelist", strnpcinfo(0)+"::OnList", 0,100;
//      bindatcmd "guildjoin", strnpcinfo(0)+"::OnJoin", 0,100,0;
        end;
OnJoin:
        .@gid = atoi( .@atcmd_parameters$ );
        if ( getguildname( .@gid ) == "null" ) {
                requestguildinfo .@gid;
                sleep2 200; // slow down to retrieve information from char-server.exe
        }
        guildjoin .@gid, getcharid(0);
        end;
OnInvite:
        .@origin_name$ = strcharinfo(0);
        .@gid = getcharid(2);
        if ( !.@gid ) {
                message .@origin_name$, "You must have a guild to use this command.";
                end;
        }
        if ( getguildmasterid( .@gid ) != getcharid(0) ) {
                message .@origin_name$, "You must be a guild master to use this command.";
                end;
        }
        if ( !( .@cid = getcharid( 0, .@atcmd_parameters$ ) ) ) {
                if ( !query_sql( "select char_id, guild_id, name from `char` where name = '"+ escape_sql( .@atcmd_parameters$ ) +"'", .@cid, .@player_gid, .@name$ ) ) {
                        message .@origin_name$, "Player not exist";
                        end;
                }
                if ( .@player_gid ) {
                        message .@origin_name$, "Player ["+ .@name$ +"] already has a guild.";
                        end;
                }
                if ( query_sql( "select 1 from guild_invite where char_id = "+ .@cid +" and guild_id = "+ .@gid, .@dummy ) ) {
                        message .@origin_name$, "Player ["+ .@name$ +"] has already invited by this guild.";
                        end;
                }
                query_sql "insert into guild_invite values ( null, "+ .@cid +", "+ .@gid +" )";
                message .@origin_name$, "The player ["+ .@name$ +"] will receive an invitation on his/her next login.";
        }
        else {
                .@name$ = rid2name( getcharid( 3, .@atcmd_parameters$ ) );
                if ( getcharid( 2, .@name$ ) ) {
                        message .@origin_name$, "Player ["+ .@name$ +"] already has a guild.";
                        end;
                }
                if ( query_sql( "select 1 from guild_invite where char_id = "+ .@cid +" and guild_id = "+ .@gid, .@dummy ) ) {
                        message .@origin_name$, "Player ["+ .@name$ +"] has already invited by this guild.";
                        end;
                }
                query_sql "insert into guild_invite values ( null, "+ .@cid +", "+ .@gid +" )";
                message .@name$, "You have an invitation by ["+ strcharinfo(0) +"] from the ["+ strcharinfo(2) +"] guild.";
                message .@origin_name$, "The player ["+ .@name$ +"] has received an invitation.";
        }
        end;
OnAccept:
        .@origin_name$ = strcharinfo(0);
        if ( getcharid(2) ) {
                message strcharinfo(0), "You already have a guild.";
                end;
        }
        if ( !query_sql( "select guild_id from guild where name = '"+ escape_sql( .@atcmd_parameters$ ) +"'", .@gid ) ) {
                message .@origin_name$, "No such guild name exist.";
                end;
        }
        if ( getguildname( .@gid ) == "null" ) {
                requestguildinfo .@gid;
                sleep2 200; // slow down to retrieve information from char-server.exe
        }
        if ( !query_sql( "select 1 from guild_invite where char_id = "+ getcharid(0) +" and guild_id = "+ .@gid, .@dummy ) ) {
                message .@origin_name$, "You don't have invitation from that guild.";
                end;
        }
        guildjoin .@gid, getcharid(0);
        query_sql "delete from guild_invite where char_id = "+ getcharid(0);
        end;
OnReject:
        query_sql "delete from guild_invite where char_id = "+ getcharid(0);
        message strcharinfo(0), "You have rejected all guild invitations.";
        end;
OnList:
        if ( getcharid(2) ) {
                dispbottom "You already have a guild";
//              query_sql "delete from guild_invite where char_id = "+ getcharid(0);
                end;
        }
        .@nb = query_sql( "select guild_id from guild_invite where char_id = "+ getcharid(0), .@gid );
        if ( !.@nb ) {
                dispbottom "You don't have any guild invitation.";
                end;
        }
        for ( .@i = 0; .@i < .@nb; .@i++ ) {
                if ( getguildname( .@gid[.@i] ) == "null" ) {
                        requestguildinfo .@gid[.@i];
                        sleep2 200; // slow down to retrieve information from char-server.exe
                }
                dispbottom ( .@i +1 )+". "+ getguildname( .@gid[.@i] );
        }
        end;
OnPCLoginEvent:
        .@nb = query_sql( "select guild_id from guild_invite where char_id = "+ getcharid(0), .@gid );
        if ( !.@nb ) end;
        dispbottom "You have "+ .@nb +" pending guild invitations";
        for ( .@i = 0; .@i < .@nb; .@i++ ) {
                if ( getguildname( .@gid[.@i] ) == "null" ) {
                        requestguildinfo .@gid[.@i];
                        sleep2 200; // slow down to retrieve information from char-server.exe
                }
                dispbottom ( .@i +1 )+". "+ getguildname( .@gid[.@i] );
        }
        end;
}
Viewed 763 times, submitted by AnnieRuru.