yuhsing

Untitled

Sep 11th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.34 KB | None | 0 0
  1.  
  2. /*
  3. New Accounts cant referal Old Accounts
  4. MAC / IP detection
  5.  
  6.  
  7.  
  8. // Install this SQL Table and load the NPC script
  9.  
  10. CREATE TABLE IF NOT EXISTS `referral_records` (
  11. `id` int(11) unsigned NOT NULL auto_increment,
  12. `player_aid` int(11) unsigned NOT NULL default '0',
  13. `player_name` varchar(30) NOT NULL DEFAULT '',
  14. `player_time` datetime NOT NULL default '0000-00-00 00:00:00',
  15.  
  16. `newbie_aid` int(11) unsigned NOT NULL default '0',
  17. `newbie_name` varchar(30) NOT NULL DEFAULT '',
  18.  
  19. `time_online` int(11) unsigned NOT NULL default '0',
  20.  
  21. `player_ip` varchar(50) NOT NULL default '',
  22. `player_mac` varchar(50) NOT NULL default '',
  23. `newbie_ip` varchar(50) NOT NULL default '',
  24. `newbie_mac` varchar(50) NOT NULL default '',
  25.  
  26. `player_reward` datetime NOT NULL default '0000-00-00 00:00:00',
  27. `newbie_reward` datetime NOT NULL default '0000-00-00 00:00:00',
  28.  
  29. PRIMARY KEY( `id` )
  30. ) ENGINE=MyISAM AUTO_INCREMENT=1;
  31.  
  32.  
  33. */
  34.  
  35.  
  36.  
  37. prontera,155,181,5 script Referal NPC 757,{
  38. .@my_name$ = strcharinfo(0);
  39. .@my_aid = getcharid(3);
  40.  
  41. mes "How can I help you ?";
  42. mes " ";
  43. switch( select(
  44. "Claim Referal Rewards.",
  45. "Create New Referal Status",
  46. "Cancel"
  47. )){
  48. Case 1:
  49. if( Weight > ( MaxWeight / 2 ) ){
  50. mes "Make sure you have at least "+( MaxWeight / 20 )+" Spare Weight.";
  51. }else{
  52. query_sql( "SELECT COUNT( `player_reward` ) FROM `referral_records` WHERE `time_online` = 0 AND `player_aid` = "+.@my_aid+" AND `player_reward` = '0000-00-00 00:00:00'",.@count );
  53. if( .@count ){
  54. mes "Claimed Rewards as a Successful Referal";
  55. for( set .@i,0; .@i < .@count; set .@i,.@i + 1 ){
  56. getitem 512,1;
  57. getitem 512,2;
  58. getitem 512,3;
  59. }
  60. query_sql( "UPDATE `referral_records` SET `player_reward` = NOW() WHERE `time_online` = 0 AND `player_aid` = "+.@my_aid+" AND `player_reward` = '0000-00-00 00:00:00'" );
  61. close;
  62. }
  63. query_sql( "SELECT COUNT( `newbie_reward` ) FROM `referral_records` WHERE `time_online` = 0 AND `newbie_aid` = "+.@my_aid+" AND `newbie_reward` = '0000-00-00 00:00:00'",.@count );
  64. if( .@count ){
  65. mes "Claimed Rewards as a Newbie";
  66. for( set .@i,0; .@i < .@count; set .@i,.@i + 1 ){
  67. getitem 501,1;
  68. getitem 501,2;
  69. getitem 501,3;
  70. }
  71. query_sql( "UPDATE `referral_records` SET `newbie_reward` = NOW() WHERE `time_online` = 0 AND `newbie_aid` = "+.@my_aid+" AND `newbie_reward` = '0000-00-00 00:00:00'" );
  72. close;
  73. }
  74. mes "You dont have any pending rewards...";
  75. }
  76. break;
  77. Case 2:
  78. mes "Enter a Player Name";
  79. mes "^777777Must be online characters^000000";
  80. mes " ";
  81. input .@player_name$;
  82. .@player_aid = getcharid( 3,.@player_name$ );
  83. if( .@player_name$ == .@my_name$ ){
  84. mes "You cant referral yourself.";
  85.  
  86. }else if( .@player_aid ){
  87. // check if player can be referred.
  88. if( .@player_aid < .@my_aid ){
  89. mes "Impossible, "+.@player_name$+" has joined this server earlier than you.";
  90. close;
  91. }
  92.  
  93. set .@last_mac$,( ( .mac_check )?"last_mac":"last_ip" );
  94. query_sql( "SELECT `last_ip`,`"+.@last_mac$+"` FROM `login` WHERE `account_id` = "+.@my_aid,.@my_ip$,.@my_mac$ );
  95. query_sql( "SELECT `last_ip`,`"+.@last_mac$+"` FROM `login` WHERE `account_id` = "+.@player_aid,.@player_ip$,.@player_mac$ );
  96.  
  97. if( .@my_ip$ == .@player_ip$ || .@my_mac$ == .@player_mac$ ){
  98. mes "Dont fool me, both of you from same IP.";
  99. close;
  100. }
  101.  
  102. if( query_sql( "SELECT `player_name`,`player_time` FROM `referral_records` WHERE `newbie_aid` = "+.@player_aid+" OR `newbie_ip` = '"+.@player_ip+"' OR `newbie_mac` = '"+.@player_mac$+"'",.@byplayer$,.@since$ ) ){
  103. mes .@player_name$+" has been referred by "+.@byplayer$+" since "+.@since$;
  104. close;
  105. }
  106.  
  107. mes "Confirmation : you have referred "+.@player_name$+" to join this server ?";
  108. next;
  109. if( select( "YES","Nope" ) == 1 ){
  110. mes "A Confirmation message will be sent to "+.@player_name$+", once he/she confirmed it, a new status will be created.";
  111. close2;
  112. if( attachrid( .@player_aid ) ){
  113. mes "Hello, "+.@my_name$+" said he referred you to this server, is this correct ?";
  114. if( select( "YES","NO" ) == 1 ){
  115. message .@my_name$,"New Referal Status Created.";
  116. mes "Thank you for your time.";
  117. set @referal_time,.referal_duration;
  118. addtimer ( .check_interval * 60000 ),.npc_name$+"::OnCheck";
  119. query_sql( "INSERT INTO `referral_records` ( `player_aid`,`player_name`,`player_time`,`newbie_aid`,`newbie_name`,`time_online`,`player_ip`,`player_mac`,`newbie_ip`,`newbie_mac` ) VALUES ( "+.@my_aid+",'"+escape_sql( .@my_name$ )+"',NOW(),"+.@player_aid+",'"+escape_sql( .@player_name$ )+"',"+.referal_duration+",'"+.@my_ip$+"','"+.@my_mac$+"','"+.@player_ip$+"','"+.@player_mac$+"' )" );
  120. close;
  121. }else{
  122. message .@my_name$,.@player_name$+" has rejected your referal request.";
  123. }
  124. }
  125. end;
  126. }
  127. }else{
  128. mes "Player not found.";
  129. }
  130. break;
  131. default: break;
  132. }
  133. close;
  134.  
  135. OnInit:
  136. // minimum duration to wait before newbie can claim item ( seconds )
  137. .referal_duration = 86400;
  138. // check for MAC address ( otherwise it use IP address )
  139. .mac_check = 0;
  140. // how long for NPC to check for vending / chatroom
  141. .check_interval = 1;
  142.  
  143. .npc_name$ = strnpcinfo(0);
  144. end;
  145.  
  146. OnCheck:
  147. set @second,@second + ( .check_interval * 60 );
  148. dispbottom "@second : "+@second;
  149. if( @second >= @referal_time ){
  150. mes "Congratz, your referal time has reached. You may claim the Newbie Reward at NPC.";
  151. query_sql( "UPDATE `referral_records` SET `time_online` = 0 WHERE `newbie_aid` = "+getcharid(3) );
  152. set @second,0;
  153. set @referal_time,0;
  154. close;
  155.  
  156. }else if( checkvending() || checkchatting() ){
  157. dispbottom "Vending / Chatroom will make your newbie timers stopped. Please relog to enable it again.";
  158.  
  159. }else{
  160. addtimer ( .check_interval * 60000 ),.npc_name$+"::OnCheck";
  161. }
  162. end;
  163.  
  164. OnPCLoginEvent:
  165. if( query_sql( "SELECT `time_online` FROM `referral_records` WHERE `newbie_aid`="+getcharid(3)+" AND `time_online` > 0",.@time ) ){
  166. set @referal_time,.@time;
  167. addtimer ( .check_interval * 60000 ),.npc_name$+"::OnCheck";
  168. dispbottom "@second : "+@second;
  169. }
  170. end;
  171.  
  172. OnPCLogoutEvent:
  173. if( @second ){
  174. set .@count,( @referal_time - @second );
  175. if( .@count < 0 ) set .@count,0;
  176. query_sql( "UPDATE `referral_records` SET `time_online` = "+.@count+" WHERE `newbie_aid` = "+getcharid(3) );
  177. }
  178. end;
  179. }
Advertisement
Add Comment
Please, Sign In to add comment