Jump to content
  • 0
nasagnilac

Timer Problem

Question

Hello I have here a script where npc give players a 5 minutes call to relogin in able to have an exp boost. but the problem is when the script is not activated on its time I can still receive the exp boost. I want you to check if my timer is correct. Thnx in advance.

//-------------------------------------------------------------------------------------------------	
-	script	Free Rewards	FAKE_NPC,{

OnHour11:
OnHour13:
OnHour17:
OnHour19:
goto enable;

enable:
			if(.svn){
				query_sql "DELETE FROM `acc_reg_num_db` WHERE `key`='#expboost'";
			}else{
				query_sql "DELETE FROM `global_reg_value` WHERE `str`='#expboost'";
			}
				
		set .available,1;
		set .rewards$,"EXP BOOST";
		announce "[ FREE "+.rewards$+" ] Re-login now! You have only 5 minutes for FREE "+.rewards$+".",0;
		startnpctimer;
end;

OnTimer60000:
	announce "[ FREE "+.rewards$+" ] You have 4 minutes left to relogin.",0;
	end;

OnTimer120000:
	announce "[ FREE "+.rewards$+" ] You have 3 minutes left to relogin.",0;
	end;

OnTimer180000:
	announce "[ FREE "+.rewards$+" ] You have 2 minutes left to relogin.",0;
	end;

OnTimer240000:
	announce "[ FREE "+.rewards$+" ] You have 1 minute left to relogin.",0;
	end;

OnTimer300000: 
	announce "[ FREE "+.rewards$+" ] Time's Up...!",0;
	stopnpctimer;
	goto reset;
	end;
	
reset:
	set .available,0; 
end;

OnInit:
	//-------------------------------------------------------------------------------------------------	
		set .svn,1;			// 0 - rAthena/eAthena, 1 - Hercules
		set .available,0; 
		set .n$, "^FF0000[Free EXP BOOST]^000000";
		bindatcmd "expboost","Free Rewards::OnDoEvent",80,100;		// Admin reset command
	//-------------------------------------------------------------------------------------------------	
end;


OnDoEvent:

	if ( compare( .@atcmd_parameters$, "reset" ) ) {
				if(.svn){
					query_sql "DELETE FROM `acc_reg_num_db` WHERE `key`='#expboost'";
				}else{
					query_sql "DELETE FROM `global_reg_value` WHERE `str`='#expboost'";
				}
		mes .n$;
		mes"FREE EXP BOOST has been reset."; 
		close;
	}else if ( compare( .@atcmd_parameters$, "on" ) ) { 
		mes .n$;
		mes "FREE EXP BOOST is now enabled."; 
		close2;
		set .available,1; 
		set .rewards$,"EXP BOOST";
		announce "[ FREE "+.rewards$+" ] Re-login now! You have only 5 minutes for FREE "+.rewards$+".",0;
		startnpctimer;
	}
end;




OnPCLoginEvent:
	if(.available){
	    	if(!#expboost){		
			set #expboost,1;	
			sc_start SC_CASH_PLUSEXP,900000,150;
			sc_start SC_CASH_RECEIVEITEM,900000,150;
		end;
		}
	}
end;

}

 

Edited by gmblank

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0


//-------------------------------------------------------------------------------------------------

- script Free Rewards FAKE_NPC,{

 

OnHour11:

OnHour13:

OnHour17:

OnHour19:

OnEnable:

.time = gettimetick(2)+(5*60); // 5 Minutes

.available = true;

.rewards$ = "Exp Boost";

announce "[ FREE "+.rewards$+" ] Re-login now! You have only 5 minutes for FREE "+.rewards$+".", bc_all;

initnpctimer;

end;

 

OnTimer60000:

announce "[ FREE "+.rewards$+" ] You have 4 minutes left to relogin.", bc_all;

end;

 

OnTimer120000:

announce "[ FREE "+.rewards$+" ] You have 3 minutes left to relogin.", bc_all;

end;

 

OnTimer180000:

announce "[ FREE "+.rewards$+" ] You have 2 minutes left to relogin.", bc_all;

end;

 

OnTimer240000:

announce "[ FREE "+.rewards$+" ] You have 1 minute left to relogin.", bc_all;

end;

 

OnTimer300000:

announce "[ FREE "+.rewards$+" ] Time's Up...!", bc_all;

stopnpctimer;

.available = false;

end;

 

OnInit:

//-------------------------------------------------------------------------------------------------

.available = false;

.n$ = "^FF0000[Free EXP BOOST]^000000";

bindatcmd "expboost","Free Rewards::OnDoEvent",80,100; // Admin reset command

//-------------------------------------------------------------------------------------------------

end;

 

 

OnDoEvent:

// No Need of Reset, starting new event will reset the expboost.

if (compare(.@atcmd_parameters$, "on")) {

mes .n$;

mes "FREE EXP BOOST is now enabled.";

close2;

callsub OnEnable;

}

end;

 

 

 

 

OnPCLoginEvent:

if (.available == true && .time > 0) {

if (#expboost < .time) {

#expboost = .time;

sc_start SC_CASH_PLUSEXP,900000,150;

sc_start SC_CASH_RECEIVEITEM,900000,150;

}

}

end;

}

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.