Advertisement
akbare

Referall System player

Jan 19th, 2022
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.63 KB | None | 0 0
  1. //===== eAthena Script ================================================================================
  2. //= Referral System
  3. //===== By: ===========================================================================================
  4. //= rahuldev345
  5. //===== Current Version: ==============================================================================
  6. //= V.1
  7. //===== Compatible With: ==============================================================================
  8. //= eAthena SVN, SQL Only
  9. //===== Description: ==================================================================================
  10. //= Referral System Working:
  11. /*
  12. Player A : Old player (Invited player B and C)
  13. Player B and C : New comers
  14.  
  15. 1: As Player B and Player C logs in, they need to find npc
  16. "Referral Npc" and must Sign with NPC by choosing option
  17. "- My Friend Called me!" and Enter the exact name of his
  18. friend and then complete process by choosing option
  19. "Complete the process".
  20. 2: The Player will be asked to Relog to Start with the System.
  21. 3: As he relog, a timer will start attaching to player and
  22. it will run till he completes his todays work, i.e Play/
  23. Stay online for 5 Hours at your server.(as per below con-
  24. figuration, can be changed according to needs).
  25. ********************************************************\
  26. set $@hourstoplay, 5; // No. of hours to play everyday.
  27. \*******************************************************
  28. 4: But, the reward wont be given just yet, the NPC will do
  29. constant checking, to see whether players B and C are
  30. active, for at least *days( Depends on you. ).
  31. Being active means, any(or) all of these;
  32. * Logs in and plays atleast X (won't mention this)
  33. hours a day.
  34. * The npc keeps checking IP's Everytime the players
  35. logs in, ( You can set the no. of octets you want
  36. to check of ip-address )
  37. Eg; Referrals starting with first 3 octets being the
  38. same, ex: 204.152.10.25 and 204.152.10.75, won't count
  39. and it will dispbottom the warning.
  40. 5: If they meet all those requirements, the inviter, will be
  41. rewared with some items.
  42. */
  43. //===== Additional Comments: ===========================================================================
  44. //= Let me know, if you find any bugs.
  45. //===== Changelogs: ====================================================================================
  46. // V.2 (a) Now the npc name is more suitable to edit.
  47. // ( Now Recruits can't enter new players name than him. - thanks to Topher08 for pointing that out.
  48. // V.3 (a) Prevent players those who completed job, but still able to apply as recruits.
  49. //======================================================================================================
  50. // - SQL TABLE
  51. /*
  52. CREATE TABLE IF NOT EXISTS `callfrnd` (
  53. `id` int(11) NOT NULL auto_increment,
  54. `account_id` int(11) NOT NULL default '0',
  55. `name` varchar(23) NOT NULL default '',
  56. `last_ip` varchar(100) NOT NULL default '',
  57. `last_ip2` varchar(100) NOT NULL default '',
  58. `ref_name` varchar(23) NOT NULL default '',
  59. `ref_id` int(11) NOT NULL default '0',
  60. `mins` tinyint(3) unsigned NOT NULL default '0',
  61. `days` tinyint(3) unsigned NOT NULL default '0',
  62. `task_end` tinyint(3) unsigned NOT NULL default '0',
  63. PRIMARY KEY (`account_id`),
  64. KEY (`id`)
  65. ) ENGINE=MyISAM;
  66. */
  67. //======================================================================================================
  68.  
  69. //======================================================================================================
  70. // Edit Configurations here:
  71. //======================================================================================================
  72. - script Ref_config -1,{
  73.  
  74. OnInit:
  75. set $@daystoplay, 1; // total no of days to play.
  76. set $@noofplayers, 1; // min. no. of players to call to server to be eligible to get the price.
  77. set $@hourstoplay, 1; // No. of hours to play everyday.
  78. set $@noofoctet, 3; // No. of octects, that script will check.
  79. set $@new_aid, 2000000; // To be sure that the player is really new to server. Put the latest registered account id here.
  80. set $@name$,"^E41B17[Call Your Friend]^000000"; // Edit npc name here.
  81. end;
  82. }
  83.  
  84. //======================================================================================================
  85. // The main NPC:
  86. //======================================================================================================
  87. prontera,141,173,5 script Referral Friends 549,{
  88.  
  89. mes $@name$;
  90. mes "^616D7EI am one of the staff members of GM Team. And i am assigned to award players who bring players to our server and contribute to server population.";
  91. mes " ";
  92. next;
  93. mes $@name$;
  94. mes "^616D7ESo, How may I help you?";
  95. next;
  96. switch(select("- My Friend Called me!:- I have called My Friend's:- Close")) {
  97. mes $@name$;
  98. case 1:
  99. if ( getcharid(3) < $@new_aid ) {
  100. mes "^616D7EYou doesn't seems to be new to server.";
  101. close;
  102. }
  103. mes "^616D7EOh.. Nice, so would you like to proceed with the Referral System?";
  104. switch(select("Yes")) {
  105. case 1:
  106. if (#CallFrnd >= 1) {
  107. mes "^616D7EYou are already Registered on our database.";
  108. close;
  109. }
  110. goto ReferralSystem;
  111. }
  112. case 2:
  113. if ( #YCallFrnd ) {
  114. mes "^0000ffThanks! for supporting our server.";
  115. close;
  116. }
  117. query_sql("SELECT count(ref_id) from `callfrnd` where ref_id = " + getcharid(3) + " AND task_end = 1",.@count);
  118. if(.@count >= $@noofplayers) {
  119. mes "^616D7ECongratulations, It seems you have Recruited [^880000 " + .@count + " ^000000] Players, to our server.";
  120. next;
  121. set #YCallFrnd, 1;
  122. mes $@name$;
  123. mes "^616D7EAll Process has been completed successfully. Now you are eligible to get the 200 TCG Card from the Referral Award Shop.";
  124. mes " ";
  125. mes "^616D7EHave a pleasent Stay at our server.!";
  126. close;
  127. }
  128. mes "^616D7ENot Enough Recruitment's. Work Hard.";
  129. close;
  130. case 3:
  131. mes "^616D7EI wish!, if you could have helped me. :(";
  132. close;
  133. }
  134. end;
  135.  
  136. ReferralSystem:
  137. next;
  138. mes $@name$;
  139. mes " ";
  140. mes "^ff0000NOTE: ^000000^616D7EThe Entered Name should match with your friend's name or he won't get the prize.";
  141. mes " ";
  142. mes "^616D7EEnter your Friend name: ";
  143. next;
  144. input .@frnd$;
  145. if ( .@frnd$ == strcharinfo(0) ) {
  146. mes $@name$;
  147. mes "^616D7ESorry, you are not allowed to Enter your name.";
  148. close;
  149. }
  150. mes $@name$;
  151. mes "^616D7ESo you have been called by [ ^ff000f" + .@frnd$ + "^000000 ]? ^616D7EIs that right??";
  152. next;
  153. if(select("Yes:Back")==2) goto ReferralSystem;
  154. mes $@name$;
  155. mes "^616D7EIf you play more than [ ^2B60DE" + $@daystoplay + " days ^000000] and spend more than x hours to our server every day. Your friend will get a reward from the Referral Shop.";
  156. next;
  157. switch(select("Next:Show me the item List")) {
  158. case 1:
  159. break;
  160. case 2:
  161. mes $@name$;
  162. mes "^616D7ETalk to my Neighbour Npc to check the Item Reward Or Read forums.";
  163. close;
  164. }
  165. mes $@name$;
  166. mes "^616D7EAnd, if you Call your [ ^2B60DE" + $@noofplayers + " Friends ^000000] to our server, and they play more than [ ^2B60DE" + $@daystoplay + " days ^000000] and x no. of hours every day. Then you will also have a chance to win a Free Reward.";
  167. next;
  168. mes $@name$;
  169. mes "^616D7EIts, Just that you need to follow some rules: ";
  170. mes " ";
  171. next;
  172. switch(select("Exit:Complete the process")) {
  173. case 1:
  174. mes $@name$;
  175. mes "^616D7ENevermind~, You can come back again!";
  176. close;
  177. case 2:
  178. query_sql("SELECT last_ip FROM `login` WHERE account_id = "+getcharid(3)+"", .@lastip$); // recruits ip address
  179. set .@frnd, query_sql ("SELECT name, char.account_id, last_ip FROM `char` LEFT JOIN `login` ON login.account_id = char.account_id where name = '" + escape_sql(.@frnd$) + "'",.@chname$, .@account_id, .@flastip$); // recruiter ip address and information
  180. if (!.@frnd) {
  181. mes $@name$;
  182. mes "^ff0000FAILED! FAILED! FAILED!";
  183. mes " ";
  184. mes "^616D7ESorry, We didn't found your friend's name in our database. Make sure that you Enter's Everything correctly.";
  185. close;
  186. }
  187. if ( .@account_id == getcharid(3) ) {
  188. mes $@name$;
  189. mes "^ff0000WARNING: ^616D7EThis Player is found on your account. Sorry, Unable to proceed further!!!";
  190. mes " ";
  191. mes "Enter some other name";
  192. close;
  193. }
  194. if ( .@account_id > getcharid(3) ) { // i am older than my frnd
  195. mes $@name$;
  196. mes "^616D7EIt seems, your friend is newer than you to our server. Damn you cheaters. ";
  197. close;
  198. }
  199. if ( .@lastip$ == .@flastip$ ) {
  200. mes $@name$;
  201. mes "^616D7EIt seems you and your friend are from IP Address: ^ff0000" + .@flastip$ + "^000000. Sorry, but its not allowed.";
  202. close;
  203. }
  204. set #CallFrnd, 1;
  205. query_sql("INSERT INTO `callfrnd` VALUES (NULL," + getcharid(3) + ",'" + escape_sql(strcharinfo(0)) + "','" + .@lastip$ + "','None','" + escape_sql(.@frnd$) + "'," + .@account_id + ",0,0,0)");
  206. mes $@name$;
  207. mes "^616D7EYour registration is now accepted.";
  208. mes "^ff0000Now, you should relog to make changes save and start properly.^000000";
  209. mes " ";
  210. mes "and ^0000ff~ We Welcome's you to our server.";
  211. close;
  212. }
  213. }
  214.  
  215. //======================================================================================================
  216. // Keep Checking Records and performs accordingly.
  217. //======================================================================================================
  218. - script timeplayed -1,{
  219.  
  220. OnPCLoginEvent:
  221. if (#CallFrnd != 1) end; // Task still not started or is completed
  222. query_sql("SELECT ref_id, mins, days from `callfrnd` where account_id = " + getcharid(3), @ref_id, @minute, consecutive_days);
  223. query_sql("SELECT SUBSTRING_INDEX(last_ip,'.'," + ($@noofoctet) + ") from `login` where account_id = " + @ref_id,.@fip$);
  224. query_sql("SELECT SUBSTRING_INDEX(last_ip,'.'," + ($@noofoctet) + ") from `login` where account_id = " + getcharid(3),@myip$);
  225. if((#lastDayOnlineC == gettimetick(2)/86400)) end; // If today's job is completed or not.
  226. if( #lastDayOnlineC < ((gettimetick(2)/86400)-1) ) { // if login was not yesterday
  227. set consecutive_days, 0;
  228. set @minute, 0;
  229. goto TimerStart;
  230. }
  231. if( #lastDayOnlineC == ((gettimetick(2)/86400)-1) ) { // if login was yesterday
  232. goto TimerStart;
  233. }
  234.  
  235. TimerStart:
  236. if(.@fip$ == @myip$) {
  237. dispbottom "Referral system Stopped because you and your friend(s) ip is same.";
  238. end;
  239. }
  240. attachnpctimer ""+strcharinfo(0);
  241. initnpctimer;
  242. end;
  243.  
  244. OnTimer30000:
  245. if(checkvending() == 1 || checkchatting() == 1) { //Check if Vending or chatting
  246. dispbottom "The timer stopped because you are vending/chatting. Please relog if you wish to start again.";
  247. stopnpctimer;
  248. end;
  249. }
  250.  
  251. getmapxy( .@map$, .@x, .@y, 0 ); //Check if Idle
  252. if(@map$ == .@map$ && @x == .@x && @y == .@y) {
  253. set @afk, @afk + 1;
  254. } else {
  255. set @afk, 0;
  256. }
  257. set @map$, .@map$;
  258. set @x, .@x;
  259. set @y, .@y;
  260.  
  261. if(@afk == 5) { // if afk for 5 mins reduce 4 mins from their total minutes.
  262. set @minute, @minute - 4;
  263. dispbottom "The timer stopped because you were Idle for 5 minutes. Please relog if you wish to start again.";
  264. stopnpctimer;
  265. end;
  266. }
  267. end;
  268.  
  269. OnTimer60000: //Check every 1 Minute
  270. set @minute, @minute + 1;
  271. if(@minute == ($@hourstoplay*60)) {
  272. set @minute,0;
  273. query_sql("UPDATE `callfrnd` SET days = (days+1) WHERE account_id = " + getcharid(3) +";");
  274. set #lastDayOnlineC, gettimetick(2)/86400;
  275. set consecutive_days, consecutive_days +1;
  276. if( consecutive_days == $@daystoplay ) {
  277. set #CallFrnd, 2;
  278. query_sql("UPDATE `callfrnd` SET task_end = 1 WHERE account_id = " + getcharid(3) +";");
  279. stopnpctimer;
  280. end;
  281. }
  282. end;
  283. }
  284. initnpctimer;
  285. end;
  286.  
  287. OnPCLogoutEvent:
  288. if (#CallFrnd != 1) end;
  289. query_sql("INSERT INTO `callfrnd` (id,account_id,mins) VALUES (NULL," + getcharid(3) + ","+@minute+") ON DUPLICATE KEY UPDATE account_id= " + getcharid(3) + ",last_ip='"+@myip$+"',mins="+@minute);
  290. end;
  291. }
  292.  
  293. //======================================================================================================
  294. // Shop NPC:
  295. // NOTE: This npc lets you buy only one item of quantity one.
  296. //======================================================================================================
  297. prontera,139,173,5 script Referral Prize 495,{
  298. if(#YCallFrnd == 1) {
  299. mes "[ " + strnpcinfo(3) + " ]";
  300. getitem .item,.qty;
  301. set #YCallFrnd, 2;
  302. mes "Thanks!";
  303. close;
  304. } else {
  305. mes "[ " + strnpcinfo(3) + " ]";
  306. mes "What? " + ((#YCallFrnd==0)? "you haven't Referred anyone to our server.":"you have alredy Received the price.");
  307. close;
  308. }
  309.  
  310. OnInit:
  311. npcshopattach "Ref#shop1";
  312. set .item,12152; // Item id
  313. set .qty,1; // Quantity
  314. end;
  315. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement