Strange Convar.set_int behavior

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
Global Moderator
Posts: 153
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Strange Convar.set_int behavior

Postby Kami » Mon Jun 04, 2018 6:18 pm

Hey guys,

I'm using this code to initialize server variables from a txt file:

Syntax: Select all

import os
from cvars import ConVar

def get_addon_path():
path = os.path.dirname(os.path.abspath(__file__))
return path

path = get_addon_path()+"/svar/svar.txt"
file = open(path)
lines = [line.rstrip('\n') for line in file]

for line in lines:
if not line.startswith('//'):
if line != "":

The problem is that ConVar(line).set_int(0) will not set the variable to 0 but to an empty string, which then leads to problems when I try to do math on them.
When I use

Syntax: Select all


it works like it's intended but does not seem like the way it should be. I think this might be a bug.

Thank you :)
User avatar
Senior Member
Posts: 527
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany

Re: Strange Convar.set_int behavior

Postby BackRaw » Fri Jul 20, 2018 4:37 am

Maybe try

Syntax: Select all

from cvars import cvar

User avatar
Project Leader
Posts: 2603
Joined: Sat Jul 07, 2012 1:59 am

Re: Strange Convar.set_int behavior

Postby satoon101 » Sat Jul 21, 2018 11:52 pm

I'm not entirely sure what you are attempting to do, but I imagine it has to do with WCS and using ES-style console commands. You might try using set_string('0') to see if that fixes your issue.

Return to “Plugin Development Support”

Who is online

Users browsing this forum: Bing [Bot] and 4 guests