Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Title: Icabit's Referral System
- //Version: 1
- //Author: Icabit
- //Created: 09/06/2013
- //Released: 01/07/
- //Compatibility: rAthena | Hercules
- //Support: SQL
- //Credits:Thank you to the Athena community.
- //
- // Don't Claim this script as yours..
- // Don't Delete This header
- // Don't Modify without My Permission
- //
- - script totaltime -1,{
- //--Start of the Script
- OnPCLoginEvent:
- set .@harmony,1; // if you have harmony, set this to 1 or more for additional mac address check
- set .@myname$, strcharinfo(0);
- if (.@harmony>=1)
- {
- query_sql "SELECT `account_id` FROM `totaltime` WHERE `account_id`="+getcharid(3),.@accid;
- if (query_sql("SELECT `char`.`name` FROM `char` LEFT JOIN login ON `char`.account_id=login.account_id WHERE login.last_mac=(SELECT last_mac FROM login WHERE account_id="+getcharid(3)+") AND `char`.online=1 AND `char`.char_id!="+getcharid(0), .@name$) >= 1)
- {
- for (set .@i,0; .@i<getarraysize(.@name$); set .@i,.@i+1) {
- if (checkvending(.@name$[.@i]) != 2)
- set .@samemac, .@samemac +1;
- }
- if (.@samemac >= 1) {
- announce "Sorry, only 1 account per computer can only be recorded for your game time.", bc_self;
- end;
- }
- }
- }
- query_sql "SELECT `account_id` FROM `totaltime` WHERE `account_id`="+getcharid(3),.@accid;
- if (.@harmony>=1)
- {
- query_sql "SELECT `last_mac` FROM `login` WHERE `account_id`="+getcharid(3),.@lastmac$;
- if ( .@accid == 0 )
- {
- query_sql "INSERT INTO `totaltime` VALUES (" + getcharid(3) + ",0,0,0,0,'"+.@lastmac$+"')";
- //freebies add here
- getitem 31016,1;
- getitem 27920,10;
- dispbottom "You have Claimed your Freebies";
- }
- else
- {
- query_sql "UPDATE `totaltime` SET `mac` = ('" + .@lastmac$ + "') WHERE `account_id`=" + getcharid(3);
- }
- }
- else
- {
- if ( .@accid == 0 ) { query_sql "INSERT INTO `totaltime` VALUES (" + getcharid(3) + ",0,0,0,0)"; }
- //freebies add here
- getitem 31016,1;
- getitem 27920,10;
- dispbottom "You have Claimed your Freebies";
- }
- if( #DailyBonus != gettime(5) ){
- dispbottom "You Have Gained Daily Rewards";
- getitem 673,1;
- set #DailyBonus ,gettime(5);
- set totaltime,0;
- }
- set totaltimeold,totaltime; //copies the current totaltime
- set @afk,0;
- attachnpctimer ""+strcharinfo(0)+"";
- initnpctimer;
- // dispbottom .@accid;
- // dispbottom .@lastmac$;
- end;
- OnTimer60000:
- if(isloggedin(strcharinfo(0))) // checks for @autotrade and @afk characters
- {
- stopnpctimer;
- end;
- }
- //Check if Vending (normal or @at)
- if(@afk >= 3) {
- getmapxy( .@map$, .@x, .@y, 0 );
- if(@map$ == .@map$ && @x == .@x && @y == .@y) {
- dispbottom "The total time playing has been stopped because you were idle for "+@afk+" Minutes.";
- set @afk, @afk + 1;
- }
- else
- {
- set @afk,0;
- }
- stopnpctimer;
- attachnpctimer ""+strcharinfo(0)+"";
- initnpctimer;
- end;
- }
- if(checkvending() >= 1 || checkchatting() == 1) {
- set @afk, @afk + 1;
- stopnpctimer;
- attachnpctimer ""+strcharinfo(0)+"";
- initnpctimer;
- end;
- }
- else
- {
- //Check if Idle
- getmapxy( .@map$, .@x, .@y, 0 );
- if(@map$ == .@map$ && @x == .@x && @y == .@y) {
- set @afk, @afk + 1;
- }
- //If move increases total time of accnt by 1 min
- else {
- set @afk, 0;
- set totaltime,totaltime+1;
- if ((totaltime%60)==0){ getitem 673,1; dispbottom "Heres your reward being online for total time in minutes: "+ totaltime; }
- if ((totaltime%300)==0){ getitem 671,1; dispbottom "Heres your reward being online for total time in minutes: "+ totaltime; }
- }
- set @map$, .@map$; set @x, .@x; set @y, .@y;
- //Idle Check for 3 minutes
- //if(@afk >= 3) {
- //dispbottom "The total time playing has been stopped because you were idle for "+@afk+" Minutes.";
- //stopnpctimer;
- //attachnpctimer ""+strcharinfo(0)+"";
- //initnpctimer;
- //end;
- //}
- //dont uncomment this area unless you know what to do and what will happen
- //query_sql "UPDATE `totaltime` SET `time` = (`time` + 1) WHERE `account_id`=" + getcharid(3);
- //dispbottom "your total time in minutes: "+ totaltime; // for debug purposes
- stopnpctimer;
- attachnpctimer ""+strcharinfo(0)+"";
- initnpctimer;
- end;
- //recording times or updating database
- OnPCLogoutEvent:
- set @totalcalc,totaltime-totaltimeold;
- query_sql "SELECT MAX(base_level) FROM `char` where account_id=" + getcharid(3),.@maxlvl;
- query_sql "UPDATE `totaltime` SET `time` = (`time` + " + @totalcalc + ") WHERE `account_id`=" + getcharid(3);
- query_sql "UPDATE `totaltime` SET `level` = (" + .@maxlvl + ") WHERE `account_id`=" + getcharid(3);
- end;
- }
- }
- //--End of the Script
- //Time ladder
- mellina,64,60,5 script Referral System 837,{
- set .@harmony,1; // if you have harmony, set this to 1 or more for additional mac address check
- set .@mlvlreq,230; //lvl requirement for the newbie to qualify for a point
- set .@daysqualify,3; //number of days of gaming time
- set .@timequalify,.@daysqualify*24*60; //.@daysqualify stands for days, 24 for hours , 60 for min edit this to your own liking
- set .@pointreq,5; //total point requirement in order to claim the reward, this will also determine the length of the list of accounts that the player recruited.
- set .@npc$,"[ ^FF0000 Referral System ^000000 ]"; // npc name
- set .@glvl,99; // minimum group level to check the list of accounts that had the longest game time/length
- set .@llength,10;// length of the list for gm's
- set .@Zeny,0; //Zeny reward (0:Disable)
- set .@maxZeny,2000000000;// max Zeny of the server
- setarray .@itemreward, 7227,677; //item rewards (0:Disable)
- setarray .@itemquantity, 120,6;// it should be paired with item reward
- //start of script
- mes .@npc$;
- mes "What do you want to do?";
- switch(select("Time Check:Referral System:Close")){
- case 1:
- next;
- if (getgroupid()>=.@glvl)
- {
- mes .@npc$;
- query_sql "SELECT account_id, time FROM `totaltime` ORDER BY time DESC LIMIT 10",.@nameid,.@time;
- for(set .@i,0;.@i<.@llength;set .@i,.@i+1) {
- mes "^0000FF"+(.@i+1)+".^000000 " +( (.@nameid[.@i] == 0)? "None":.@nameid[.@i] )+ " - ^FF0000"+(.@time[.@i])+"^000000 Minute(s)";
- }
- mes " ";
- }
- query_sql "SELECT `time` FROM `totaltime` WHERE `account_id`="+getcharid(3),.@time;
- mes "^0000FF["+strcharinfo(0)+"'s]^000000 total time is ^FF0000"+(.@time)+"^000000 Minute(s).";
- close;
- break;
- case 2:
- switch(select("Check Points and Recruits:Your Recruiter:Close")){
- case 1:
- query_sql "SELECT account_id, time , level FROM `totaltime` WHERE `raccount_id`="+getcharid(3)+" ORDER BY level DESC LIMIT 10",.@name$,.@time,.@level$;
- for(set .@i,0;.@i<.@pointreq;set .@i,.@i+1) {
- mes "^0000FF"+(.@i+1)+".^000000 " +( (.@name$[.@i] == "")? "None":.@name$[.@i] )+ " - ^FF0000"+(.@time[.@i])+"^000000 Minute(s)";
- }
- query_sql "SELECT account_id FROM `totaltime` WHERE `time`>= "+.@timequalify+" AND `raccount_id`="+getcharid(3)+" ORDER BY level DESC LIMIT 10 ",.@name1$;
- set .@paccounts, getarraysize(.@name1$);
- set .@pointearned,0;
- for(set .@i,0; .@i<=.@paccounts; set .@i,.@i+1)
- {
- query_sql "SELECT MAX(base_level) FROM `char` where account_id="+.@name1$,.@maxlvl;
- if ( .@maxlvl>=.@mlvlreq ) { set .@pointearned,.@pointearned+1; break; }
- }
- mes "________________________";
- mes "You will earn 1 point for every Recruit you have who's been playing for "+ .@daysqualify +" day(s) worth of game time and he or she must have at least 1 level "+.@mlvlreq+" character in his or her account.";
- mes "________________________";
- mes "You already have ^FF0000"+ .@pointearned +"^000000 points gained";
- mes "________________________";
- query_sql "SELECT `claimed` FROM `totaltime` WHERE `account_id`="+getcharid(3),.@clamied;
- if (.@clamied==1) mes "Your reward status:^00FF00Already claimed Reward^000000"; close;
- if (.@clamied==0)
- {
- mes "Your reward status:^FF0000Haven't claimed reward^000000";
- mes "________________________";
- next;
- mes .@npc$;
- mes "Do you want to claim your reward?";
- switch(select("Yes:Close"))
- {
- case 1:
- next;
- mes .@npc$;
- mes "You will need 10 points to claim your reward...";
- mes "________________________";
- mes "You already have ^FF0000"+ .@pointearned +"^000000 points gained";
- switch(select("Claim Reward:Close"))
- {
- case 1:
- if (.@pointearned>=.@pointreq)
- {
- next;
- mes .@npc$;
- if ((Zeny+.@Zeny)>=.@maxZeny)
- {
- mes "If i reward you will have more than "+ .@maxZeny +" which is the max limit of Zeny in the server...";
- mes "Come back once you have lesser Zeny with you";
- close;
- }
- else
- {
- set Zeny,Zeny + .@Zeny;
- for(set .@i, 0; .@i < getarraysize(.@itemreward); set .@i, .@i + 1)
- {
- if(.@itemreward)
- {
- getitem .@itemreward[.@i], .@itemquantity[.@i];
- }
- else
- {
- break;
- }
- }
- mes "Congratulations you have been rewarded by recruiting Active players :)";
- query_sql "UPDATE `totaltime` SET `claimed` = (1) WHERE `account_id`=" + getcharid(3);
- close;
- }
- }
- else
- {
- next;
- mes .@npc$;
- mes "Sorry, You haven't met the requirements";
- mes "come back once you have "+.@pointreq+" points";
- close;
- }
- close;
- break;
- case 2:
- mes .@npc$;
- mes "See you later...";
- close;
- break;
- }
- break;
- case 2:
- mes .@npc$;
- mes "See you later...";
- break;
- close;
- }
- }
- close;
- break;
- case 2:
- query_sql "SELECT `raccount_id` FROM `totaltime` WHERE `account_id`="+getcharid(3),.@raccountid;
- if (.@raccountid==0) // no recruiter
- {
- mes .@npc$;
- mes "Do you want to register your recruiter?";
- switch(select("Yes:NO"))
- {
- case 1:
- next;
- mes .@npc$;
- mes "Kindly Type the Name of Your Recruiter. Make sure you have the right spelling";
- set @rname$,0;
- input @rname$;
- if (@rname$ == strcharinfo(0)) //checks if the player writes his/her own name
- {
- next;
- mes .@npc$;
- mes "You can't be your own recruiter";
- close;
- break;
- }
- if (@rname$=="") //checks if the recruiter exists
- {
- next;
- mes .@npc$;
- mes "Please Enter a The name of your Recruiter";
- close;
- break;
- }
- query_sql "SELECT `account_id` FROM `char` WHERE `name`='"+@rname$+"'",.@accid;
- if (.@accid == getcharid(3)) //checks if he's trying to recruit himself with his other characters
- {
- next;
- mes .@npc$;
- mes "You can't use your other character to be your own recruiter";
- close;
- break;
- }
- else
- {
- if(.@harmony >= 1)
- { //harmony mac address check
- query_sql "SELECT `last_mac` FROM `login` WHERE `account_id`="+getcharid(3),.@lastmac1$;
- query_sql "SELECT `last_mac` FROM `login` WHERE `account_id`="+.@accid,.@lastmac2$;
- if(.@lastmac1$==.@lastmac2$)
- {
- next;
- mes .@npc$;
- mes "You can't use your other account to be your own recruiter";
- close;
- break;
- }
- }
- query_sql "SELECT `time` FROM `totaltime` WHERE `account_id`="+.@accid,.@rtime;//gets the time of the recruiter
- query_sql "SELECT `time` FROM `totaltime` WHERE `account_id`="+getcharid(3),.@rtime2;//gets the the of the newbie
- if (.@rtime2>=.@rtime) //compare both times
- {
- next;
- mes .@npc$;
- mes "Your recruiter is not qualified..";
- mes "Your game time is greater than your recruiter...";
- mes "Your recruiter should be more experienced than you..";
- close;
- break;
- }
- next;
- mes .@npc$;
- mes "Are you sure yo want "+ @rname$ +" to be your recruiter?";
- mes "^FF0000note^000000 you can't change this any more once you set it up";
- switch(select("Yes:No"))
- {
- case 1:
- next;
- query_sql "UPDATE `totaltime` SET `raccount_id` = (" + .@accid + ") WHERE `account_id`=" + getcharid(3);
- mes "You have listed "+@rname$+" as your recruiter";
- break;
- close;
- case 2:
- next;
- mes .@npc$;
- mes "See you later...";
- break;
- close;
- }
- }
- case 2:
- next;
- mes .@npc$;
- mes "See you later...";
- close;
- break;
- }
- }
- else //already recruited
- {
- next;
- mes .@npc$;
- mes "You have already been recruited.";
- mes "See you later...";
- close;
- break;
- }
- close;
- break;
- case 3:
- next;
- mes .@npc$;
- mes "See you later...";
- close;
- break;
- }
- close;
- break;
- case 3:
- next;
- mes .@npc$;
- mes "See you later...";
- close;
- break;
- }
- OnInit:
- waitingroom "Referral System",0; // Look on the configuration!
- }
- //execute this to your sql database
- /*
- CREATE TABLE IF NOT EXISTS `totaltime` (
- `account_id` int(11) NOT NULL,
- `time` int(255) NOT NULL,
- `claimed` int(11) NOT NULL,
- `raccount_id` int(11) NOT NULL,
- `level` int(11) NOT NULL,
- `mac` VARCHAR( 18 ) NOT NULL, //remove this line if you don't have harmony/or any mac address detection
- PRIMARY KEY (`account_id`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement