News:

Come Chat with us live! Learn how HERE!

Main Menu

If statements got me down, bro!

Started by OhaiReapd, May 10, 2011, 12:27:56 PM

OhaiReapd

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

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

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

#3
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.


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... >:(

F50

The problem is with

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

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

So, how would I fix it? :[ This is so confusing..... Thanks for the help so far!!!

Menace13


Quote from: amz181 on September 08, 2011, 12:32:07 PM
but a small twisty barrel will have small pew pew's, and small pew pew's can hurt mr.tyrant.