Chrono, your my savior. Now. ONE MORE PROBLEM. When I mine the "Lead". I dont get my 15 dollars, pounds... units, whatever. money.
$Dig_pickCost[1] = 50;
$Dig_pickCost[2] = 100;
$Dig_pickCost[3] = 175;
$Dig_pickCost[4] = 250;
$Dig_pickCost[5] = 400;
$Dig_valueMin["gold"] = 10;
$Dig_valueMin["einst"] = 3;
$Dig_valueMin["silver"] = 6;
%Dig_valueMin["lead"] = 15;
function servercmdstartDig(%client)
{
if(%client.bl_id != getNumKeyID() && findLocalClient() !$= %client)
{
messageClient(%client, '', "You are not the host so you cannot start dig mode");
return;
}
$Dig_allowedMission["Slate"] = 1;
$Dig_allowedMission["Slate Aurora"] = 1;
$Dig_allowedMission["Destruct"] = 1;
$Dig_groundID["Slate"] = 5;
$Dig_groundID["Slate Aurora"] = 6;
$Dig_groundID["Destruct"] = 5;
if(!$Dig_allowedMission[missionInfo.name])
{
messageClient(%client, '', "Dig mode is only usable in Slate, Slate Aurora, and Destruct");
return;
}
$Dig_host = %client;
$Dig_host_brickgroup = %client.brickgroup;
$Dig_host_id = %client.bl_id;
deleteVariables("$Dig_placedDirt*");
%ground = missionGroup.getobject($Dig_groundID[missionInfo.name]);
if(missionInfo.name $= "Slate Aurora")
%water = missionGroup.getobject(7);
if(isObject(%ground))
%ground.delete();
if(isObject(%water))
%water.delete();
%spawnsphere = playerDropPoints.getobject(0);
%spawnsphere.radius = 5;
%spawnsphere.RayHeight = 3;
messageAll('', "<color:00FF00>Dig mode is now enabled");
for(%x = -5.5; %x <= 5.5; %x++)
for(%y = -5.5; %y <= 5.5; %y++)
{
Dig_PlaceCement(%x*2 SPC %y*2 SPC 0, "brick4xCubeData");
Dig_PlaceCement(%x*2 SPC %y*2 SPC 10, "brick4xCubeData");
}
%pos[0] = "10 10";
%pos[1] = "10 -10";
%pos[2] = "-10 10";
%pos[3] = "-10 -10";
for(%a = 0; %a < 4; %a++)
{
Dig_PlaceCement(%pos[%a] SPC 3, "brick8xCubeData");
Dig_PlaceCement(%pos[%a] SPC 7, "brick8xCubeData");
}
for(%z = 0; %z <= 3; %z++)
{
for(%x = 0; %x < 8; %x++)
Dig_PlaceDirt(-7 + %x*2 SPC 11 SPC 2+%z*2);
for(%y = 0; %y < 8; %y++)
Dig_PlaceDirt(11 SPC 7 - %y*2 SPC 2+%z*2);
for(%x = 0; %x < 8; %x++)
Dig_PlaceDirt(7 - %x*2 SPC -11 SPC 2+%z*2);
for(%y = 0; %y < 8; %y++)
Dig_PlaceDirt(-11 SPC -7 + %Y*2 SPC 2+%z*2);
}
%light = Dig_PlaceCement("0 0 8.75", "brick2x2FRoundData");
%light.setLight(PlayerLight);
activatepackage(Dig_spawnPackage);
for(%c = 0; %c < ClientGroup.getCount(); %c++)
if(ClientGroup.getObject(%c).hasSpawnedOnce)
ClientGroup.getObject(%c).instantRespawn();
Dig_announceStats();
$Dig_on = 1;
}
function servercmdStopDig(%client)
{
if(%client.bl_id != getNumKeyID() && findLocalClient() !$= %client)
{
messageClient(%client, '', "You are not the host so you cannot stop dig mode");
return;
}
servercmdclearallbricks(%client);
cancel($Dig_announceSchedule);
messageAll('', "<color:00FF00>Dig mode is off");
Dig_changeMapTry();
}
function Dig_changeMapTry()
{
$Dig_changeMapSchedule = schedule(1000, 0, Dig_changeMapTry);
if($server::BrickCount == 0)
{
deactivatepackage(Dig_spawnPackage);
schedule(1000, 0, changeMap, missionInfo.name);
cancel($Dig_changeMapSchedule);
$Dig_on = 0;
}
}
function serverCmdStats(%client)
{
messageClient(%client, '', "<color:FFFFFF>Dirt: "@ %client.dig_dirt);
messageClient(%client, '', "<color:FFFFFF>Einsteinium: "@ %client.dig_einst);
messageClient(%client, '', "<color:FFFFFF>Silver: "@ %client.dig_silver);
messageClient(%client, '', "<color:FFFFFF>Gold: "@ %client.dig_gold);
messageClient(%client, '', "<color:FFFFFF>Lead: "@ %client.dig_lead);
}
function Dig_announceStats()
{
for(%c = 0; %c < ClientGroup.getCount(); %c++)
{
%client = ClientGroup.getObject(%c);
%silverCount = %client.dig_silver;
%goldCount = %client.dig_gold;
%dirtCount = %client.dig_dirt;
%einstCount = %client.dig_einst;
%leadCount = %client.dig_lead;
if(%silverCount > %highSilver)
{
%highSilver = %silverCount;
%highSilverClient = %client;
}
if(%goldCount > %highGold)
{
%highGold = %goldCount;
%highGoldClient = %client;
}
if(%dirtCount > %highDirt)
{
%highDirt = %dirtCount;
%highDirtClient = %client;
}
if(%einstCount > %highEinst)
{
%highEinst = %einstCount;
%highEinstClient = %client;
}
if(%leadCount > %highLead)
{
%highLead = %leadCount;
%highLeadClient = %client;
}
}
if(ClientGroup.getCount())
{
if(%highGoldClient.dig_gold)
schedule(0, 0, BottomPrintAll, "Most gold: <color:FFFFFF>"@ %highGoldClient.getPlayerName() @"<color:FF0000>("@ %highGoldClient.dig_gold @")", 5);
if(%highSilverClient.dig_silver)
schedule(5000, 0, BottomPrintAll, "Most silver: <color:FFFFFF>"@ %highSilverClient.getPlayerName() @"<color:FF0000>("@ %highSilverClient.dig_silver @")", 5);
if(%highDirtClient.dig_dirt)
schedule(10000, 0, BottomPrintAll, "Most dirt: <color:FFFFFF>"@ %highDirtClient.getPlayerName() @"<color:FF0000>("@ %highDirtClient.dig_dirt @")", 5);
if(%highEinstClient.dig_einst)
schedule(10000, 0, BottomPrintAll, "Most einsteinium: <color:FFFFFF>"@ %highEinstClient.getPlayerName() @"<color:FF0000>("@ %highEinstClient.dig_einst @")", 5);
if(%highLeadClient.dig_lead)
schedule(10000, 0, BottomPrintAll, "Most lead: <color:FFFFFF>"@ %highLeadClient.getPlayerName() @"<color:FF0000>("@ %highLeadClient.dig_lead @")", 5);
$Dig_announceSchedule = schedule(30000, 0, "Dig_announceStats");
}
}
function servercmdPowerMode(%client)
{
if(!%client.isAdmin)
return;
if(%client.dig_powermode)
{
messageClient(%client, '', "Power mode is now off");
%client.dig_powermode = 0;
}
else
{
messageClient(%client, '', "Power mode is now on");
%client.dig_powermode = 1;
}
}
function Dig_PlaceCement(%pos, %db)
{
%brick = new fxDTSBrick()
{
client = $Dig_host;
datablock = %db;
position = %pos;
rotation = "0 0 0 0";
colorID = 6;
scale = "1 1 1";
angleID = "0";
colorfxID = "0";
shapefxID = "0";
isPlanted = 1;
stackBL_ID = $Dig_host_id;
};
$Dig_host_brickgroup.add(%brick);
if(mAbs(getWord(%pos, 0)) == 5 && mAbs(getWord(%pos, 1)) == 5 && getWord(%pos, 2) == 0)
%brick.setItem("DiggingPickaxeItem");
$server::BrickCount++;
return %brick;
}
function Dig_PlaceDirt(%pos)
{
%x = getWord(%pos, 0);
%y = getWord(%pos, 1);
%z = getWord(%pos, 2);
%color = 8;
%colorfx = 0;
%health = 10;
if(!(mAbs(%x) <= 11 && mAbs(%y) <= 11 && %z <= 10 && %z >= 0))
{
%random = getRandom() * 100;
%c = 100;
if(%random >= %c-=2.5) //2.5% chance
{
%type = "Gold";
%color = 1;
%health = 25*3;
}
else if(%random >= %c-=2) //2%
{
%type = "Silver";
%color = 4;
%health = 15*3;
}
else if(%random >= %c-=5) //5% chance
{
%type = "Einst";
%color = 13;
%health = 11*3;
}
else if(%random >= %c-=0.5) //0.5% chance
{
%type = "lava";
%color = 0;
%health = 1;
%colorfx = 3;
}
else if(%random >= %c-=2) //2% chance
{
%type = "Lead";
%color = 6;
%health = 20*3;
}
}
%brick = new fxDTSBrick()
{
client = $Dig_host;
datablock = "brick4xCubeData";
position = %pos;
rotation = "0 0 0 0";
colorID = %color;
scale = "1 1 1";
angleID = 0;
colorfxID = %colorfx;
shapefxID = 0;
isPlanted = 1;
stackBL_ID = $Dig_host_id;
type = %type;
isMineable = 1;
health = %health;
};
$Dig_host_brickgroup.add(%brick);
$Dig_placedDirt[%pos] = 1;
$server::BrickCount++;
return %brick;
}
function Dig_rebuildDirt(%position)
{
%x = getWord(%position, 0);
%y = getWord(%position, 1);
%z = getWord(%position, 2);
%position[0] = %x+2 SPC %y SPC %z;
%position[1] = %x-2 SPC %y SPC %z;
%position[2] = %x SPC %y+2 SPC %z;
%position[3] = %x SPC %y-2 SPC %z;
%position[4] = %x SPC %y SPC %z+2;
%position[5] = %x SPC %y SPC %z-2;
for(%a = 0; %a < 6; %a++)
{
%x = getWord(%position[%a], 0);
%y = getWord(%position[%a], 1);
%z = getWord(%position[%a], 2);
if(!$Dig_placedDirt[%position[%a]] && !(mAbs(%x) <= 11 && mAbs(%y) <= 11 && %z <= 10 && %z >= 0))
Dig_PlaceDirt(%position[%a]);
}
}
function Dig_mineBrick(%obj, %col, %pos)
{
if(%col.isMineable)
{
serverPlay3D(hammerHitSound, %pos);
if(%obj.client.pickaxeNum)
%col.health -= 1*%obj.client.pickaxeNum;
else
%col.health--;
if(%col.health <= 0 || (%obj.client.isAdmin && %obj.client.dig_powermode))
{
%type = "dirt";
if(%col.type $= "gold")
{
%type = "<color:FFFF00>gold";
if(!%obj.client.dig_powermode)
{
%obj.client.mineMoney += $Dig_valueMin["gold"];
%obj.client.dig_gold++;
}
}
else if(%col.type $= "silver")
{
%type = "<color:EEE5dE>silver";
if(!%obj.client.dig_powermode)
{
%obj.client.mineMoney += $Dig_valueMin["silver"];
%obj.client.dig_silver++;
}
}
else if(%col.type $= "einst")
{
%type = "<color:236B8E>einsteinium";
if(!%obj.client.dig_powermode)
{
%obj.client.mineMoney += $Dig_valueMin["einst"];
%obj.client.dig_einst++;
}
}
else if(%col.type $= "lead")
{
%type = "<color:236B8E>lead";
if(!%obj.client.dig_powermode)
{
%obj.client.mineMoney += $Dig_valueMin["lead"];
%obj.client.dig_lead++;
}
}
else if(%col.type $= "lava")
{
%type = "<color:FF0000>lava";
if(!%obj.client.dig_powermode)
%obj.client.dig_lava++;
if(!%obj.client.isAdmin)
%obj.client.player.kill();
messageAll('', "<color:FFFFFF>"@ %obj.client.getPlayerName() @" <color:00FF00>mined a lava pocket!");
}
else if(!%obj.client.dig_powermode)
%obj.client.dig_dirt++;
commandToClient(%obj.client, 'centerPrint', "Mined "@ %type, 5);
%obj.client.sendMiningStatus();
Dig_rebuildDirt(%col.getPosition());
%col.delete();
}
else
commandToClient(%obj.client, 'centerPrint', "Health: <color:FFFFFF>"@ %col.health, 3);
}
}
function serverCmdUpgradePick(%client)
{
if(%client.pickaxeNum > 4)
messageClient(%client, '', "You cannot upgrade your pick above level 5");
else if($Dig_pickCost[%client.pickaxeNum+1] > %client.mineMoney)
messageClient(%client, '', "You do not have enough money. Money needed: $"@ mAbs(%client.mineMoney - $Dig_pickCost[%client.pickaxeNum+1]));
else if($Dig_pickCost[%client.pickaxeNum+1] <= %client.mineMoney)
{
%client.pickaxeNum++;
%client.mineMoney -= $Dig_pickCost[%client.pickaxeNum];
messageClient(%client, '', "You have upgrade your pick to level "@ %client.pickaxeNum @"($"@ $Dig_pickCost[%client.pickaxeNum] @")");
}
%client.sendMiningStatus();
}
function serverCmdBuyLight(%client)
{
if(%client.mineLight)
commandToClient(%client, 'centerPrint', "You already bought a light!", 3);
else if(%client.mineMoney >= 25)
{
%client.mineLight = 1;
commandToClient(%client, 'centerPrint', "You have bought a light for \c3$25", 3);
%client.mineMoney -= 25;
serverCmdLight(%client);
}
else
commandToClient(%client, 'centerPrint', "You cannot afford a light for \c3$25", 3);
%client.sendMiningStatus();
}
function DiggingPickaxeProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
Dig_mineBrick(%obj, %col, %pos);
}
function gunProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);
if(%obj.client.isAdmin)
Dig_mineBrick(%obj, %col, %pos);
}
function akimboGunProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);
if(%obj.client.isAdmin)
Dig_mineBrick(%obj, %col, %pos);
}
$Dig_PickaxeColor = "0.000000 0.000000 0.900000 1.000000";
datablock projectileData(DiggingPickaxeProjectile : hammerProjectile)
{
directDamage = 5;
lifeTime = 100;
explodeOnDeath = false;
};
datablock itemData(DiggingPickaxeItem : hammerItem)
{
uiName = "Pickaxe";
image = DiggingPickaxeImage;
colorShiftColor = $Dig_PickaxeColor;
};
datablock shapeBaseImageData(DiggingPickaxeImage : hammerImage)
{
item = DiggingPickaxeItem;
projectile = DiggingPickaxeProjectile;
colorShiftColor = $Dig_PickaxeColor;
};
function DiggingPickaxeImage::onFire(%this, %obj, %slot)
{
parent::onFire(%this, %obj, %slot);
%obj.playThread(2, "armAttack");
}
function DiggingPickaxeImage::onStopFire(%this, %obj, %slot)
{
%obj.playThread(2, "root");
}
package Dig_package
{
function GameConnection::spawnPlayer(%this)
{
parent::spawnPlayer(%this);
}
function GameConnection::sendMiningStatus(%this)
{
if(!%this.pickaxeNum)
%this.pickaxeNum = 0;
if(!%this.mineMoney)
%this.mineMoney = 0;
%msg = "<font:arial bold:14>\c6Cash: \c3$"@ %this.mineMoney @" \c6Dirt: \c3"@ %this.dig_dirt @" \c6Pickaxe level: \c3"@ %this.pickaxeNum;
if(%client.pickaxeNum < 5)
%msg = %msg @" \c6Next pickaxe: \c3$"@ $Dig_pickCost[%this.pickaxeNum+1];
commandtoClient(%this, 'bottomPrint', %msg, 10);
}
function GameConnection::saveMiningStats(%this)
{
%id = %this.bl_id;
$Dig_stats_isSaved[%id] = 1;
$Dig_stats_pickaxeNum[%id] = %this.pickaxeNum;
$Dig_stats_mineMoney[%id] = %this.mineMoney;
$Dig_stats_dig_dirt[%id] = %this.dig_dirt;
$Dig_stats_dig_einst[%id] = %this.dig_einst;
$Dig_stats_dig_lava[%id] = %this.dig_lava;
$Dig_stats_dig_gold[%id] = %this.dig_gold;
$Dig_stats_dig_silver[%id] = %this.dig_silver;
%Dig_stats_dig_lead[%id] = %this.dig_lead;
}
function GameConnection::loadMiningStats(%this)
{
%id = %this.bl_id;
if($Dig_stats_isSaved[%id])
return 0;
%this.pickaxeNum = $Dig_stats_pickaxeNum[%id];
%this.mineMoney = $Dig_stats_mineMoney[%id];
%this.dig_dirt = $Dig_stats_dig_dirt[%id];
%this.dig_einst = $Dig_stats_dig_einst[%id];
%this.dig_lava = $Dig_stats_dig_lava[%id];
%this.dig_gold = $Dig_stats_dig_gold[%id];
%this.dig_silver = $Dig_stats_dig_silver[%id];
%this.dig_lead = $Dig_stats_dig_lead[%id];
return 1;
}
function GameConnection::autoAdminCheck(%this)
{
%parent = parent::autoAdminCheck(%this);
if(!%this.loadMiningStats())
{
%this.pickaxeNum = 1;
%this.mineMoney = 0;
%this.dig_dirt = 0;
%this.dig_einst = 0;
%this.dig_lava = 0;
%this.dig_gold = 0;
%this.dig_silver = 0;
%this.dig_lead = 0;
}
return %parent;
}
function GameConnection::onClientLeaveGame(%this)
{
%this.saveMiningStats();
parent::onClientLeaveGame(%this);
}
function serverCmdLight(%client)
{
if(%client.mineLight || !$Dig_on)
parent::serverCmdLight(%client);
else
commandToClient(%client, 'centerPrint', "You have not bought a light yet. You can by a light for \c3$25", 3);
}
};
activatePackage(Dig_package);