//Begin cash functions
function togglecash()
{
 if(!$Host::Cash)
 {
  $Host::Cash = 1;
  messageAll("yar", "\c2The admin has enabled RPG mode!");
  messageAll("MsgAdminForce", "\c3To get a job please type /job for job listings. Getting the job you want is simple, just type /job {jobname}.");
  %count = ClientGroup.getCount();
  for(%i = 0; %i < %count; %i++)
  {
   %obj = ClientGroup.getObject(%i);
   %obj.cash = $Cash::Basecash;
   %obj.job = $Cash::Basejob;
   %obj.tax = $Cash::Basetax;
   %obj.income = $Cash::Baseincome;
   %obj.rpgName = %obj.nameBase;
  }
  payClients();
  taxClients();
 }
 else
 {
  $Host::Cash = 0;
  messageAll("yar", "\c2The admin has disabled RPG mode!");
  messageAll("MsgAdminForce", "\c3All jobs and cash values have been completely reset!");
  %count = ClientGroup.getCount();
  for(%i = 0; %i < %count; %i++)
  {
   %obj = ClientGroup.getObject(%i);
   %obj.cash = "";
   %obj.job = "";
   %obj.taxrate = "";
   %obj.income = "";
  }
 }
}
//Pay the clients
function payClients()
{
 if ($Host::Cash)
 {
  %count = ClientGroup.getCount();
  for(%i = 0; %i < %count; %i++)
  {
   %obj = ClientGroup.getObject(%i);
   if (%obj.cash $= "")
    %obj.cash = $Cash::Basecash;
   if (%obj.job $= "")
    %obj.job = $Cash::Basejob;
   if (%obj.income $= "")
    %obj.income = $Cash::Baseincome;
   if (%obj.taxrate = "")
    %obj.tax = $Cash::Basetax;
   //pay clients.
   %obj.cash = (%obj.income + %obj.cash);
   messageClient(%obj, "Paythebooty", "\c2You've been payed \c3$" @ %obj.income @ "\c2 and now have \c3$" @ %obj.cash);
  }
  schedule($Cash::PayTime * 1000, 0, "payClients");
 }
}
//Tax the clients
function taxClients()
{
 if ($Host::Cash)
 {
  %count = ClientGroup.getCount();
  for (%i = 0; %i < %count; %i++)
  {
   %obj = ClientGroup.getObject(%i);
   %obj.cash = %obj.cash - (%obj.income * %obj.tax);
   messageClient(%obj, "Taxedthebooty", "\c2You've been taxed and now have \c3$" @ %obj.cash);
  }
  %random = getRandom($Cash::MinTaxTime, $Cash::MaxTaxTime);
  schedule(%random * 1000, 0, "taxClients");
 }
}
//End Cash functions