PDA

View Full Version : executing a script..


Mr_nStuff
12-23-2002, 06:00 AM
I'm trying to get a script to properly execute.. The exec doesn't seem to be working.. Here is what i'm trying without success. Basically I want to allow voting on Lean and Axis shotgun. But the only way to do that is have a script to determin the currently selected dmflags.

callvote.cfg
[code:1]"Lean + Strafe" "exec" list
{
"Allowed" "leanOn.scr"
"Disallowed" "leanOff.scr"
}[/code:1]
leanOn.scr
[code:1]main:

if( int( getcvar( dmflags ) ) == 0 )
setcvar "dmflags" "262144"

if( int( getcvar( dmflags ) ) == 1048576 )
setcvar "dmflags" "1310720"

end[/code:1]
leanOff.scr
[code:1]main:

if( int( getcvar( dmflags ) ) == 262144 )
setcvar "dmflags" "0"

if( int( getcvar( dmflags ) ) == 1310720 )
setcvar "dmflags" "1048576"

end[/code:1]

Well here's what pops up on the console when one of these votes passes:

'setcvar' not available from the console
'setcvar' not available from the console
'end' not available from the console
'setcvar' not available from the console
'setcvar' not available from the console
'end' not available from the console

So i'm pretty sure it's not executing as a script.. Instead it's tring to carry out the contents of the SCR file the same way it processes a CFG file.. But weirder yet.. Why does it say end not available twice and setcvar not available four times? That's odd since each SCR file only has 1 end and 2 setcvar commands. Dunno though..

Anyone know how to get a script file SCR (or SHADER?) to properly execute from the console?

Hammer
12-23-2002, 09:08 AM
Sorry man, it will only let you exec another .cfg (i.e., console commands) from callvote.

You might try something like this:

server.cfg[code:1]alias _dmflags_lean_strafe "add dmflags 262144"
alias _dmflags_axis_shotty "add dmflags 1048576"
alias _dmflags "set dmflags 0; _dmflags_lean_strafe; _dmflags_axis_shotty"[/code:1]

callvote.cfg[code:1]"Lean + Strafe" "alias" list
{
"Allowed" "_dmflags_lean_strafe add dmflags 262144 ; _dmflags"
"Disallowed" "_dmflags_lean_strafe ; _dmflags"
}[/code:1]
... or something like that :D

--[MC] Hammer

Mr_nStuff
12-23-2002, 05:58 PM
I can make a workable callvote with both a Lean+Strafe vote and AxisShotgun vote using add and subtract commands.

The problem is that callvote can not detect whether something is being voted on that's already set..

So lets say Lean+Strafe is already set to on. So your dmflags is set to 262144.. Now some moron comes on and calls a vote to turn the Lean+Strafe on while it's on already. If the vote passes, it adds an additional 262144 to the flags.. Now your dmflags is set to 524288. Which is for the Old-SniperRifle with the Lean+Strafe off.

Here's my callvote right now.. Lean+Strafe is permanently set to on without any vote to change it.
[code:1]"Kick Client" "clientkick" clientnotself

"Axis Weapon" "set" list
{
"Shotgun" "dmflags 1310720"
"Gewehrgranate" "dmflags 262144"
}

"Friendly Fire" "exec" list
{
"On" "FFon.cfg"
"Off" "FFoff.cfg"
}

"Sprint Mode" "set" list
{
"On" "sv_dmspeedmult 1.100000;sv_sprinton 1"
"Off" "sv_dmspeedmult 1.000000;sv_sprinton 0"
}[/code:1]

If it weren't for the problem at hand. I would add a vote for Lean+Strafe for the heck of it.. But right now that's only possible using add and subtract commands. Which causes problems if someone votes on something that's already set.

Hammer
12-23-2002, 09:02 PM
Check my posting again and pay close attention to the _dmflags alias and it's use in the callvote file. The alias sets dmflags to all the active _dmflags_* aliases (only show two in my example). Hence, you don't have to worry about double-adding/subtracting.

--[MC] Hammer

Mr_nStuff
12-28-2002, 11:39 PM
oh yeah.. that works that way.. very clever indeed.

well to bad I don't want people to vote on anything other than the german shotgun. heh

thanks for the help!