Assign the value of a variable to another variable

Discussion for ET Players

Moderators: Forum moderators, developers

Post Reply
Mano de Dios
Posts: 16
Joined: Sat Apr 24, 2004 7:06 am

Assign the value of a variable to another variable

Post by Mano de Dios »

In my autoexec.cfg, I have set up an "announce" button. I set it every time I have something to announce (e.g., class selection, ffe).

I want to set up a "one-time only" announcement, and then revert back to my old announcement. Anyone know how to set up a variable to be the value of another variable?

something like this:

Code: Select all

set announce_this "vsay IamMedic; say_team I am going to revive you."
bind , "vstr announce_this"
bind 4 "cg_drawgun 1; weaponbank 4; cg_drawgun 0; set last_announcement announce_this; vstr set_last"
set set_last "set announce_this 'vsay_team Move ^4Here goes a ^7Gre^hnade!!!'; bind MOUSE1 +attack; -attack; vstr reset_last"
set reset_last "set announce_this last_announcement"
The variable "announce_this" is dynamic and gets reset. When I switch to a grenade, I want to it to announce my grenade when I fire and then revert back to announcing I'm a medic.

I have a couple workarounds (e.g., other grenade scripts and rebindings) but I wanted to know if it was possible to assign a variable to the value of another variable.

I don't want to do a vstr in this instance because the variable is dynamic and changes.

Anyone know how to do this?

Thanks.
User avatar
Lagger
Posts: 316
Joined: Mon Sep 29, 2003 8:30 am

Post by Lagger »

well you can't copy the value of one cvar to another, yet.

the workaround isn't very pretty, but in your case i would do something like this:

Code: Select all

// announce current and revert to last one
bind , "vstr ann_this;vstr ann_getprev" 

// setting a announcement that will be reverted to
set ann_getprev "set ann_this "vsay_team iammedic my needle comes for joo, don't tap out""; vstr ann_getprev

// setting a one-shot announcement
set ann_this "say i am a one time announcement \o/"

// a temporary bind fer the nade toss
bind 4 "weaponbank 4; set ann_this "say_team "here i come to toss a nade!""

// resetting the announce by releasing mouse1
bind mouse1 "+vstr att_in att_out"
set att_in "+attack"
set att_out "-attack; vstr ann_getprev"
Mano de Dios
Posts: 16
Joined: Sat Apr 24, 2004 7:06 am

Post by Mano de Dios »

Thanks, Lagger.

Unfortunately, that's what I figured (not being able to assign the value of one cvar to another).

Your workaround is more robust than mine.

I "rebound" my announce key [,] instead of trying to change what the dynamic variable says. The problem is that if I don't throw the grenade, and then do another action that would change the announcement (e.g., switching classes), the announcement doesn't get reset.

Because of those little annoyances, I might think about going with your workaround. But my cfg is already too big imo.

Thanks again.
Post Reply