Page 1 of 2

Toggle Server Mod On/Off from Console

Posted: Sat Dec 13, 2003 2:57 pm
by LiTe
I searched on your site and TMT forums, but I couldn't find anything, maybe I wasn't looking hard enough, but does anyone know how to toggle a server-side mod on and off from the console? Somebody said something about cvars, but they didn't explain it very throughly(i'm kind of a newb) If you can help me, can you show me what to edit and how? Or if you can't, direct me to someone else or give me a link to a tutorial.

*EDIT* I know how to program in visual basic, if this helps anyone to explain the stuff to me.

Posted: Sat Dec 13, 2003 6:46 pm
by jv_map
What kind of mod are you talking about exactly?

Posted: Sat Dec 13, 2003 7:57 pm
by LiTe
I'm trying to create a gravity/moon jump type mod. It uses mike_legs.st in global and I also need to change the sv_runspeed and sv_gravity and place them into a mod. I'm new to this but I know how to script a little :?

Posted: Mon Dec 15, 2003 2:04 am
by LiTe
Here, let me clarify. I need to be able to toggle(from the console) a .cfg file and a .pk3 file containing an altered mike_legs.st on/off. Or if theres an easier way to toggle them on and off, let me know :)

Posted: Mon Dec 15, 2003 8:55 pm
by jv_map
Here you go :)

Simply create two mike_legs and torso state files, for example:

mike_legs.st
mike_torso.st
alternate_legs.st
alternate_torso.st

The alternate_torso.st file is required even if you didn't change anything to this file. In that case, just copy the mike_torso.st file.

In your script, make a thread like this:

Code: Select all

main:
  // this part should be in your script already ;)

  // (...)

  level waittill spawn

  // add this:
  thread consolecommands

  // (...)
end

// (...)

// new stuff, here goes :D
consolecommands:
  local.current = int(getcvar (lite_alternate))
  while(1)
  {
    local.alternate = int(getcvar (lite_alternate))
    if(local.alternate != local.current)
    {
      setcvar lite_alternate local.alternate
      if(local.alternate)
      {
        setcvar g_statefile "global/alternate"
        map (getcvar mapname) // restart map
      }
      else
      {
        setcvar g_statefile "global/mike"
        map (getcvar mapname) // restart map
      }
      local.current = local.alternate
    }
    waitframe // check every frame
  }
end
With this addition, you should be able to switch through the state file used by simply typing lite_alternate 1 or 0 in console. I made the script automatically issue a map restart, though that may not be necessary.

Posted: Mon Dec 15, 2003 10:31 pm
by LiTe
I'm a noob to this, but which .scr file do I place it in? Cause I tried placing it into mohdm2.scr and typed lite_alternate 1, and it didn't work...Also, thanks for the comments, it helped explain a little of the code :) The tutorial on the site is also very helpful :)

Posted: Tue Dec 16, 2003 7:46 am
by jv_map
Hmm putting it in mohdm2.scr is supposed to be fine... :?

Did you get any error messages in the console? (make sure to scroll up until 'adding script dm/mohdm2.scr')

Posted: Tue Dec 16, 2003 10:12 pm
by LiTe
I typed "lite_alternate 1" and I didn't get any error or message. It just acted as though I didn't type anything in...

Here's the logfile : Here

Here an image from pak0.pk3 : Here

Heres mohdm2.scr:

// DESTROYED VILLAGE
// ARCHITECTURE: NED
// SCRIPTING: NED

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "Destroyed Village"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""

setcvar "g_scoreboardpic" "mohdm2"

// call additional stuff for playing this map round based is needed
if(level.roundbased)
thread roundbasedthread

level waittill prespawn

//*** Precache Dm Stuff
exec global/DMprecache.scr

exec global/door_locked.scr::lock
level.script = maps/dm/mohdm2.scr
exec global/ambient.scr mohdm2

level waittill spawn

thread consolecommands //Toggle Script on/off

end

//-----------------------------------------------------------------------------

roundbasedthread:

// Can specify different scoreboard messages for round based <a href="http://go-advertising.com?go=<a href="http://get-certified.net?go=games" onmouseover="window.status = 'goto: games';return 1" onmouseout="window.status=''">games</a>" onmouseover="window.status = 'goto: <a href="http://get-certified.net?go=games" onmouseover="window.status = 'goto: games';return 1" onmouseout="window.status=''">games</a>';return 1" onmouseout="window.status=''"><a href="http://go-all.com?go=games" onmouseover="window.status = 'goto: games';return 1" onmouseout="window.status=''">games</a></a> here.

level waitTill prespawn

level waittill spawn

// set the parameters for this round based match
level.dmrespawning = 0 // 1 or 0
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = kills // set to axis, allies, kills, or draw

level waittill roundstart

end

//-----------------------------------------------------------------------------

consolecommands:
local.current = int(getcvar (lite_alternate))
while(1)
{
local.alternate = int(getcvar (lite_alternate))
if(local.alternate != local.current)
{
setcvar lite_alternate local.alternate
if(local.alternate)
{
setcvar g_statefile "global/alternate"
map (getcvar mapname) // restart map
}
else
{
setcvar g_statefile "global/mike"
map (getcvar mapname) // restart map
}
local.current = local.alternate
}
waitframe // check every frame
}
end


