Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- New Accounts cant referal Old Accounts
- MAC / IP detection
- // Install this SQL Table and load the NPC script
- CREATE TABLE IF NOT EXISTS `referral_records` (
- `id` int(11) unsigned NOT NULL auto_increment,
- `player_aid` int(11) unsigned NOT NULL default '0',
- `player_name` varchar(30) NOT NULL DEFAULT '',
- `player_time` datetime NOT NULL default '0000-00-00 00:00:00',
- `newbie_aid` int(11) unsigned NOT NULL default '0',
- `newbie_name` varchar(30) NOT NULL DEFAULT '',
- `time_online` int(11) unsigned NOT NULL default '0',
- `player_ip` varchar(50) NOT NULL default '',
- `player_mac` varchar(50) NOT NULL default '',
- `newbie_ip` varchar(50) NOT NULL default '',
- `newbie_mac` varchar(50) NOT NULL default '',
- `player_reward` datetime NOT NULL default '0000-00-00 00:00:00',
- `newbie_reward` datetime NOT NULL default '0000-00-00 00:00:00',
- PRIMARY KEY( `id` )
- ) ENGINE=MyISAM AUTO_INCREMENT=1;
- */
- prontera,155,181,5 script Referal NPC 757,{
- .@my_name$ = strcharinfo(0);
- .@my_aid = getcharid(3);
- mes "How can I help you ?";
- mes " ";
- switch( select(
- "Claim Referal Rewards.",
- "Create New Referal Status",
- "Cancel"
- )){
- Case 1:
- if( Weight > ( MaxWeight / 2 ) ){
- mes "Make sure you have at least "+( MaxWeight / 20 )+" Spare Weight.";
- }else{
- 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 );
- if( .@count ){
- mes "Claimed Rewards as a Successful Referal";
- for( set .@i,0; .@i < .@count; set .@i,.@i + 1 ){
- getitem 512,1;
- getitem 512,2;
- getitem 512,3;
- }
- 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'" );
- close;
- }
- 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 );
- if( .@count ){
- mes "Claimed Rewards as a Newbie";
- for( set .@i,0; .@i < .@count; set .@i,.@i + 1 ){
- getitem 501,1;
- getitem 501,2;
- getitem 501,3;
- }
- 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'" );
- close;
- }
- mes "You dont have any pending rewards...";
- }
- break;
- Case 2:
- mes "Enter a Player Name";
- mes "^777777Must be online characters^000000";
- mes " ";
- input .@player_name$;
- .@player_aid = getcharid( 3,.@player_name$ );
- if( .@player_name$ == .@my_name$ ){
- mes "You cant referral yourself.";
- }else if( .@player_aid ){
- // check if player can be referred.
- if( .@player_aid < .@my_aid ){
- mes "Impossible, "+.@player_name$+" has joined this server earlier than you.";
- close;
- }
- set .@last_mac$,( ( .mac_check )?"last_mac":"last_ip" );
- query_sql( "SELECT `last_ip`,`"+.@last_mac$+"` FROM `login` WHERE `account_id` = "+.@my_aid,.@my_ip$,.@my_mac$ );
- query_sql( "SELECT `last_ip`,`"+.@last_mac$+"` FROM `login` WHERE `account_id` = "+.@player_aid,.@player_ip$,.@player_mac$ );
- if( .@my_ip$ == .@player_ip$ || .@my_mac$ == .@player_mac$ ){
- mes "Dont fool me, both of you from same IP.";
- close;
- }
- 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$ ) ){
- mes .@player_name$+" has been referred by "+.@byplayer$+" since "+.@since$;
- close;
- }
- mes "Confirmation : you have referred "+.@player_name$+" to join this server ?";
- next;
- if( select( "YES","Nope" ) == 1 ){
- mes "A Confirmation message will be sent to "+.@player_name$+", once he/she confirmed it, a new status will be created.";
- close2;
- if( attachrid( .@player_aid ) ){
- mes "Hello, "+.@my_name$+" said he referred you to this server, is this correct ?";
- if( select( "YES","NO" ) == 1 ){
- message .@my_name$,"New Referal Status Created.";
- mes "Thank you for your time.";
- set @referal_time,.referal_duration;
- addtimer ( .check_interval * 60000 ),.npc_name$+"::OnCheck";
- 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$+"' )" );
- close;
- }else{
- message .@my_name$,.@player_name$+" has rejected your referal request.";
- }
- }
- end;
- }
- }else{
- mes "Player not found.";
- }
- break;
- default: break;
- }
- close;
- OnInit:
- // minimum duration to wait before newbie can claim item ( seconds )
- .referal_duration = 86400;
- // check for MAC address ( otherwise it use IP address )
- .mac_check = 0;
- // how long for NPC to check for vending / chatroom
- .check_interval = 1;
- .npc_name$ = strnpcinfo(0);
- end;
- OnCheck:
- set @second,@second + ( .check_interval * 60 );
- dispbottom "@second : "+@second;
- if( @second >= @referal_time ){
- mes "Congratz, your referal time has reached. You may claim the Newbie Reward at NPC.";
- query_sql( "UPDATE `referral_records` SET `time_online` = 0 WHERE `newbie_aid` = "+getcharid(3) );
- set @second,0;
- set @referal_time,0;
- close;
- }else if( checkvending() || checkchatting() ){
- dispbottom "Vending / Chatroom will make your newbie timers stopped. Please relog to enable it again.";
- }else{
- addtimer ( .check_interval * 60000 ),.npc_name$+"::OnCheck";
- }
- end;
- OnPCLoginEvent:
- if( query_sql( "SELECT `time_online` FROM `referral_records` WHERE `newbie_aid`="+getcharid(3)+" AND `time_online` > 0",.@time ) ){
- set @referal_time,.@time;
- addtimer ( .check_interval * 60000 ),.npc_name$+"::OnCheck";
- dispbottom "@second : "+@second;
- }
- end;
- OnPCLogoutEvent:
- if( @second ){
- set .@count,( @referal_time - @second );
- if( .@count < 0 ) set .@count,0;
- query_sql( "UPDATE `referral_records` SET `time_online` = "+.@count+" WHERE `newbie_aid` = "+getcharid(3) );
- }
- end;
- }
Advertisement
Add Comment
Please, Sign In to add comment