//=============================================================================
// Sheep saved the day here again.
// MainMan [edit]: his code is no longer needed.
//=============================================================================
class Key1Button extends DeusExDecoration;

var(loser) int CreditCost;
var(loser) class<Inventory> SpawnClass;
var int PandaLagga;

Function Tick(Float DeltaTime)
{
	if(PandaLagga > 0)
	{
		PandaLagga -= 1;
	}

	if(PandaLagga < 0)
	{
		PandaLagga = 0;
	}

	Super.Tick(DeltaTime);
		
}

function Frob(Actor Frobber, Inventory frobWith)
{
	local KeyDummy hmm2;

	local int klopisgay;

	local RPGSpawn SpawnObject;
	local MMRPGCreditCard Inv;
	local DeusExPlayer Player;
	local int i;
	local int k;
	local int q;
	local AptKey Inv2;
	local AptKey xxx;
	local _MMRPGPlayer MMP;


	local Class<Inventory> B1;
	local Class<Inventory> B2;
	local Class<Inventory> B3;
	local Class<Inventory> B4;
	local Class<Inventory> B5;
	local Class<Inventory> B6;
	local Class<Inventory> B7;
	local Class<Inventory> B8;
	local Class<Inventory> B9;
	local Class<Inventory> B10;

	Player = DeusExPlayer(Frobber);
	
	If(PandaLagga > 0)
	{
		//PandaLagga = 30;
		//Player.Clientmessage("|p2-Please Wait-");
		//_MMRPGPlayer(Frobber).PandaLagga = 30;
		return;
	}

	if(_MMRPGPlayer(Frobber).PandaLagga > 0)
	{
		Player.Clientmessage("|p2-Please Wait-");
		_MMRPGPlayer(Frobber).PandaLagga = 30;
		return;
	}

	if(_MMRPGPlayer(Frobber).PandaLagga == 0)
	{

	If(PandaLagga == 0)
	{
		PandaLagga = 30;
		_MMRPGPlayer(Frobber).PandaLagga = 30;

	Inv2=None; //to make sure!!
	klopisgay = 0;



   		foreach AllActors(class'MMRPGCreditCard', Inv)
		{
			if (Inv.Owner == Player)
			{
				if (Inv.CreditAmount < CreditCost)
				{
					Player.ClientMessage("You do not have enough money");
					return;
				}
			}
		}



	if(_MMRPGPlayer(Player).KeyCheck() == False)
	{
			return;
	}



	i = 0;
	k = 0;
	for(k=0;k<11;k++)
	{
		for(i=0;i<1500;i++)
		{
			if(class'InvContender'.static.GetBank(i, k) == String(SpawnClass))
			{
				klopisgay = 1;
				Player.ClientMessage("|p2This apartment has already been taken");
				return;
			}
		}
			
	}

	for(k=0;k<11;k++)
	{
		for(i=0;i<1500;i++)
		{
			if(class'InvContender'.static.GetInv(i, k) == String(SpawnClass))
			{
				klopisgay = 1;
				Player.ClientMessage("|p2This apartment has already been taken");
				return;
			}
		}
			
	}

	foreach AllActors(class'_MMRPGPlayer', MMP)
	{
		if(  (MMP.BankItem1 == String(SpawnClass))||  (MMP.BankItem2 == String(SpawnClass))||  (MMP.BankItem3 == String(SpawnClass))||  (MMP.BankItem4 == String(SpawnClass))||  (MMP.BankItem5 == String(SpawnClass))||  (MMP.BankItem6 == String(SpawnClass))||  (MMP.BankItem7 == String(SpawnClass))||  (MMP.BankItem8 == String(SpawnClass))||  (MMP.BankItem9 == String(SpawnClass))||  (MMP.BankItem10 == String(SpawnClass))   )
		{
			klopisgay = 1;
			Player.ClientMessage("|p2This apartment has already been taken");
			return;	
		}
	}

	foreach AllActors(class'Aptkey', Inv2)
	{
		if(Inv2.Class == SpawnClass)
		{
			klopisgay = 1;
			Player.ClientMessage("|p2This apartment has already been taken");
			return;
		}
	}

	if(klopisgay == 0)
	{
		Inv = None;
   		foreach AllActors(class'MMRPGCreditCard', Inv)
		{
			if (Inv.Owner == Player)
			{
				if (Inv.CreditAmount >= CreditCost)
				{
					foreach AllActors(class'KeyDummy', hmm2)
					{
						if (hmm2 != None)
						{
							if (Player.HandleItemPickup(hmm2, True) == False)
							{
								return;
							}
						}
					}
					Inv.CreditAmount -= CreditCost;
					Player.ClientMessage(""$CreditCost$" credits deducted from your credit card");
					_MMRPGPlayer(Player).SpawnItemz(SpawnClass);
				}
				else Player.ClientMessage("You do not have enough money");
			}
		}
	}
	}
	}
}	


defaultproperties
{
     CreditCost=450
     SpawnClass=Class'Contender.AptKey1'
     bInvincible=True
     ItemName="Apartment 1"
     bPushable=False
     Physics=PHYS_None
     Skin=Texture'DeusExDeco.Button1Tex5'
     RemoteRole=ROLE_SimulatedProxy
     Mesh=LodMesh'DeusExDeco.Button1'
     CollisionRadius=2.000000
     CollisionHeight=2.000000
     bCollideWorld=False
     bBlockActors=False
     Mass=5.000000
     Buoyancy=2.000000
}
