Results 1 to 4 of 4

Thread: How to create a custom cvar?

  1. #1

    Lightbulb How to create a custom cvar?

    How to create a custom cvar, example:

    swhud 0
    swhud 1

    to do, something like this:
    Code:
    if swhud == 0 {
      showhuds
    } else {
      hidehuds
    }

  2. #2
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,603

    Default


    getcvar "swhud"
    setcvar "swhud"

    but I recommend using level scope variables instead,

    level.swhud

  3. #3

    Default

    If you use setcvar you can set any cvar you whant.

    If you check the cvar on the script it will act as the cvar is already created:

    Code:
    local.cvar = getcvar "swhud"
    
    
    if(local.cvar == "1")
    {
    //swhud 1
    //code
    }
    else
    {
    //swhud 0
    //code
    }
    Last edited by DoubleKill; May 29th, 2018 at 06:01 AM.

  4. #4

    Default

    Very well, thank you, for the help.
    I was able to do the following script with cvar,

    It consists of displaying message by console
    in case of changing the value of cvar "msg" to "1"

    Code:
    main:
     level waittill playerspawn
     thread mensaje
    end
    
    mensaje:
    	
    	while(1)
    	{   
    		level.msg = getcvar(msg)
    		if (level.msg == "1"){
    		  stuffsrv "say msg = 1"
    		  setcvar "msg" "0"
    		}
    		waitframe
    	}
    	
    end

Tags for this Thread

Posting Permissions

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