CVARS, am I doing this right?

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Splaetos
Major General
Posts: 730
Joined: Tue Jan 20, 2004 2:55 pm
Contact:

CVARS, am I doing this right?

Post by Splaetos »

trying here to set up the variables that can be controlled before the round, a few different methods of play... and some timing options...

first I set the defaults, then I have the script read the cvars. If the cvar is not set, it should keep the default right? also, im not positive of my syntax... strings go in quotes?

anyway does this look proper?

Code: Select all

config_setup:

     //defaults
     level.mode = "conquest"
     level.flag_capturetime = 50 //tenths
     level.flag_recapturetime = 50 //tenths
     level.conquest_wintime = 30 //seconds
     level.score_noscoretime = 60 //seconds
     level.score_finalstage = 60 //seconds

     //gametypes -- conquest - score - capture
     level.mode = getcvar (capture_mode)

     //flag capture times
     level.flag_capturetime = (int) getcvar (conquest_capturetime)
     level.flag_recapturetime = (int) getcvar (conquest_recapturetime)

     //conquest options
     level.conquest_wintime = (int) getcvar (conquest_wintime)

     //push options
     level.score_noscoretime = (int) getcvar (score_noscoretime)
     level.score_finalstage = (int) getcvar (score_finalstage)
     
end
When I am king, you will be first against the wall~
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

cvar

Post by tltrude »

It is hard to tell what you are trying to do, but to make a new cvar you must first set it with "setcvar".

setcvar "conquest_wintime" "30"

then when you need it:

level.conquest_wintime = int(getcvar(conquest_wintime))

That will make "level.conquest_wintime" equal 30, but you can just do it like this without a cvar.

level.conquest_wintime = 30
Tom Trude,

Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Try this maybe

config_setup:

//defaults
level.mode = "conquest"
level.flag_capturetime = 50 //tenths
level.flag_recapturetime = 50 //tenths
level.conquest_wintime = 30 //seconds
level.score_noscoretime = 60 //seconds
level.score_finalstage = 60 //seconds

//gametypes -- conquest - score - capture
level.mode = getcvar (capture_mode)

//flag capture times

if((getcvar conquest_capturetime) != "")
level.flag_capturetime = int(getcvar conquest_capturetime)

if((getcvar conquest_recapturetime) != "")
level.flag_recapturetime = int(getcvar conquest_recapturetime)

//conquest options

if((getcvar conquest_wintime) != "")
level.conquest_wintime = int(getcvar conquest_wintime)

//push options

if((getcvar score_noscoretime) != "")
level.score_noscoretime = int(getcvar score_noscoretime)

if((getcvar score_finalstage) != "")
level.score_finalstage = int(getcvar score_finalstage)

end
Image
Splaetos
Major General
Posts: 730
Joined: Tue Jan 20, 2004 2:55 pm
Contact:

Post by Splaetos »

thanks...

it needs to be cvars and not jsut set, so that it can be changed later. Technicaly the timing aspects dont NEED to be changed, but as long as I need cvars for the three different gametypes I intend, I might as well make the timing aspects customizable.

I cant set the cvar within the script... cause that would over write any cvar that was set by console when the maps load...
When I am king, you will be first against the wall~
Image
Post Reply