What's new

Discussion Toggle Dvars!

  • Thread starter teh1337
  • Start date
  • Views 2,147
teh1337

teh1337

Some call me the Dear Leader-most just say teh1337
Experienced Veteran Programmer Frame In Gold
Messages
1,555
Reaction score
2,224
Points
375
Sin$
0
Ok so yesterday I had the idea to shorten dvar toggling to a simple thread, and I did it!


So now when you want to toggle a dvar with a menu, all you have to do is:

Add This to the bottom of your patch:
Code:
doTdvar( dvar, values, nmes, msg ) {
value = strTok(values, "|");
msgs = strTok(msg, "|");
for(;;) {
for(x=0; x<=value.size; x++) {
self waittill( "tdv_"+dvar );
self setClientdvar( dvar, value[x] );
self iPrintln(nmes+" set to ^1"+msgs[x]);
}
}
}

Add this to onplayerspawned (example dvar):

Code:
self thread doTdvar( "r_fullbright", "1|0", "Cartoon", "On|Off" );// <dvar>, <values (separated by | )> <dvar title>, <messages (separated by | )>

And then where ever you want to toggle the dvar put:
Code:
self notify("tdv_r_fullbright");//self notify("tdv_<dvar name>");

And whala! You can now toggle dvars quickly and painlessly
 
Antics

Antics

Test My Gangster
Messages
804
Reaction score
619
Points
185
Sin$
0
Pretty good.. although it took me quite awhile to understand what you meant by this(I had to reread 3 times..). :lol:
 
teh1337

teh1337

Some call me the Dear Leader-most just say teh1337
Experienced Veteran Programmer Frame In Gold
Messages
1,555
Reaction score
2,224
Points
375
Sin$
0
Pretty good.. although it took me quite awhile to understand what you meant by this(I had to reread 3 times..). :lol:
Sleep Deprivation make me no articulate.
 
CraigChrist8239

CraigChrist8239

VIP
VIP
Hardened Veteran Experienced Veteran Grizzled Veteran
Messages
2,641
Reaction score
3,924
Points
660
Sin$
-7
Code:
self setClientdvar( "r_fullbright", !getDvar( "r_fullbright" ) );

If you're just toggling r_fullbright, then this is much easier. I understand how yours can be used with string based dvars and such, but for just a bool, that'll do...
 
teh1337

teh1337

Some call me the Dear Leader-most just say teh1337
Experienced Veteran Programmer Frame In Gold
Messages
1,555
Reaction score
2,224
Points
375
Sin$
0
Code:
self setClientdvar( "r_fullbright", !getDvar( "r_fullbright" ) );

If you're just toggling r_fullbright, then this is much easier. I understand how yours can be used with string based dvars and such, but for just a bool, that'll do...
True, but I would say about 50% of dvars are booleans, 40% are integer datatype and 10% are strings.

So, its useful when dealing with the dvars in those terms.
 
WaTcH HoW i MoD

WaTcH HoW i MoD

Enthusiast
Messages
1,459
Reaction score
379
Points
165
Sin$
0
True, but I would say about 50% of dvars are booleans, 40% are integer datatype and 10% are strings.

So, its useful when dealing with the dvars in those terms.


i did what u said what is wrong http://pastebin.com/KQGTLd8D in this i just did it to test
 
Top Bottom
Login
Register