//@unloadnpc loginevent
//@loadnpc npc/valhalla/OnPCLoginEvent.txt

-	script	loginevent	-1,{
end;

OnInit:
/*************************************************************
 *                      Configuration                        *
 *************************************************************/
	.@ServName$ = "Valhalla Ragnarok Online";

	setarray .announcements$, "Hope you're having fun on "+ .@ServName$+"! Please invite your friends to play with us. Visit our FB Page or website to get updates.",
		 "[ Tips ] You can claim your free supplies at Morocc. Re-supply is scheduled every 6AM and 6PM",
		 "[ Tips ] Use command @sell to send global message that you want to sell your item in your inventory.!",
		 "[ Tips ] Use command @buy to send global message that you want to buy specific item.!",
		 "[ Tips ] You can get random costume and Stat Reset Stone from your Lvl 30 Growth Pack. Enjoy!",
		 "[ Tips ] You can get Skill Reset Rod from your Lvl 40 Growth Pack. Enjoy!",
		 "[ Tips ] Staying online will earn you 1x Play Time Token per hour. Use this token to open a special shop.!",
		 "[ Tips ] Use command @whereis <mob> it will display list of map where it is spawned.",
		 "[ Tips ] Use command @whodrops <item> it will display list of mobs who will drop it.",
		 "[ Tips ] Convert your favorite Regular Headgear into a Costume FREE of charge. Visit the Stylist NPC at Central Office.",
		 "[ Tips ] I can't find Juice Maker (Marx Hansen)! Visit our website https://valhallaro.net and check out our Guides section.",
		 "[ Tips ] Kafra Employee can warp you to ALL cities and 1st level dungeon.",
		 "[ Tips ] Join the battleground and earn special badges. Use @joinbg to join and @bgshop to check goodies it offers.",
		 "[ Warning ] Blocking an NPC or staying on the location where an NPC is positioned is strictly prohibited.  We will block player trying to do this annoying act.",
		 "[ Warning ] Real Money Trading (RMT) is strictly prohibited inside the game.  We will impose perma block on accounts both buyer and seller engaging in this transactions.",	
		 "[ Warning ] Adding any contact info to PUB or VEND, may it be phone or social media account is a form of  Real Money Trading (RMT) is strictly prohibited inside the game.  We will impose perma block on accounts without notice.",	
		 "[ Warning ] Creating a dummy account to perform Real Money Trading (RMT) is strictly prohibited inside the game. We will impose perma block on your machineID without notice.",	
		 "[ Warning ] Sending a private message to sell an item for Real Money is strictly prohibited inside the game. We will impose perma block on accounts without notice.",	
		 "[ Tips ] Can't find the Change Job Master? Warp to Central Office using Kafra Teleport Service.";

	setarray .announcements_m$, "Hope you're having fun on "+ .@ServName$+"! Please invite your friends to play with us. Visit our FB Page or website to get updates.",
		 "[ Tips ] You can claim your free supplies at Morocc. Re-supply is scheduled every 6AM and 6PM",
		 "[ Tips ] Use command @sell to send global message that you want to sell your item in your inventory.!",
		 "[ Tips ] Use command @buy to send global message that you want to buy specific item.!",
		 "[ Tips ] You can get random costume and Stat Reset Stone from your Lvl 30 Growth Pack. Enjoy!",
		 "[ Tips ] You can get Skill Reset Rod from your Lvl 40 Growth Pack. Enjoy!",
		 "[ Tips ] Staying online will earn you 1x Play Time Token per hour. Use this token to open a special shop.!",
		 "[ Tips ] Use command @whereis <mob> it will display list of map where it is spawned.",
		 "[ Tips ] Use command @whodrops <item> it will display list of mobs who will drop it.",
		 "[ Tips ] Convert your favorite Regular Headgear into a Costume FREE of charge. Visit the Stylist NPC at Central Office.",
		 "[ Tips ] I can't find Juice Maker (Marx Hansen)! Visit our website https://valhallaro.net and check out our Guides section.",
		 "[ Tips ] Kafra Employee can warp you to ALL cities and 1st level dungeon.",
		 "[ Tips ] Join the battleground and earn special badges. Use @joinbg to join and @bgshop to check goodies it offers.",
		 "[ Warning ] Blocking an NPC or staying on the location where an NPC is positioned is strictly prohibited.  We will block player trying to do this annoying act.",
		 "[ Warning ] Real Money Trading (RMT) is strictly prohibited inside the game.  We will impose perma block on accounts both buyer and seller engaging in this transactions.",	
		 "[ Warning ] Adding any contact info to PUB or VEND, may it be phone or social media account is a form of  Real Money Trading (RMT) is strictly prohibited inside the game.  We will impose perma block on accounts without notice.",	
		 "[ Warning ] Creating a dummy account to perform Real Money Trading (RMT) is strictly prohibited inside the game. We will impose perma block on your machineID without notice.",	
		 "[ Warning ] Sending a private message to sell an item for Real Money is strictly prohibited inside the game. We will impose perma block on accounts without notice.",	
		 "[ Tips ] Can't find the Change Job Master? Warp to Central Office using Kafra Teleport Service.";
	end;

OnAnnounce:
	announce .announcements$[rand(getarraysize(.announcements$))],bc_self;
	addtimer 300000,strnpcinfo(0) + "::OnAnnounce";
	end;

OnAnnounce_m:
	announce .announcement_ms$[rand(getarraysize(.announcements_m$))],bc_self;
	addtimer 300000,strnpcinfo(0) + "::OnAnnounce_m";
	end;

OnPCLoginEvent:
	if(!countitem(12622) && hascashmount()){
		setcashmount();
	}
	if(!countitem(30045) ) {
		getitem 30045,1;
	}
	if(spinning1){
		spinning1 = 0;
		dispbottom "You have pending Gatcha I spin at the Central Office.  Please talk to the machine to refund tickets.";
	}
	if(r_spinning){
		r_spinning = 0;
		dispbottom "You have pending Card Recycler tries from King Poring.  Please talk to him to retry.";
	}	
	/* Check if mobile or PC */
	query_sql "SELECT `last_ip` FROM login WHERE `account_id` = "+ getcharid(CHAR_ID_ACCOUNT), .@last_ip$;
	@is_mobile = ( .@last_ip$ == "45.124.64.45" );
 	if (@is_mobile) {
		set #mobile,1;
   		announce .announcements_m$[rand(getarraysize(.announcements_m$))],bc_self;
    		addtimer 300000,strnpcinfo(0) + "::OnAnnounce_m";
	} else {
		set #mobile,0;
   		announce .announcements$[rand(getarraysize(.announcements$))],bc_self;
    		addtimer 300000,strnpcinfo(0) + "::OnAnnounce";
	}
	end;

}

