-----------------------------------
-- 
-- Zone: Dynamis-San_dOria
-- 
-----------------------------------
package.loaded["scripts/zones/Dynamis-San_dOria/TextIDs"] = nil;
-----------------------------------

require("scripts/globals/settings");
require("scripts/zones/Dynamis-San_dOria/TextIDs");

-----------------------------------
--  onInitialize
-----------------------------------

function onInitialize(zone)
end;

-----------------------------------
-- onZoneIn
-----------------------------------

function onZoneIn(player,prevZone)
	
	cs = -1;
	
	local realDay = os.time();
	local dynaWaitxDay = player:getVar("dynaWaitxDay");
	
	if((dynaWaitxDay + (BETWEEN_2DYNA_WAIT_TIME * 24 * 60 * 60)) < realDay or player:getVar("DynamisID") == GetServerVariable("[DynaSandoria]UniqueID")) then
		if(player:isBcnmsFull() == 1) then
			if(player:hasStatusEffect(EFFECT_DYNAMIS, 0) == false) then
				inst = player:addPlayerToDynamis(1281);
				
				if(inst == 1)then
					player:bcnmEnter(1281);
				else
					 cs = 0;
				end
			else
				player:bcnmEnter(1281);
			end
		else
			inst = player:bcnmRegister(1281);
			
			if(inst == 1)then
				player:bcnmEnter(1281);
			else
				cs = 0;
			end
		end
	else
		cs = 0;
	end

	return cs;
	
end;

-----------------------------------
-- onRegionEnter          
-----------------------------------

function onRegionEnter(player,region)
end;

-----------------------------------
-- onEventUpdate
-----------------------------------

function onEventUpdate(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
end;

-----------------------------------
-- onEventFinish
-----------------------------------

function onEventFinish(player,csid,option)
--printf("CSID: %u",csid);
--printf("RESULT: %u",option);
	
	if(csid == 0) then
		player:setPos(161.000,-2.000,161.000,94,0xE6);
	end
	
end;