Author Topic: Solve this!  (Read 1195 times)

My part one objective is to add a segment to the hud (picture down below.) I would like to add a feature that shows you your specific amount of drugs that you have marijuana, opium ect... I am a very very new at torquescript and I would like some help. Here is the command to show you how many drugs you have and which specific ones you have.

function servercmdmydrugs(%client)
{
   messageClient(%client,'',"\c6Your marijuana in grams :" @ CityRPGXData.getData(%client.bl_id).valueMarijuana);
   messageClient(%client,'',"\c6Your opium in grams: " @ CityRPGXData.getData(%client.bl_id).valueopium);
   messageClient(%client,'',"\c6Your total drugs in grams: " @ CityRPGXData.getData(%client.bl_id).valuetotaldrugs);
}

to execute that you have to type /mydrugs this does work. This post should contain 2 images and in those images I would like for you to focus on the lumber in the hud. You see in one image it doesn't show that I have any lumber but in the next photo it shows that I have 1 lumber and only displays that when I actually have it. I would love to use this with the drugs. I have the code here of the lumber and ore code.

   // Resources
   if(getWord(CityRPGXData.getData(%client.bl_id).valueJailData, 1) || %client.getJobSO().laborer || getWord(CityRPGXData.getData(%client.bl_id).valueResources, 0) > 0 || getWord(CityRPGXData.getData(%client.bl_id).valueResources, 1) > 0)
   {
      if(getWord(CityRPGXData.getData(%client.bl_id).valueResources, 0) > 0)
         %client.CityRPGXPrint = %client.CityRPGXPrint SPC "\c6Lumber: \c3" @ (strlen(getWord(CityRPGXData.getData(%client.bl_id).valueResources, 0)) > 0 ? getWord(CityRPGXData.getData(%client.bl_id).valueResources, 0) : 0);
      
      if(getWord(CityRPGXData.getData(%client.bl_id).valueResources, 1) > 0)
         %client.CityRPGXPrint = %client.CityRPGXPrint SPC "\c6Ore: \c3" @ (strlen(getWord(CityRPGXData.getData(%client.bl_id).valueResources, 1)) > 0 ? getWord(CityRPGXData.getData(%client.bl_id).valueResources, 1) : 0);
   }

This is the code that I would like to manipulate into the drugs. I need your help to do that and any help would be appreciated! Thank you!

No lumber

Lumber

If your server command does not work then the .Value(drugs) is non-existent.
If it is existent than this should work for the HUD

Code: [Select]
if(getWord(CityRPGXData.getData(%client.bl_id).valueJailData, 1) || %client.getJobSO().laborer || getWord(CityRPGXData.getData(%client.bl_id).valueResources, 0) > 0 || getWord(CityRPGXData.getData(%client.bl_id).valueResources, 1) > 0)
{
if(getWord(CityRPGXData.getData(%client.bl_id).valueResources, 0) > 0)
%client.CityRPGXPrint = %client.CityRPGXPrint SPC "\c6Lumber: \c3" @ (strlen(getWord(CityRPGXData.getData(%client.bl_id).valueResources, 0)) > 0 ? getWord(CityRPGXData.getData(%client.bl_id).valueResources, 0) : 0);

if(getWord(CityRPGXData.getData(%client.bl_id).valueResources, 1) > 0)
%client.CityRPGXPrint = %client.CityRPGXPrint SPC "\c6Ore: \c3" @ (strlen(getWord(CityRPGXData.getData(%client.bl_id).valueResources, 1)) > 0 ? getWord(CityRPGXData.getData(%client.bl_id).valueResources, 1) : 0);

if(CityRPGXData.getData(%client.bl_id).valueMarijuana > 0)
%client.CityRPGXPrint = %client.CityRPGXPrint SPC "\c6Ore: \c3" @ (strlen(CityRPGXData.getData(%client.bl_id).valueMarijuana) > 0 ? CityRPGXData.getData(%client.bl_id).valueMarijuana : 0);

if(CityRPGXData.getData(%client.bl_id).valueOpium > 0)
%client.CityRPGXPrint = %client.CityRPGXPrint SPC "\c6Ore: \c3" @ (strlen(CityRPGXData.getData(%client.bl_id).valueOpium) > 0 ? CityRPGXData.getData(%client.bl_id).valueOpium : 0);

if(CityRPGXData.getData(%client.bl_id).valueTotalDrugs > 0)
%client.CityRPGXPrint = %client.CityRPGXPrint SPC "\c6Ore: \c3" @ (strlen(CityRPGXData.getData(%client.bl_id).valueTotalDrugs) > 0 ? CityRPGXData.getData(%client.bl_id).valueTotalDrugs : 0);
}

If your server command does not work then the .Value(drugs) is non-existent.
If it is existent than this should work for the HUD

Code: [Select]
if(getWord(CityRPGXData.getData(%client.bl_id).valueJailData, 1) || %client.getJobSO().laborer || getWord(CityRPGXData.getData(%client.bl_id).valueResources, 0) > 0 || getWord(CityRPGXData.getData(%client.bl_id).valueResources, 1) > 0)
{
if(getWord(CityRPGXData.getData(%client.bl_id).valueResources, 0) > 0)
%client.CityRPGXPrint = %client.CityRPGXPrint SPC "\c6Lumber: \c3" @ (strlen(getWord(CityRPGXData.getData(%client.bl_id).valueResources, 0)) > 0 ? getWord(CityRPGXData.getData(%client.bl_id).valueResources, 0) : 0);

if(getWord(CityRPGXData.getData(%client.bl_id).valueResources, 1) > 0)
%client.CityRPGXPrint = %client.CityRPGXPrint SPC "\c6Ore: \c3" @ (strlen(getWord(CityRPGXData.getData(%client.bl_id).valueResources, 1)) > 0 ? getWord(CityRPGXData.getData(%client.bl_id).valueResources, 1) : 0);

if(CityRPGXData.getData(%client.bl_id).valueMarijuana > 0)
%client.CityRPGXPrint = %client.CityRPGXPrint SPC "\c6Ore: \c3" @ (strlen(CityRPGXData.getData(%client.bl_id).valueMarijuana) > 0 ? CityRPGXData.getData(%client.bl_id).valueMarijuana : 0);

if(CityRPGXData.getData(%client.bl_id).valueOpium > 0)
%client.CityRPGXPrint = %client.CityRPGXPrint SPC "\c6Ore: \c3" @ (strlen(CityRPGXData.getData(%client.bl_id).valueOpium) > 0 ? CityRPGXData.getData(%client.bl_id).valueOpium : 0);

if(CityRPGXData.getData(%client.bl_id).valueTotalDrugs > 0)
%client.CityRPGXPrint = %client.CityRPGXPrint SPC "\c6Ore: \c3" @ (strlen(CityRPGXData.getData(%client.bl_id).valueTotalDrugs) > 0 ? CityRPGXData.getData(%client.bl_id).valueTotalDrugs : 0);
}

Made a few adjustments and wham! Thank you so much! Do you mind helping me with one more thing?

Do you mind helping me with one more thing?

Ask away, I coded one of these city RPG's a long while ago.