View Full Version : C++ w/ Configs?
pete
July 19th, 2003, 03:48 PM
Was wondering if it was posible to use C++ in TFC *.cfg files. I don't know much C++, but i do know a lot of PHP. I wanted to do something like:
$pyro = pyro.cfg
if ($pyro == 1) {
cl_cmdrate ++10
} else {
cl_cmdrate 37
}
So basicaly, if pyro.cfg is executed, then add 10 to my cl_cmdrate, else keep my cl_cmdrate at 37.
*EDIT* I don't want it to be exactly like this, i could just go into my pyro.cfg and put cl_cmdrate 47 then make another config and have it exec by each class that puts it back to cl_cmdrate 37. What I really want to know if it is just posible to use some type of C++ or PHP or some shit in configs.
TkMasTaH
July 19th, 2003, 04:02 PM
idk, but what you just posted isnt C++. looks like perl to me.
pete
July 19th, 2003, 04:15 PM
what i posted was php, but i don't know any C++ thats why i used php instead, but C++ and PHP are simular so i figured what the hell..
Koron
July 19th, 2003, 04:16 PM
No, you can't. The scripting engine is intentionally limited. Anything more and you could have serious cheating with just scripts.
K2`
July 19th, 2003, 06:28 PM
What you can do is set up each of your class configs individually (pyro.cfg, scout.cfg, etc.) with all of the settings you need for that specific class, and just enable config parsing...I *believe* the cmd is "cl_lc 1". Every time you change classes, the correct config will be loaded automatically.
July 19th, 2003, 06:38 PM
setinfo "ec" "1" will execute the class configs whenever you change class
not "cl_lc" which is a lag compensation setting :)
OGC has some limited support for branching and looping in HL scripts but obviously it's illegal and not really that useful anyway
pete
July 19th, 2003, 07:48 PM
Shit, OGC is illegal?
gabe
July 19th, 2003, 09:15 PM
Originally posted by pete
Shit, OGC is illegal?
rofl
adroit
July 19th, 2003, 11:23 PM
your php is horrid
ABM-
July 19th, 2003, 11:27 PM
All I want from the scripting engine is If statements D:
adroit
July 20th, 2003, 12:47 AM
Originally posted by ABM-
All I want from the scripting engine is If statements D: of course that includes else and elseif statements, right?
Koron
July 20th, 2003, 12:49 AM
Originally posted by adroit
your php is horrid
What, exactly, was horrid about his 5 line piece of code? What have you ever coded with PHP?
LilBigCip
July 20th, 2003, 03:11 AM
you could just put cl_cmdrate in all other configs than pyro and put cl_cmdrate in the pyro one
Acharne
July 20th, 2003, 03:24 AM
hehe...
If "enemy in crosshairs":
fire weapon;
elseif "enemy not in crosshairs":
reload weapon;
(pseudo code, not really a language)
Kami-
July 20th, 2003, 04:15 AM
make a config with the values that you want to be default, then simply exec it at the begining of all your class configs. That way you can change whatever you want (assuming it's in the aformentioned cfg) and have it change back after you change class.
Just make sure that you exec it in every class config :P
an example: my sniper cfg
echo SNIPER CFG LOADED
exec base.cfg
alias +hidefire "+attack;wait;crosshair 0"
alias -hidefire "-attack;wait;crosshair 1"
bind mouse1 +hidefire
The 'base.cfg' resets my mouse1 to +attack every time it's run, and since it's at the begining of all my cfgs, i can have my gay little crosshair hiding alias on sniper without having it on medic :)
edit: the command to enable class configs is 'setinfo ec 1'
BoyG
July 20th, 2003, 07:03 AM
The thing you want is to modify your class configs and such as stated above. Also one reason his PHP is horrid would be the lack of the terminating semicolon. Another is that the opening and closing php tags aren't there, but I'm not that picky. I'm sure an external hook could be coded to support such a scripting language though. holy hell it's 6am. . . offf to bed fr me.
pete
July 20th, 2003, 10:25 AM
jesus christ i was giving an example chill out yall. So basicaly, you cannot use php in configs, unless posibly a hook was made, the end.?
ABM-
July 20th, 2003, 10:40 AM
Originally posted by adroit
of course that includes else and elseif statements, right?
Yes. Let's add while loops too!
If they actually did put it in, it'd have to be severely limited..
They would have to not allow usage of %i or anything.. that could be used evilly.
But if they allowed integer variables that could possibly store numbers from things like commands it wouldn't be as bad ^_^
July 20th, 2003, 11:10 AM
Looks more like Java script to me than C++
Paragon
July 20th, 2003, 11:48 AM
You can get pretty close to if/else branches with the alias commands already given... It's more like setting function pointers maybe. And you have a while loop already with _special. If you're elite you can set it up to.. heck, I dunno, loop stuff like auto discard, reload, jump, moveup, chop, throw flag, det pipes, and +use separately or at the same time depending on what keys you press to activate a variety of aliases in tandem to determine what happens. Thanks to hooks we can even get them to trigger when certain events happen, so you can stop them when you die and start them up again when you spawn, get them going when you touch the flag, or who knows.
FryGuy
July 20th, 2003, 11:01 PM
Originally posted by adroit
your php is horrid
pete
July 21st, 2003, 01:45 PM
its php damnit, lol
AGT-King
July 21st, 2003, 08:40 PM
lol, you just suck at using white space is all =]
pete
July 21st, 2003, 09:02 PM
but this space is blue!
FryGuy
July 22nd, 2003, 01:55 AM
perhaps this is better:
bind p changecmdrate
<?
function changecmdrate() {
if ($class == "pyro") {
cl_cmdrate += 10;
} else {
cl_cmdrate 37;
}
}
?>
Your example is terrible. I mean, you are setting $pyro to pyro.cfg, then comparing it to the number 1. How is the code snippet getting run anyways? Is it being put in the autoexec or something?
Anyways, the answer to your question is no, you can't do something like that directly in config files. You can do something with a bunch of aliases (which is a pain), or you can write an addon to sparkies (related code would be in Pre_Hud_Reset).
adroit
July 22nd, 2003, 02:21 AM
fryguy summed it up for me
pete
July 22nd, 2003, 06:57 AM
aight yall are fucken retards or something. im sure that each one of you spell check, and take as much 5 mins to write up each damn post. ITS A FUCKEN GAMING FORUM AND WE DON"T GIVA FUCK ABOUT SPELLING/ERRORS.
All i was doing was giving an example, if its that hard to figure out then just stfu already.
Rimuladas
July 22nd, 2003, 01:31 PM
yes, pete, they are retarted.
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.