· 6 years ago · Nov 30, 2019, 05:38 PM
1//===== ReverieRO Script ==========================================|
2//= Vote Goal System/Vote Assistant =|
3//===== By: ======================================================|
4//= crazyarashi =|
5//===== Current Version: =========================================|
6//= 1.0 Initial Version =|
7//================================================================|
8//= Settings on OnInit =|
9//= Vote for Points Shop =|
10//= Recalculate Votes every dawn =|
11//= Vote counter stop at months end, and starts at first day =|
12//================================================================|
13/* ADD SQL TABLE FIRST
14
15CREATE TABLE IF NOT EXISTS `vote_rewards` (
16 `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
17 `unique_id` int(11) UNSIGNED NOT NULL DEFAULT '0',
18 PRIMARY KEY (`id`)
19) ENGINE=MyISAM DEFAULT CHARSET=utf8;
20
21*/
22
23- script vote_goal_system -1,{
24OnPCLoginEvent:
25 .@account_id = getcharid(3);
26 query_sql("SELECT `points` FROM `cp_v4p_voters` WHERE account_id='"+.@account_id+"'",.@vote_point);
27
28 sleep2 10;
29 dispbottom "Vote Points: "+#VOTEPOINTS+"";
30 dispbottom "Current Month's Vote Goal: "+$total_vote+" / " +.goal+"";
31
32 if(.@vote_point){
33 #VOTEPOINTS += .@vote_point;
34 query_sql("UPDATE `cp_v4p_voters` SET `points` = 0 WHERE account_id='"+.@account_id+"'");
35 if(.active) $total_vote += (.@vote_point/.points);
36 }
37 if($vote_r_active){
38 .@unique_id$ = get_unique_id();
39 query_sql("SELECT `id` FROM `vote_rewards` WHERE `unique_id` = '"+escape_sql(.@unique_id$)+"'",.@id);
40 if(!.@id){
41 function claim_reward;
42 .@char_id = getcharid(0);
43 claim_reward(.@unique_id$,.@char_id);
44 }
45 }
46end;
47
48OnHour00:
49 function is_leap_year;
50 .@current_day = gettime(DT_DAYOFMONTH);
51 if(.@current_day == (is_leap_year()?29:28) || .@current_day == 30 || .@current_day == 31){
52 function check_date;
53 check_date(.@current_day);
54 } else if(.@current_day == 1){
55 if($vote_reward){
56 $vote_reward = 0;
57 $vote_r_active = 1;
58 }
59 $total_vote = 0;
60 .active = 1;
61 } else if(.@current_day == .reward_day){
62 $vote_r_active = 0;
63 $vote_reward = 0;
64 query_sql("TRUNCATE TABLE `vote_rewards`"); //= Reset for next month.
65 }
66end;
67
68function check_date {
69 .@current_day = getarg(0);
70 .@month = gettime(DT_MONTH);
71 switch(.@month){
72 case APRIL: case JUNE: case SEPTEMBER: case NOVEMBER:
73 .@days = 30;
74 break;
75
76 case FEBRUARY:
77 .@bool = is_leap_year();
78 if(.@bool){
79 .@days = 29;
80 } else {
81 .@days = 28;
82 }
83 break;
84
85 default:
86 .@days = 31;
87 break;
88 }
89 if(.@current_day == .@days){
90 if($total_vote >= .goal) $vote_reward = 1;
91 $total_vote = 0;
92 .active = 0;
93 }
94 end;
95}
96
97function is_leap_year {
98 .@year = gettime(DT_YEAR);
99 if(.@year % 4 == 0 && .@year % 100 != 0 || .@year % 400 == 0){
100 return 1;
101 } else {
102 return 0;
103 }
104 return 0;
105}
106
107function claim_reward {
108 .@id = getarg(0);
109 .@char_id = getarg(1);
110 query_sql("INSERT INTO `vote_rewards` (`unique_id`) VALUES ("+.@id+")");
111 for(.@i = 0; .@i < getarraysize(.rewards); .@i += 2){
112 .@item_id[getarraysize(.@item_id)] = .rewards[.@i];
113 .@amount[getarraysize(.@amount)] = .rewards[.@i+1];
114 }
115 mail .@char_id,"ReverieRO","Vote Goal Reward","Here you go! A special gift from the ReverieRO staff for reaching the " +.goal+" vote goal last month! Enjoy!",0,.@item_id,.@amount;
116 end;
117}
118
119OnInit:
120 .active = 1;
121 .points = 1; //= Points per 1 vote.
122 .goal = 5; //= Monthly Goal. Set to 7500. NOTE: Players can get 4 VP per 12 hours (= 56 per week (224? per month per player) with consistent voting). 1 ($0.10) DC = 7 Vote Points.
123 .reward_day = 8; //= Date to claim reward : Currently 7 days to claim.
124 setarray .rewards, //= Item ID, Amount...
125 677,5, // 5 Midgard Coin
126 12209,3, // 3 Life Insurance
127 12103,1; // 1 Bloody Branch
128end;
129}
130
131- shop vote_shop -1,501:-1
132
133prontera,131,217,5 script Credit Assistant 1_M_PUBMASTER,{
134 mes .npc$;
135 mes "Hello, I am the Credit Assistant. I provide multiple services that revolve around Donation Credits and Vote Points.";
136 mes "What can I do for you?";
137 next;
138 switch(select("How to redeem Donation Credits?:How to obtain Vote Points?:Trade my Vote Points for rewards.:Quit.")){
139 case 1:
140 mes .npc$;
141 mes "These are automatically redeemed. Originally, the system requires you to take several steps in between before you have access to the Donation Credits but we decided to make it easier for you.";
142 next;
143 mes .npc$;
144 mes "All you have to do is log in on the ReverieRO domain, make a donation and log into the game. A message will be displayed that your donation was successful and Donation Credits have been credited to your account.";
145 next;
146 mes .npc$;
147 mes "Be aware that you can only receive Donation Credits if you log in with the account you've donated with! For example- If you donate with account A but log in game with account B, nothing happens! Just bringing that to your attention.";
148 next;
149 mes .npc$;
150 mes "I hope to have informed you enough. Enjoy playing ReverieRO!";
151 close;
152
153 case 2:
154 mes .npc$;
155 mes "Vote Points are a non-physical currency automatically awarded to players that have voted for the server. They can be exchanged for fabulous items, such as Donation Credits and Costume Boxes.";
156 next;
157 mes .npc$;
158 mes "In order to get Vote Points, all you need to do is log in on the ReverieRO domain, vote for the server through the links displayed on the vote page and then talk to me. ";
159 next;
160 mes .npc$;
161 mes "Be aware that your Vote Points will only show up if you log in with the account you've voted with! For example- If you vote with account A but log in game with account B, you not have access to your points!";
162 next;
163 mes .npc$;
164 mes "Cheers!";
165 close;
166
167
168 case 3:
169 mes .npc$;
170 mes "Have you voted for the server via the ReverieRO domain? Thank you very much! It'll help us reach higher in the top lists! Of course, we'd like to reward you for that!";
171 next;
172 mes "Here's what we have to offer~";
173 mes "-----------------------------------";
174 mes "Current Vote Points : ^00FF00" + getd(.currency$);
175 callshop "vote_shop",1;
176 npcshopattach "vote_shop";
177 end;
178
179 case 4:
180 mes .npc$;
181 mes "I hope to have informed you enough. Enjoy playing ReverieRO!";
182 close;
183 }
184 end;
185
186OnBuyItem:
187 for(.@i = 0; .@i < getarraysize(@bought_nameid); .@i++)
188 for(.@j = 0; .@j < getarraysize(.item); .@j++)
189 if(.item[.@j] == @bought_nameid[.@i])
190 .@total_cost += (.price[.@j] * @bought_quantity[.@i]);
191 mes .npc$;
192 mes "Selected Items :";
193 for(.@i = 0; .@i < getarraysize(@bought_nameid); .@i++){
194 mes "^00FF00" + @bought_quantity[.@i] + "x^000000 - "+getitemname(@bought_nameid[.@i])+" = ^FF0000"+(.price[.@i]*@bought_quantity)+" VP^000000";
195 }
196 mes "---------------------------------";
197 mes "Total Amount : ^00FF00" + .@total_cost +"^000000";
198 mes "Current Vote Points : ^00FF00" + getd(.currency$) +"^000000";
199 if(getd(.currency$) < .@total_cost){
200 mes "You do not have enough Vote Points for this purchase.";
201 }
202 next;
203 switch(select(((getd(.currency$) >= .@total_cost)?"Purchase":""),"Quit")){
204 case 1:
205 if(getd(.currency$) >= .@total_cost){
206 mes .npc$;
207 mes "Thank you for your continous patronage.";
208 for(.@i = 0; .@i < getarraysize(@bought_nameid); .@i++){
209 getitem @bought_nameid[.@i],(@bought_quantity[.@i]*.quantity[.@i]);
210 }
211 setd(.currency$,getd(.currency$) - .@total_cost);
212 } else {
213 dispbottom "You do not have enough Vote Points for this purchase.";
214 }
215 dispbottom "Remaining Vote Points : "+ getd(.currency$);
216 deletearray @bought_quantity, getarraysize(@bought_quantity);
217 deletearray @bought_nameid, getarraysize(@bought_nameid);
218 end;
219
220 case 2:
221 end;
222 }
223end;
224
225OnInit:
226 .npc$ = "[Credit Assistant]";
227 .currency$ = "#VOTEPOINTS";
228 setarray .shop_items$, //= ITEMID,QUANTITY,POINTS
229 "30502,1,10",
230 "7638,1,40",
231 "7639,1,70";
232 npcshopdelitem "vote_shop",501;
233 for(.@i = 0; .@i < getarraysize(.shop_items$); .@i++){
234 explode(.@items$,.shop_items$[.@i],",");
235 .item[getarraysize(.item)] = atoi(.@items$[0]);
236 .quantity[getarraysize(.quantity)] = atoi(.@items$[1]);
237 .price[getarraysize(.price)] = atoi(.@items$[2]);
238 npcshopadditem "vote_shop",atoi(.@items$[0]),atoi(.@items$[2]);
239 }
240end;
241}