Author Topic: Need help on IF statements in commands  (Read 984 times)

0 Members and 1 Guest are viewing this topic.

sirenzlow

  • Youngling
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
  • Twitch Name: SirEnzlow
Need help on IF statements in commands
« on: January 20, 2017, 11:47:47 PM »
Heyo,

I am creating a command that will multiply the target by constant and then deduct the result from the users points. I have that portion figured out (took me a minute....). Anyway, I want to have explanation text appear if the user DOES NOT provide a target and just types the command in. I found that I can use an IF statement, but for some reason I am having issues.

I built a test command like this and it returns true if a target of 1 or higher is entered and displays the false text when no targets are entered:

@if@[>=||@target@||1||True target is greater than or equal to 1||False target is less than 1 and probably doesn't exist]

When I try to incorporate the actions that occur when the statement is true or false for the real command, it will only take action when it returns true and will not print out the text if no target is provided... I'm stumped because it should work... Anyway, here is the mega confusing command I am trying to get to work:

@if@[>=||@target@||1||@user@ the Knight has requested @target@ airstabs from SirEnzlow, at the price of @calc@[*|@target@|5] @pointsname@! @editpoints@[@user@|-@calc@[*|@target@|5]]||Airstabs cost 5 Ingots, please specify how many stabs you'd like to request]

Seems like something is breaking the IF statement if it returns as false... Does anyone know how to fix this?

TheNumbLock

  • Advisor
  • Councilor
  • **
  • Posts: 4776
  • Karma: +137/-5
    • View Profile
  • Twitch Name: TheNumbLock
Re: Need help on IF statements in commands
« Reply #1 on: January 21, 2017, 01:16:00 AM »
Easiest way:

@if@[@target@||||You need to include something after the command.||Run Next command or whatever.]
Old Name: RepentGamingTV
Twitch: Here

Need help ASAP?
Join Deepbot's Discord: Discord.Deepbot.tv
Deepbot's Twitter: @DeepSupport

sirenzlow

  • Youngling
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
  • Twitch Name: SirEnzlow
Re: Need help on IF statements in commands
« Reply #2 on: January 21, 2017, 08:02:54 AM »
Thanks for the reply.... I tried the if statement you provided to no avail... When I use the if statement you provided, it only returns the false text.... I tried switching the true and false around but nothing worked. Here are the two I tried:

@if@[@target@||||@user@ the Knight has requested @target@ airstabs from SirEnzlow, at the price of @calc@[*|@target@|5] @pointsname@! @editpoints@[@user@|-@calc@[*|@target@|5]]||Airstabs cost 5 Ingots each, please specify how many airstabs you want to request.]

@if@[@target@||||Airstabs cost 5 Ingots each, please specify how many airstabs you want to request.||@user@ the Knight has requested @target@ airstabs from SirEnzlow, at the price of @calc@[*|@target@|5] @pointsname@! @editpoints@[@user@|-@calc@[*|@target@|5]]]

Stumped....

TheNumbLock

  • Advisor
  • Councilor
  • **
  • Posts: 4776
  • Karma: +137/-5
    • View Profile
  • Twitch Name: TheNumbLock
Re: Need help on IF statements in commands
« Reply #3 on: January 21, 2017, 10:20:17 AM »
The Second one should work. :o

Try this:

@if@[@target@||||Airstabs cost 5 Ingots each, please specify how many airstabs you want to request.||@user@ the Knight has requested @target@ airstabs from SirEnzlow, at the price of @calc@[*|5|@target@] @pointsname@! @editpoints@[@user@|-@calc@[*|5|@target@]]]


All I did was move @target@ at the end of the @calc@ and it worked.
Old Name: RepentGamingTV
Twitch: Here

Need help ASAP?
Join Deepbot's Discord: Discord.Deepbot.tv
Deepbot's Twitter: @DeepSupport