Results 1 to 7 of 7

Thread: what is cvar?

  1. #1
    ... connecting
    Join Date
    Nov 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    what is cvar?

    Ok dumb question

    what is cvar and how do i use it?

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Hey, a cvar is something like a persistent variable (till server restart). It can only contain strings, integers (int) or floating point numbers (float).

    In server-console you can do:
    set somevalue HELLO
    somevalue -> will print HELLO

    Then there are some codscript-functions to access those variables:

    Code:
    gethello = getcvar("somevalue"); // the variable gethello contains HELLO now
    Code:
    setcvar("somevalue", "BYE"); // the variable gethello is set to BYE now
    What returns this function-call now? getcvar("somevalue"); *question for you*


    Like the server got cvar's, a client got them also. You can set client-cvars like this:

    Code:
    player setclientcvar("com_maxfps", "125"); // everybody can strafe now :D
    timescale 0.01

  3. #3
    ... connecting
    Join Date
    Nov 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok and if i wanted to for example

    change the gravity to 50 after i use a trigger_use?

  4. #4
    ... connecting
    Join Date
    Nov 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    nvm Fixed thanks ^_^

  5. #5
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,011
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    Please post solution
    timescale 0.01

  6. #6
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by kung foo man View Post
    Please post solution
    sure...
    Code:
    lowgravtrig()
    {
    	trig = getent("lowgravtrigger", "targetname");
    	while(true)
    	{
    		trig waittill("trigger", user);
    		if(!isplayer(user))
    			continue;
    		oldgrav = getcvarint("g_gravity");
    		setcvar("g_gravity", 50);
    		wait 60;
    		setcvar("g_gravity", oldgrav);'
    	}
    }
    or anything similar...

  7. The Following User Says Thank You to IzNoGoD For This Useful Post:

    kung foo man (30th November 2012)

  8. #7
    ... connecting
    Join Date
    Nov 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i just did

    Code:
    thread gravity();    
    }
    
    gravity()
    {
    button2 = getent("button2", "targetname");
    
    while(1)
    {
    button2 waittill("trigger", player);
    setCvar("g_gravity", "50");
    iprintlnbold((player.name) + "\n IT WORKED!");
    wait 5.0;
    }
    }
    xD

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •