/* 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 `unique_id` FROM `gp_records` WHERE `unique_id` = "+atoi(""+get_unique_id()), .@unique_id); if (.@unique_id[0] == atoi(""+get_unique_id())){ mes "[Guild Package]"; mes "You're PC has already redeemed the items!"; close; } if (atoi(""+get_unique_id()) == 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("INSERT INTO `gp_records` (`unique_id`,`account_id`) VALUES ("+atoi(""+get_unique_id())+","+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. setarray(.MemberItems[0], // Itemid, Amount 678,1, setarray(.LeaderItems[0], // Itemid, Amount 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; //} }