Tremulous Forum
General => Troubleshooting => Topic started by: OhaiReapd on May 10, 2011, 12:27:56 pm
-
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
-
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.
-
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
-
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... >:(
-
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.
-
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.
-
So, how would I fix it? :[ This is so confusing..... Thanks for the help so far!!!
-
http://www.tremfusion.net/wiki/Features_list#The_.60if.60_command
I believe it's the same in FSM-GPP.
-
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. >:(