Author Topic: 123 Commands  (Read 2103 times)

Your probably confused by the title but what I'm trying to say is, how do you make it so that when someone says 1 while standing on a brick, it will do something. I already have a trigger so no problem there but how do you do that. I looked at the CityRPG code where its done and I can't figure out why it wont work if you use what they use now. Any help?

What you have to do is set up an event that's triggered when a player enters and leaves the trigger.

Using that to determine when a player is inside the trigger, you need to intercept the chat command and check if they're in the trigger, and then do something based on what they say.

So how would I do that. Does it have to do with inputs?


use triggers. search them on the forums

on the "a brick" specify a trigger

when players enter it, add 1 to a variable called "intrigger"
when they leave, subtract 1

while inside of it, have anything sent from serverCmdMessageSent(%client,%message) be captured (by running commands on it and then returning WITHOUT the parent) and put through a switch statement (look that up too) to parse out specific stuff to do


I also have one more request. How do you display variables in a client sided GUI? I know it has to do with clientCmd and commandToClient, but when I do that it shows up blank even when I do that.

Come on forums. Its been 5 hours!

Come on forums. Its been 5 hours!

You are going to need to post some snippets of code that you have tried that doesn't seem to work if you want specific help.
My guess is that you are misunderstanding the inputs and outputs of the functions you are using, but there is no way to tell since you didn't post anything.

Here is what I tried for the 123

Code: [Select]
function CreeRPGShop::onEnterTrigger(%this,%trigger,%obj,%msg,%user,%datablock, %client, %text, %input)
{

%obj.client.isInCShop = 1;

messageclient(%obj.client,'',"<color:FF0000>Shop<color:FFFFFF>:");
messageclient(%obj.client,'',"<color:FF0000>1<color:FFFFFF>) Print Hi");
messageclient(%obj.client,'',"<color:FF0000>2<color:FFFFFF>) Print Test");

if(%obj.client.isInCShop >= 1)

   switch$(%input)
   {
      case "1":
     echo("Hi"); 
   }
%input = "";
}

}


Alright, I sorta got it to work. If I say 1 it will print hi

Code: [Select]
package CreeRPGShop
{
function serverCmdMessageSent(%client, %msg)
{
     if(%msg $= "1")
{

      messageclient(%client,'',"<color:FF0000>Hi");

     }
     else
     {

      Parent::serverCmdMessageSent(%client, %msg);

     }
}
};
activatePackage(CreeRPGShop);


but if I do this
Code: [Select]
if(%msg $= "1" && %client.isInCShop == 1)

It wont work. Any idea why?


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)
};

This is an example I once wrote for a Jail RP, based heavily on code written by Iban for his city RPG

Code: [Select]

datablock fxDTSBrickData(BlackMarketBrick : brick2x4FData)
{
category = "Special";
subCategory = "JailRP";
uiName = "Black Market Brick";
JailRPBrickAdmin = true;
BlackMarket = true;
triggerDatablock = JailRPInputTriggerData;
triggerSize = "2 4 1";
trigger = 0;
};

datablock triggerData(JailRPInputTriggerData)
{
tickPeriodMS = 500;
parent = 0;
};

datablock PlayerData(PlayerJailRPArmor : PlayerStandardArmor)
{
canJet = false;
uiName = "Sprinter";
sprinter = true;
};

package JailRP
{

function serverCmdmessageSent(%cl, %text)
{
if(isObject(%cl.player) && isObject(%cl.JailRPTrigger) && isObject(%cl.JailRPTrigger.parent) && %cl.JailRPTrigger.parent.getDatablock().BlackMarket)
%cl.JailRPTrigger.parent.getDatablock().parseData(%cl.JailRPTrigger.parent, %cl, "", %text);
else
parent::serverCmdmessageSent(%cl, %text);
}
};





function JailRPInputTriggerData::onEnterTrigger(%this, %trigger, %obj)
{
if(!isObject(%obj.client))
{
return;
}
%obj.client.JailRPTrigger = %trigger;
%trigger.parent.getDatablock().parseData(%trigger.parent, %obj.client, true, "");
}

function JailRPInputTriggerData::onLeaveTrigger(%this, %trigger, %obj, %a)
{
if(!isObject(%obj.client))
{
return;
}

if(%obj.client.JailRPTrigger == %trigger)
{
%trigger.parent.getDatablock().parseData(%trigger.parent, %obj.client, false, "");
%obj.client.JailRPTrigger = "";
}
}

function BlackMarketBrick::parseData(%this, %brick, %cl, %triggerStatus, %text)
{
if(!$JailRP::active)
return;

if(%cl.tdmteam == 1 || !$JailRP::BlackMarket::Open)
return;

if(%triggerStatus !$= "")
{
if(%triggerStatus == true && %cl.BMstage $= "")
{
messageClient(%cl, '', "\c6This is the Black Market.  What do you want?");
messageClient(%cl, '', "\c1You currently have \c2"@%cl.JailRPC@" \c1dollars.");
messageClient(%cl, '', "\c31 \c6- Gamble.");
messageClient(%cl, '', "\c32 \c6- Shop.");
messageClient(%cl, '', "\c33 \c6- Community Fund.");
%cl.BMstage = 0;
}

if(%triggerStatus == false && %cl.BMstage !$= "")
{
messageClient(%cl, '', "\c6See ya 'round, Buddy.");
%cl.BMstage = "";
}
return;
}
%input = strLwr(%text);

if(mFloor(%cl.BMstage) == 0)
{
//etc...
}
}

Error!

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)
{
case ##"##1":
messageClient(%cl, '', "<color:FFFFFF>Test");

case "2":
messageClient(%cl, '', "<color:FFFFFF>Hi");
}

}