viewing paste [ Request ] Change Guild Leader | 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 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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
// =============================
/* Change Guild Leader: http://herc.ws/board/topic/13842-safely-transfer-guild-master/
    ----------------------------
    by: Legend
    compatible w/: Hercules
    ----------------------------
    Version: 1.2
    * Fixed wrong variable usage
    * Query through sql than "getguild***" functions
      to allow query without old guild leader to be online.
    * Added delay after guild leader transfer since we
      are using sql query which has certain seconds before it
      updates. (for safety purposes)
    ----------------------------
    special thanks to:
    * Dastgir (for pointing out the wrong variable usage)
    ----------------------------
    Description:
    * Allows Game Masters to safely transfer
      guild leader ownership to any members of the guild.
    * Can be triggered through "@guild" command or
      can also be triggered through NPC click.
    * Be careful and you must check the correct spelling of the name before 
      proceeding ( Upper & lower case letters and etc.)
    * No need for the old guild leader to be online.
    * New guild leader must be online.
    * Certain checks were applied for safe transfer purpose.
    ----------------------------
    Comments:
        Please report if bugs were found.
        Drop me a message: http://herc.ws/board/user/5387-legend/
*/
// =============================
 
prontera,159,173,4  script  Request#4   4_M_KNIGHT_GOLD,{
    doevent "Request#4::OnMain";
    end;
 
OnMain:
    if (getgmlevel() < .reqlvl) {
        mes .npc$;
        mes "You are not allowed to use this.";
        close;
    }
    mes .npc$;
    mes "Please provide the ^FF0000old^000000 guild leader name of the character correctly.";
    mes "^FF0000NOTE^000000:";
    mes "^FF0000-^000000 Double check the spelling.";
    mes "^FF0000-^000000 The character name you";
    mes "  will be providing should";
    mes "  be a guild leader.";
    mes "^FF0000-^000000 New Guild leader should be online.";
    input .@char$;
    next;
    .@check = query_sql("SELECT `account_id` FROM `char` WHERE `name`='"+escape_sql(.@char$)+"'",.@acid);
    if (!.@check) {
        mes .npc$;
        mes "Character [ ^FF0000"+.@char$+"^000000 ] doesn't exist!";
        close;
    }
    query_sql("SELECT `guild_id` FROM `char` WHERE `name`='"+escape_sql(.@char$)+"'",.@gldid);
    if (!.@gldid){
        mes .npc$;
        mes "Character [ ^FF0000"+.@char$+"^000000 ] isn't registered to any guild!";
        close;
    }
    if (.gcdone == .@gldid){
        if ( .delay > gettimetick(2) ){
        mes .npc$;
        mes "You must wait [^FF0000"+(.delay - gettimetick(2))+"^000000] seconds,";
        mes .@char$+"'s guild has been currently";
        mes "modified and changed their";
        mes "guild leader authority.";
        close;
        }
    }
    query_sql("SELECT `name` , `master` , `guild_lv` FROM `guild` WHERE `guild_id` = '"+.@gldid+"'",.@gname$,.@gldmstr$,.@glvl);
    if (.@char$ != .@gldmstr$){
        mes .npc$;
        mes "Character [ ^FF0000"+.@char$+"^000000 ] isn't a guild master!";
        close;
    }
    mes .npc$;
    mes "Information:";
    mes "Guild Name: ^ff0000"+.@gname$+"^000000";
    mes "Guild Level: ^ff0000"+.@glvl+"^000000";
    mes "Guild Master: ^ff0000"+.@gldmstr$+"^000000";
    mes "Master, what would like to do?";
    next;
    switch(select("Change Guild Leader:Cancel")){
        case 1:
            mes .npc$;
            mes "Are you sure you wanted to change the guild leader?";
            next;
            if (select("Yes","No") != 2){
                mes .npc$;
                mes "Enter the ^FF0000new^000000 guild leader's name.";
                input .@cgl$;
                next;
                mes .npc$;
                mes "Please ^FF0000re-enter^000000 the name again for confirmation.";
                input .@cgl2$;
                next;
                if (.@cgl$ != .@cgl2$) {
                    mes .npc$;
                    mes "The names you entered doesn't match.";
                    close;
                }
                .@check = query_sql("SELECT `account_id` FROM `char` WHERE `name`='"+escape_sql(.@cgl$)+"'",.@acid);
                if (!.@check){
                    mes .npc$;
                    mes "Character [ ^FF0000"+.@cgl$+"^000000 ] doesn't exist!";
                    close;
                }
                if (.@cgl$ == .@char$) {
                    mes .npc$;
                    mes "Character [ ^FF0000"+.@cgl$+"^000000 ] is already the leader of [ ^FF0000"+.@gname$+"^000000 ] Guild.";
                    close;
                }
                if (!isloggedin(getcharid(3,.@cgl$), getcharid(0,.@cgl$))){
                    mes .npc$;
                    mes "Character [ ^FF0000"+.@cgl$+"^000000 ] must be online to proceed!";
                    close;
                }
                if (getcharid(2,.@cgl$) != .@gldid){
                    mes .npc$;
                    mes "Character [ ^FF0000"+.@cgl$+"^000000 ] is not a member of [ ^FF0000"+.@gname$+"^000000 ] Guild.";
                    close;
                }
                mes .npc$;
                mes "Please confirm the following details before we proceed,";
                mes "Current Leader: ^FF0000"+.@char$+"^000000";
                mes "New Leader: ^FF0000"+.@cgl$+"^000000";
                mes "Would you like to proceed?";
                next;
                if (select("Close","^FF0000Confirmed^000000!") != 1) {
                    close2;
                    if (.gcdone == .@gldid){
                        if ( .delay > gettimetick(2) ){
                            message strcharinfo(0), "Transfer failed!";
                            mes .npc$;
                            mes "You must wait [^FF0000"+(.delay - gettimetick(2))+"^000000] seconds,";
                            mes .@char$+"'s guild has been currently";
                            mes "modified and changed their";
                            mes "guild leader authority.";
                            close;
                        }
                    }
                    message strcharinfo(0), "You have succesfully transferred the guild!";
                    announce strcharinfo(0)+" : The [ "+.@gname$+" ] Guild previously owned by "+.@char$+" succesfully transferred its ownership to "+.@cgl$+"!",bc_all,0xe57c00;
                    guildchangegm(.@gldid,.@cgl$);
                    .gcdone = .@gldid;
                    if (.d)
                    .delay = gettimetick(2) + .d;
                    sleep2 1000;
                    if (isloggedin(getcharid(3,.@cgl$), getcharid(0,.@cgl$))){
                        atcommand "@kick "+.@cgl$;
                    }
                    if (isloggedin(getcharid(3,.@char$), getcharid(0,.@char$))){
                        atcommand "@kick "+.@char$;
                    }
                    end;
                }
                close;          
            }
            close;
            
        case 2:
            close;
    }
 
OnInit:
    .reqlvl = 99; // Allowed GM level to use the NPC.
    .npc$ = "[ Guild Manager ]"; // You can change the NPC name through this.
    
// -- PLEASE DO NOT TOUCH THIS(FOR SAFETY PURPOSE). --
    .d = 60; // delay in seconds.
    bindatcmd "guild",strnpcinfo(3)+"::OnMain",.reqlvl,.reqlvl;
    end;
}
Viewed 1204 times, submitted by Legend.