viewing paste Unknown #50066 | Text

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
/* player side:
player will talk to the npc
npc checks if player has requirements level of guild and members of guild as these checks are active
npc checks if unique id already redeemed before
player gives the items from array list, guild leader has a separate prize.
npc logs the unique id
 
gm side:
gm can turn off/on the npc for giving reward
 
 
SQL
CREATE TABLE IF NOT EXISTS `gp_records` (
  `account_id` int(11) NOT NULL,
  `unique_id` int(11) NOT NULL
);
*/
prontera,138,186,6  script  Guild Package   4_M_KY_HEAD,{
//function get_unique_id; // for emulation purposes
 
    if (.Disabled == 1) end;
    .@guild_id = getcharid(2);
    if (!.@guild_id) {
        mes "[Guild Package]";
        mes "You need a guild to talk to me.";
        close;
    }
    if (.CheckGuildLevel) {
        query_sql("SELECT `guild_lv` FROM `guild` WHERE `guild_id` = "+.@guild_id,.@guild_lv);
        if (.@guild_lv[0] < .CheckGuildLevel) {
            mes "[Guild Package]";
            mes "Sorry to redeem your guild needs to be level "+.CheckGuildLevel;
            mes "Or wait some more minutes if you met the guild requirements";
            close;
        }
    }
    if (.CheckGuildMembers) {
        query_sql("SELECT `account_id` FROM `guild_member` WHERE `guild_id` = "+.@guild_id,.@account_id);
        .@orig = getcharid(3);
        .@count = 0;
        for (.@i = 0;.@i < getarraysize(.@account_id);.@i++) {
            if (attachrid(.@account_id[.@i]) && .@last_id != .@account_id[.@i]) {
                .@count++;
                .@last_id = .@account_id[.@i];
            }
        }
        attachrid(.@orig);
        if (.@count < .CheckGuildMembers) {
            mes "[Guild Package]";
            mes "Sorry to redeem your online guild member count needs to be "+.CheckGuildMembers;
            close;
        }
    }
    if (.CheckUnique) {
    query_sql("SELECT `last_unique_id` FROM `login` WHERE `account_id` = '"+getcharid(3)+"'",.@lui$);
        query_sql("SELECT `unique_id` FROM `gp_records` WHERE `unique_id` = "+.@lui$, .@unique_id);
        if (.@unique_id[0] == .@lui$) {
            mes "[Guild Package]";
            mes "You're PC has already redeemed the items!";
            close;
        }
        if (.@lui$ == 0) {
            mes "Something went wrong, you do not have a unique id contact a staff immediately!";
            close;
        }
    } else {
        query_sql("SELECT `account_id` FROM `gp_records` WHERE `account_id` = "+getcharid(3), .@account_id);
        if (.@account_id[0] == getcharid(3)){
            mes "[Guild Package]";
            mes "You're account has already redeemed the items!";
            close;
        }
    }
    mes "Do you want to get your guild package?";
    if (select("Yes:No")==1) {
        if( !#gpakc2s5 ){
        set #gpakc2s5,1;
 
 
        if (getguildmaster(.@guild_id) == strcharinfo(0)) {
            for (.@i = 0; .@i < getarraysize(.LeaderItems);.@i+=2){
                getitembound .LeaderItems[.@i],.LeaderItems[.@i+1],1;
            }
        } else {
            for (.@i = 0; .@i < getarraysize(.MemberItems);.@i+=2){
                getitembound .MemberItems[.@i],.MemberItems[.@i+1],1;
            }
        }
        query_sql("SELECT `last_unique_id` FROM `login` WHERE `account_id` = '"+getcharid(3)+"'",.@lui$);
        query_sql("INSERT INTO `gp_records` (`unique_id`,`account_id`) VALUES ("+.@lui$+","+getcharid(3)+")");
        next;
        mes "Here you go! Good luck to you and your guild!";
        close;
 
} else {
mes"Sorry, but your account already got it..";
close;
}
    } else {
        close;
 
    }
end;
 
OnEnableGP:
    .Disabled = 0;
    dispbottom "GP NPC is enabled";
end;
 
OnDisableGP:
    .Disabled = 1;
    dispbottom "GP NPC is disabled";
end;
 
OnInit:
    .CheckGuildLevel = 30; // Set 0 to turn off, set to required level to turn on
    .CheckGuildMembers = 10; // Set to 0 to disable, or set to amount of members required.
    .CheckUnique = 1; // Set to 1 to turn on or 0 to turn off
                      // Turning this off would check for Account ID instead.
    .Disabled = 1;    // NPC is disabled by default upon load
    .GMLevelAllow = 10; // GM level allowed to turn it on/off.
 
  // Itemid, Amount
    setarray .MemberItems[0],678,1;
    setarray .LeaderItems[0],678,1;
 
    bindatcmd "gpon", strnpcinfo(3)+"::OnEnableGP", .GMLevelAllow,100;
    bindatcmd "gpoff", strnpcinfo(3)+"::OnDisableGP", .GMLevelAllow,100;
end;
 
// Test function to emulate get_unique_id
//function get_unique_id {
//  return 1234;
//}
}
 
Viewed 2717 times, submitted by Rebel.