Author Topic: 123 Commands  (Read 2290 times)

Alright, fixed it. But it doesnt work.

Code: [Select]
function CreeRPGShopBrickData::parseData(%this, %brick, %cl, %triggerStatus, %text)
{

if(%triggerStatus !$= "")
{
if(%triggerStatus == true && %cl.CRPGShopTrig $= "")
{
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.CRPGShopTrig = 0;
}

if(%triggerStatus == false && %cl.CRPGShopTrig !$= "")
{
messageClient(%cl, '', "<color:FFFFFF>Thanks for coming!");
%cl.CRPGShopTrig = "";
}
return;
}
%input = strLwr(%text);

if(mFloor(%cl.CRPGShopTrig) == 0)
{
          if(strReplace(%input, "1", "") !$= %input || strReplace(%input, "one", "") !$= %input)
  {
 
  messageClient(%cl, '', "<color:FF0000>Test");
 
  }
}

}


A: what did you want to happen
B: what actually happened
C: what did you do to make it happen

A) I wanted it to make it so when I said 1 it would print Test.
B) Nothing happened
C) No Errors happened

Your if statements make no sense.

if(mFloor(%cl.CRPGShopTrig) == 0)

CRPGShopTrig should be a boolean value, why are you flooring it?  Also don't you want it to be true?

Add a ton of echoes to your code to read out the states of all the variables you are using at different times.

I put in some echos to see if it was working and none of the echos showed. Here is my code.

Code: [Select]
function CreeRPGShopBrickData::parseData(%this, %brick, %cl, %triggerStatus, %text)
{

if(%triggerStatus !$= "")
{
  echo("First Works");
if(%triggerStatus == true && %cl.CRPGShop $= "")
{
echo("Second Works");
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 !$= "")
{
echo("Leaveing Works");
messageClient(%cl, '', "<color:FFFFFF>Thanks for coming!");
%cl.CRPGShop = "";
}
return;
}
%input = strLwr(%text);

if(%cl.CRPGShop == true)
{
echo("Text Input Works");
          if(strReplace(%input, "1", "") !$= %input || strReplace(%input, "one", "") !$= %input)
  {
 
  messageClient(%cl, '', "<color:FF0000>Test");
 
  }
}

}

Echoes will appear in the sever console.  Make sure you are checking there.

put an echo here to make sure the function is even being called
function CreeRPGShopBrickData::parseData(%this, %brick, %cl, %triggerStatus, %text)
{
   >>>> echo here
   if(%triggerStatus !$= "")
   {

parseData isnt even being called. No Echo.

parseData isnt even being called. No Echo.

Your code should have the following parts:

Code: [Select]
various trigger and brick datablocks

myTriggerData::onEnterTrigger(%this, %trigger, %obj)

myTriggerData::onLeaveTrigger(%this, %trigger, %obj, %a)

myBrick::parseData(%this, %brick, %cl, %triggerStatus, %text)

package myPackage
{
    function serverCmdmessageSent(%cl, %text)
};
You're not posting (or don't have anything for) all these necessary parts. Functions don't magically know when and how to call themselves



Headcrab, can you help? See what is wrong here. If everything is wrong... I swear to god.

Code: [Select]
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);
}
};


Code: [Select]
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);
}
};

On a very quick read-through I noticed your variables are named inconsistenty.
In onEnterTrigger, you reference 'CreeRPG'
In onLeaveTrigger you reference 'CreeRPGShop"
In parseData you reference 'CRPGShop"

In the createTrigger function you define %trigger.brick, but everywhere else you reference %trigger.parent
« Last Edit: October 24, 2013, 01:48:02 PM by Headcrab Zombie »

Should it be %brick.trigger or %trigger.parent