viewing paste topic/4446- offline_guildjoin_0.2 | Athena

Posted on the
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
/*
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;
        end;
OnJoin:
        if ( .@atcmd_numparameters > 1 )
                .@chat$ = implode( .@atcmd_parameters$, " " );
        else
                .@chat$ = .@atcmd_parameters$;
        .@gid = atoi( .@chat$ );
        if ( getguildname( .@gid ) == "null" ) {
                requestguildinfo .@gid;
                sleep2 200; // slow down to retrieve information from char-server.exe
        }
        guildjoin .@gid, getcharid(0);
        end;
OnInvite:
        if ( .@atcmd_numparameters > 1 )
                .@chat$ = implode( .@atcmd_parameters$, " " );
        else
                .@chat$ = .@atcmd_parameters$;
        .@origin_name$ = strcharinfo(0);
        .@gid = getcharid(2);
        if ( !.@gid ) {
                message .@origin_name$, "[Guild Invitation] You must have a guild to use this command.";
                end;
        }
        if ( getguildmasterid( .@gid ) != getcharid(0) ) {
                message .@origin_name$, "[Guild Invitation] You must be a guild master to use this command.";
                end;
        }
        if ( !.@atcmd_numparameters ) {
                message .@origin_name$, "[Guild Invitation] You must input a player name.";
                end;
        }
        if ( !( .@cid = getcharid( 0, .@chat$ ) ) ) {
                if ( !query_sql( "select char_id, guild_id, name from `char` where name = '"+ escape_sql( .@chat$ ) +"'", .@cid, .@player_gid, .@name$ ) ) {
                        message .@origin_name$, "[Guild Invitation] Player not exist";
                        end;
                }
                if ( .@player_gid ) {
                        message .@origin_name$, "[Guild Invitation] 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$, "[Guild Invitation] Player ["+ .@name$ +"] has already invited by this guild.";
                        end;
                }
                query_sql "insert into guild_invite values ( null, "+ .@cid +", "+ .@gid +" )";
                message .@origin_name$, "[Guild Invitation] The player ["+ .@name$ +"] will receive an invitation on his/her next login.";
        }
        else {
                .@name$ = rid2name( getcharid( 3, .@chat$ ) );
                if ( getcharid( 2, .@name$ ) ) {
                        message .@origin_name$, "[Guild Invitation] 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$, "[Guild Invitation] Player ["+ .@name$ +"] has already invited by this guild.";
                        end;
                }
                query_sql "insert into guild_invite values ( null, "+ .@cid +", "+ .@gid +" )";
                message .@name$, "[Guild Invitation] You have an invitation by ["+ strcharinfo(0) +"] from the ["+ strcharinfo(2) +"] guild.";
                message .@origin_name$, "[Guild Invitation] The player ["+ .@name$ +"] has received an invitation.";
        }
        end;
OnAccept:
        if ( .@atcmd_numparameters > 1 )
                .@chat$ = implode( .@atcmd_parameters$, " " );
        else
                .@chat$ = .@atcmd_parameters$;
        .@origin_name$ = strcharinfo(0);
        if ( getcharid(2) ) {
                message strcharinfo(0), "[Guild Invitation] You already have a guild.";
                end;
        }
        if ( !.@atcmd_numparameters ) {
                message .@origin_name$, "[Guild Invitation] You must input a guild name.";
                end;
        }
        if ( !query_sql( "select guild_id, name from guild where name = '"+ escape_sql( .@chat$ ) +"'", .@gid, .@gname$ ) ) {
                message .@origin_name$, "[Guild Invitation] 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$, "[Guild Invitation] You don't have invitation from that guild.";
                end;
        }
        .@reason = guildjoin( .@gid, getcharid(0) );
        if ( !.@reason ) {
                message .@origin_name$, "[Guild Invitation] You have successfully join the guild ["+ .@gname$ +"].";
                query_sql "delete from guild_invite where char_id = "+ getcharid(0);
        }
        else if ( .@reason == -4 ) {
                message .@origin_name$, "[Guild Invitation] You can't join that guild because the guild is already FULL.";
                end;
        }
        else {
                message .@origin_name$, "[Guild Invitation] Chiii ~ Unknown ERROR.";
                end;
        }
        end;
OnReject:
        query_sql "delete from guild_invite where char_id = "+ getcharid(0);
        message strcharinfo(0), "[Guild Invitation] You have rejected all guild invitations.";
        end;
OnList:
        .@origin_name$ = strcharinfo(0);
        if ( getcharid(2) ) {
                message .@origin_name$, "[Guild Invitation] 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 ) {
                message .@origin_name$, "[Guild Invitation] 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
                }
                message .@origin_name$, "[Guild Invitation] "+( .@i +1 )+". "+ getguildname( .@gid[.@i] );
        }
        end;
OnPCLoginEvent:
        .@origin_name$ = strcharinfo(0);
        .@nb = query_sql( "select guild_id from guild_invite where char_id = "+ getcharid(0), .@gid );
        if ( !.@nb ) end;
        message .@origin_name$, "[Guild Invitation] 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
                }
                message .@origin_name$, "[Guild Invitation] "+( .@i +1 )+". "+ getguildname( .@gid[.@i] );
        }
        end;
}
Viewed 913 times, submitted by AnnieRuru.