· 5 years ago · Mar 03, 2020, 02:36 PM
1ayer side:
2player will talk to the npc
3npc checks if player has requirements level of guild and members of guild as these checks are active
4npc checks if unique id already redeemed before
5player gives the items from array list, guild leader has a separate prize.
6npc logs the unique id
7
8gm side:
9gm can turn off/on the npc for giving reward
10
11
12SQL
13CREATE TABLE IF NOT EXISTS `gp_records` (
14 `account_id` int(11) NOT NULL,
15 `unique_id` int(11) NOT NULL
16);
17*/
18prontera,146,75,5 script Guild Package 10134,{
19//function get_unique_id; // for emulation purposes
20
21 if (.Disabled == 1) end;
22 .@guild_id = getcharid(2);
23 if (!.@guild_id) {
24 mes "[Guild Package]";
25 mes "You need a guild to talk to me.";
26 close;
27 }
28 if (.CheckGuildLevel) {
29 query_sql("SELECT `guild_lv` FROM `guild` WHERE `guild_id` = "+.@guild_id,.@guild_lv);
30 if (.@guild_lv[0] < .CheckGuildLevel) {
31 mes "[Guild Package]";
32 mes "Sorry to redeem your guild needs to be level "+.CheckGuildLevel;
33 mes "Or wait some more minutes if you met the guild requirements";
34 close;
35 }
36 }
37 if (.CheckGuildMembers) {
38 query_sql("SELECT `account_id` FROM `guild_member` WHERE `guild_id` = "+.@guild_id,.@account_id);
39 .@orig = getcharid(3);
40 .@count = 0;
41 for (.@i = 0;.@i < getarraysize(.@account_id);.@i++) {
42 if (attachrid(.@account_id[.@i]) && .@last_id != .@account_id[.@i]) {
43 .@count++;
44 .@last_id = .@account_id[.@i];
45 }
46 }
47 attachrid(.@orig);
48 if (.@count < .CheckGuildMembers) {
49 mes "[Guild Package]";
50 mes "Sorry to redeem your online guild member count needs to be "+.CheckGuildMembers;
51 close;
52 }
53 }
54 if (.CheckUnique){
55 query_sql("SELECT `unique_id` FROM `gp_records` WHERE `unique_id` = "+atoi(""+get_unique_id()), .@unique_id);
56 if (.@unique_id[0] == atoi(""+get_unique_id())){
57 mes "[Guild Package]";
58 mes "You're PC has already redeemed the items!";
59 close;
60 }
61 if (atoi(""+get_unique_id()) == 0){
62 mes "Something went wrong, you do not have a unique id contact a staff immediately!";
63 close;
64 }
65 } else {
66 query_sql("SELECT `account_id` FROM `gp_records` WHERE `account_id` = "+getcharid(3), .@account_id);
67 if (.@account_id[0] == getcharid(3)){
68 mes "[Guild Package]";
69 mes "You're account has already redeemed the items!";
70 close;
71 }
72 }
73 mes "Do you want to get your guild package?";
74 if (select("Yes:No")==1) {
75 if( !#gpack2020 ){
76 set #gpack2020,1;
77 // With +(upgrade) items
78 getitembound2 2369,1,1,0,0, 0,0,0,0,Bound_Account;
79 getitembound2 2533,1,1,0,0, 0,0,0,0,Bound_Account;
80 getitembound2 2428,1,1,0,0, 0,0,0,0,Bound_Account;
81
82 // New
83 getitembound2 7349,1,1,0,0, 0,0,0,0,Bound_Account;
84 getitembound2 2765,2,1,0,0, 0,0,0,0,Bound_Account;
85 getitembound2 5470,1,1,0,0, 0,0,0,0,Bound_Account;
86 getitembound2 5306,1,1,0,0, 0,0,0,0,Bound_Account;
87 getitembound2 5463,1,1,0,0, 0,0,0,0,Bound_Account;
88
89 // Id in array below
90 if (getguildmaster(.@guild_id) == strcharinfo(0)) {
91 for (.@i = 0; .@i < getarraysize(.LeaderItems);.@i+=2){
92 getitembound .LeaderItems[.@i],.LeaderItems[.@i+1],1;
93 }
94 } else {
95 for (.@i = 0; .@i < getarraysize(.MemberItems);.@i+=2){
96 getitembound .MemberItems[.@i],.MemberItems[.@i+1],1;
97 }
98 }
99
100 query_sql("INSERT INTO `gp_records` (`unique_id`,`account_id`) VALUES ("+atoi(""+get_unique_id())+","+getcharid(3)+")");
101 next;
102 mes "Here you go! Good luck to you and your guild!";
103 close;
104
105} else {
106mes"Sorry, but your account already got it..";
107close;
108}
109 } else {
110 close;
111
112 }
113end;
114
115OnEnableGP:
116 .Disabled = 0;
117 dispbottom "GP NPC is enabled";
118 end;
119
120OnDisableGP:
121 .Disabled = 1;
122 dispbottom "GP NPC is disabled";
123 end;
124
125OnInit:
126 .CheckGuildLevel = 10; // Set 0 to turn off, set to required level to turn on
127 .CheckGuildMembers = 1; // Set to 0 to disable, or set to amount of members required.
128 .CheckUnique = 1; // Set to 1 to turn on or 0 to turn off
129 // Turning this off would check for Account ID instead.
130 .Disabled = 1; // NPC is disabled by default upon load
131 .GMLevelAllow = 99; // GM level allowed to turn it on/off.
132
133 setarray(.MemberItems[0],
134 // Itemid, Amount
135 13520,3,
136 13517,3,
137 13526,3);
138
139 setarray(.LeaderItems[0],
140 // Itemid, Amount
141 13520,3,
142 13517,3,
143 13526,3,
144 20465,1,
145 13510,5,
146 13511,5,
147 13512,5,
148 13513,5,
149 13514,5,
150 13515,5);
151
152 bindatcmd "gpon", strnpcinfo(3)+"::OnEnableGP", .GMLevelAllow,100;
153 bindatcmd "gpoff", strnpcinfo(3)+"::OnDisableGP", .GMLevelAllow,100;
154 end;
155
156// Test function to emulate get_unique_id
157//function get_unique_id {
158// return 1234;
159//}
160}
161
162prontera,142,68,6 script Guild Weapons 632,{
163 mes "[ Guild Weaponry ]";
164 mes "Please select a weapon you desired";
165 mes " ";
166 mes " ";
167 mes "You will have to use the";
168 mes "^FF0000Guild Package Weapon Ticket^000000 to";
169 mes "purchase here.";
170 next;
171 callshop "gpweapons",2;
172 end;
173}
174
175// =====================================================
176// ID OF ITEMS TO SELL HERE 969:1 [ID:PRICE]
177// =====================================================
178- itemshop gpweapons -1,501,42002:1,42003:1,42006:1,42008:1,42009:1,42010:1