datablock fxDTSBrickData(CreeRPGShopBrickData : brick2x4FData)
{
category = "CRPG";
subCategory = "Bricks";
uiName = "Shop Brick";
};
datablock TriggerData(CreeRPGShop)
{
tickPeriodMS = 100;
};
function fxDtsBrick::createCreeRPGShopTrigger(%this,%data)
{
%t = new Trigger()
{
datablock = %data;
polyhedron = "0 0 0 1 0 0 0 -1 0 0 0 1"; //this determines the shape of the trigger
};
missionCleanup.add(%t);
%boxMax = getWords(%this.getWorldBox(), 3, 5);
%boxMin = getWords(%this.getWorldBox(), 0, 2);
%boxDiff = vectorSub(%boxMax,%boxMin);
%boxDiff = vectorAdd(%boxDiff,"0 0 0.2");
%t.setScale(%boxDiff);
%posA = %this.getWorldBoxCenter();
%posB = %t.getWorldBoxCenter();
%posDiff = vectorSub(%posA, %posB);
%posDiff = vectorAdd(%posDiff, "0 0 0.1");
%t.setTransform(%posDiff);
%this.trigger = %t;
%t.brick = %this;
return %t;
}
function CreeRPGShopBrickData::onAdd(%this,%brick)
{
%brick.scheduleNoQuota(0,"createCreeRPGShopTrigger","CreeRPGShop");
}
function CreeRPGShopBrickData::onRemove(%this,%brick)
{
if(isObject(%brick.trigger))
%brick.trigger.delete();
}
function CreeRPGShop::onEnterTrigger(%this, %trigger, %obj)
{
if(!isObject(%obj.client))
{
return;
}
%obj.client.CreeRPG = %trigger;
%trigger.parent.getDatablock().parseData(%trigger.parent, %obj.client, true, "");
}
function CreeRPGShop::onLeaveTrigger(%this, %trigger, %obj, %client)
{
if(!isObject(%obj.client))
{
return;
}
if(%obj.client.CreeRPGShop == %trigger)
{
%trigger.parent.getDatablock().parseData(%trigger.parent, %obj.client, false, "");
%obj.client.CreeRPGShop = "";
}
}
function CreeRPGShopBrickData::parseData(%this, %brick, %cl, %triggerStatus, %text)
{
if(%triggerStatus !$= "")
{
if(%triggerStatus == true)
{
messageClient(%cl, '', "<color:FF0000>Shop<color:FFFFFF>:");
messageClient(%cl, '', "<color:FF0000>1<color:FFFFFF>) Print Test");
messageClient(%cl, '', "<color:FF0000>2<color:FFFFFF>) Print Hi");
%cl.CRPGShop = 0;
}
if(%triggerStatus == false && %cl.CRPGShop !$= "")
{
messageClient(%cl, '', "<color:FFFFFF>Thanks for coming!");
%cl.CRPGShop = "";
}
return;
}
%input = strLwr(%text);
if(mFloor(%cl.CRPGShop) == 0)
{
if(strReplace(%input, "1", "") !$= %input || strReplace(%input, "one", "") !$= %input)
{
messageClient(%cl, '', "<color:FF0000>Test");
}
}
}
package CreeRPGShop
{
function serverCmdmessageSent(%cl, %text)
{
if(isObject(%cl.player) && isObject(%cl.CRPGShop) && isObject(%cl.CreeRPGShop.parent))
%cl.JailRPTrigger.parent.getDatablock().parseData(%cl.CreeRPGShop.parent, %cl, "", %text);
else
parent::serverCmdmessageSent(%cl, %text);
}
};