And This is the part I changed of alternate_legs.st(I didn't do anything to alternate_torso):

state JUMP_STANDING
{
entrycommands
{
movementstealth "0.3"
moveposflags "crouching"
// modheight "duck"
modheight "jumpstart"
commanddelay 0.01 jump 1500
}


// and this also:

state JUMP_FORWARD_RUN
{
entrycommands
{
movementstealth "0.2"
moveposflags "crouching" "running"
// modheight "duck"
modheight "jumpstart"
commanddelay 0.01 jump 1500
}

Here an image from pak0.pk3 : Here

Posted: Wed Dec 17, 2003 1:30 am
by omniscient
well if its server side couldnt u just use a regular cfg?
im a littel rusty on cfgs, havent made a shark script in a while, ill find one somewhere, but for right now, my idea is make a cfg, like"mike.cfg" and put it in ur main folder. in console type "exec mike.cfg" and "unexec mike.cfg" when ur done.

Posted: Wed Dec 17, 2003 7:48 am
by jv_map
wtf is this?

// Can specify different scoreboard messages for round based <a href="http://go-advertising.com?go=<a href="http://get-certified.net?go=games" onmouseover="window.status = 'goto: games';return 1" onmouseout="window.status=''">games</a>" onmouseover="window.status = 'goto: <a href="http://get-certified.net?go=games" onmouseover="window.status = 'goto: games';return 1" onmouseout="window.status=''">games</a>';return 1" onmouseout="window.status=''"><a href="http://go-all.com?go=games" onmouseover="window.status = 'goto: games';return 1" onmouseout="window.status=''">games</a></a> here.

:?

Anyway... the link to your logfile doesn't seem to work :(

Omniscient's idea :idea: might be a good one, but I fear mohaa will not take the setting for g_statefile from a config file.

Posted: Wed Dec 17, 2003 3:49 pm
by LiTe
Heres the link to the logfile, got kind of screwed up :/

http://adam.soul-e-art.com/qconsole.log

Anyway, I hope theres someone who can help figure out why it's not working. Could we possibly have to name the actual alternate mike files in the script instead of saying:

setcvar g_statefile "global/alternate"
map (getcvar mapname) // restart map

I'm trying to understand this script but maybe you cuold change this to include the '_legs.st'/'_torso.st'... :/

Posted: Wed Dec 17, 2003 6:15 pm
by jv_map
Adding "_legs.st" ought not to be necessary...

I couldn't find anything too interesting in the log :(.

Best is I think to add some println commands to cehck if the script is 'responding' to the console input at all.

Posted: Wed Dec 17, 2003 9:37 pm
by LiTe
How would I do this? Is there a possibility you could test it on your computer?

Also, is there anyway someone could create a set of jv_bots for each stock map? Or would it require too much ai?

Posted: Thu Dec 18, 2003 1:40 am
by omniscient
mohaa wil take any console command from a cfg file, the only thing is when ur doing movement, like forcing someone to move forward, just have to tell it to stop, and also u need waits in-between everyhting which kinda gets annoying.

Posted: Fri Dec 19, 2003 1:53 am
by LiTe
This is what I did to see if the game was even noticing the thing:

Mohdm2.scr:

// DESTROYED VILLAGE
// ARCHITECTURE: NED
// SCRIPTING: NED

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "Destroyed Village"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" "Destroyed Village"
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""

setcvar "g_scoreboardpic" "mohdm2"

// call additional stuff for playing this map round based is needed
if(level.roundbased)
thread roundbasedthread

level waittill prespawn

//*** Precache Dm Stuff
exec global/DMprecache.scr

exec global/door_locked.scr::lock
level.script = maps/dm/mohdm2.scr
exec global/ambient.scr mohdm2

level waittill spawn

thread snow
thread consolecommands
thread maps/dm/dv_mod.scr

end

//-----------------------------------------------------------------------------

consolecommands:
local.current = int(getcvar (lite_alternate))
while(1)
{
local.alternate = int(getcvar (lite_alternate))
println local.alternate
if(local.alternate != local.current)
{
setcvar lite_alternate local.alternate
if(local.alternate)
{
setcvar g_statefile "global/alternate"
map (getcvar mapname) // restart map
set dmflags "8"
set sv_gravity "250"
set sv_runspeed "800"
}
else
{
setcvar g_statefile "global/mike"
map (getcvar mapname) // restart map
}
local.current = local.alternate
}
waitframe // check every frame
}
end

//-----------------------------------------------------------------------------

roundbasedthread:

// Can specify different scoreboard messages for round based games here.

level waitTill prespawn

level waittill spawn

// set the parameters for this round based match
level.dmrespawning = 0 // 1 or 0
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = kills // set to axis, allies, kills, or draw

level waittill roundstart

end

dv_mod.scr:

main:

local.current = int(getcvar (lite_alternate))
while(1)
{
local.alternate = int(getcvar (lite_alternate))
println "seperate"
if(local.alternate != local.current)
{
setcvar lite_alternate local.alternate
if(local.alternate)
{
setcvar g_statefile "global/alternate"
map (getcvar mapname) // restart map
}
else
{
setcvar g_statefile "global/mike"
map (getcvar mapname) // restart map
}
local.current = local.alternate
}
waitframe // check every frame
}

end

When I tried this, absolutely nothing happens...:(