// @unloadnpc onlinepoints
// @loadnpc npc/valhalla/online.txt

-	script	onlinepoints	-1,{
end;

OnPCLoginEvent:
	if(checkvending() == 2) end;
	attachnpctimer ""+strcharinfo(PC_NAME)+"";
	initnpctimer;
	if(#minute >= .Rest) {
		getitem Hourly_Coin,1;
		set #minute, 0;
	}
	end;

OnTimer30000:
	if(checkvending() == 2) stopnpctimer;
	end;

OnTimer60000:
	if(checkvending() == 2 ) end;
	++#minute;
	++#DAILYTIME;
	if(#minute >= .Rest) {

		if(BaseLevel > 79){	// XL 5%
			if(rand(1,100) < 5){
				if(rand(1,2) == 1) {
					getitem 30050,1;
				} else {
					getitem 30054,1;
				}
			}
		} else if(BaseLevel > 59){	// L 10%
			if(rand(1,100) < 10){
				if(rand(1,2) == 1) {
					getitem 30049,1;
				} else {
					getitem 30053,1;
				}
			}
		} else if(BaseLevel > 39){	// M 20%
			if(rand(1,100) < 20){
				if(rand(1,2) == 1) {
					getitem 30048,1;
				} else {
					getitem 30052,1;
				}
			}
		} else {			// S 50%
			if(rand(1,100) < 100){
				if(rand(1,2) == 1) {	
					getitem 30047,1;
				} else {
					getitem 30051,1;
				}
			}
		}
		#PLAYTIME += 1;
		getitem Hourly_Coin,1;
		dispbottom "Keep staying online to receive "+getitemname(Hourly_Coin)+" per hour. Double click the token to open a special shop";
		set #minute, 0;
	}
	stopnpctimer;
	initnpctimer;	
	end;

OnInit:
	set .Rest,60;
	end;
}