Author Topic: If statements got me down, bro!  (Read 3941 times)

OhaiReapd

  • Guest
If statements got me down, bro!
« on: May 10, 2011, 12:27:56 pm »
Code: [Select]
alias g0 say_team I am a ^7Granger ^5with^7 \$$p_hp\ ^5Health and ^7 \$$p_credits\ ^5Evos.
alias g1 say_team I am an ^7Advanced Granger ^5with^7 \$$p_hp\ ^5Health and ^7 \$$p_credits\ ^5Evos.
alias g2 say_team I am a ^7Dretch ^5with^7 \$$p_hp\ ^5Health and ^7 \$$p_credits\ ^5Evos.

alias c1 "if class = builderupg g1 c2"
alias c2 "if class = level0 g2 c3"

bind CTRL "if class = builder g0 c1"

alias ass say_team fucknuts
bind ALT "if class = builder ass g2"

This is code that I have written for binds that should exec depending on what class I am. However, its not working. I have spent like 3 hours on this trying to get it to work. Please help.

Thanks,
Reapd

Celestial_Rage

  • Posts: 636
  • Turrets: +120/-8
Re: If statements got me down, bro!
« Reply #1 on: May 10, 2011, 06:19:55 pm »
I don't think the if statement can equate strings. If the strcmp command is built in, you can use that, or replace all the names with numbers.
"The reports of my death are greatly exaggerated" ~Mark Twain

UniqPhoeniX

  • Spam Killer
  • *
  • Posts: 1376
  • Turrets: +66/-32
Re: If statements got me down, bro!
« Reply #2 on: May 10, 2011, 08:01:26 pm »
class is a cmd not a variable... but in case your client is modded and has such a cvar, you'd prob need to use "strcmp \$class\ = builder cmd_if_true cmd_if_false" etc

OhaiReapd

  • Guest
Re: If statements got me down, bro!
« Reply #3 on: May 10, 2011, 08:51:03 pm »
If I type /strcmp in console, it will explain it, but when I bind it, I get a unknown cmd. :/

Here, menace gave me this. Doesn't work tho. Lets work on this.


Code: [Select]
seta hp "p_hp"
seta heal "itemact medkit; say_team ^1***^7[ ^5>>^3Need backup! ^7| ^3I only have ^1>>^7\$$p_hp\^1<<^3 Health!^5<< ^7]^1***"
seta noheal "echo ^5Health is fine. Dumbshit....."
bind e "if hp < 90 heal noheal; deconstruct; +button3;-button3"

I added the say_team. But it execs. However, it only execs heal. So even with 100 health, it will say it and would activate medkit... >:(
« Last Edit: May 10, 2011, 10:03:44 pm by OhaiReapd »

F50

  • Posts: 740
  • Turrets: +16/-26
Re: If statements got me down, bro!
« Reply #4 on: May 11, 2011, 08:02:49 am »
The problem is with

Code: [Select]
seta hp "p_hp"
which only ever gets executed once, so hp will be the same, regardless of what your health is.
"Any sufficiently advanced stupidity is indistinguishable from malice." -- Grey's Law


David

  • Spam Killer
  • *
  • Posts: 3543
  • Turrets: +249/-273
Re: If statements got me down, bro!
« Reply #5 on: May 11, 2011, 11:09:35 am »
hp will be set to the string p_hp, not the value of p_hp.
Turning "p_hp" into a number will always be 0, because it's not a number.
Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.

OhaiReapd

  • Guest
Re: If statements got me down, bro!
« Reply #6 on: May 11, 2011, 12:45:09 pm »
So, how would I fix it? :[ This is so confusing..... Thanks for the help so far!!!

Menace13

  • Posts: 516
  • Turrets: +12/-41
    • hhhhhh
Re: If statements got me down, bro!
« Reply #7 on: May 11, 2011, 11:56:38 pm »

but a small twisty barrel will have small pew pew's, and small pew pew's can hurt mr.tyrant.

OhaiReapd

  • Guest
Re: If statements got me down, bro!
« Reply #8 on: May 12, 2011, 12:23:15 am »
http://www.tremfusion.net/wiki/Features_list#The_.60if.60_command

I believe it's the same in FSM-GPP.

but that's not a tutorial. It barely explains it. >:(