AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [INCLUDE] AutoExecConfig: Read and append to auto configs (https://forums.alliedmods.net/showthread.php?t=204254)

TnTSCS 07-29-2013 13:44

Re: [INCLUDE] Autoexecconfig read and append beta
 
On windows the config file is built properly with the additional/missing CVars with appropriate formatting... on Linux, the new CVars and descriptions are all on one long line.

Maybe I don't have the permission on the file set properly, because I see you write "\n" but it just failed to write on my .cfg file...

The file attributes for my config file is: 664

Impact123 07-29-2013 17:33

Re: [INCLUDE] Autoexecconfig read and append beta
 
I'm sorry if this sounds dumb, but which editor do you use to open/read the file?

Yours sincerely
Impact

TnTSCS 07-29-2013 17:45

Re: [INCLUDE] Autoexecconfig read and append beta
 
The last time I opened it and edited it was withing FileZilla from a Windows box... so, notepad.

I guess that could be the culprit :(

I'll have to open it with gedit again, remove a couple of CVars and let the plugin append the file and let you know how it goes. I've edited the cfg and remove 3 CVars that were set to default anyways, I'll reply once the map has changed.

Impact123 07-29-2013 17:53

Re: [INCLUDE] Autoexecconfig read and append beta
 
Yep, if you open up the file in a editor like notepad++ it looks fine.

Yours sincerely
Impact

TnTSCS 07-29-2013 18:01

Re: [INCLUDE] Autoexecconfig read and append beta
 
That's right, because windows uses the \r\n for a new line... sorry about that.

...:: TnT Edit ::...

If, in my CreateConVar I have some \n's in there, they are not properly carried over in the config.

They show up missing the // characters, like:

PHP Code:

// Use the iBots_maxfrags?
NO
YES
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
iBots_usemaxfrags "1"

// Team number for bots (2 is T, 3 is CT)
// -
// Default: "2"
// Minimum: "2.000000"
// Maximum: "3.000000"
iBots_TEAM_BOT "2"

// Utilize 'Updater' plugin to auto-update iBots when updates are published?
1=yes0=no
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
iBots_useupdater "0" 

the usemaxfrags:
PHP Code:

AutoExecConfig_CreateConVar("iBots_usemaxfrags""1""Use the iBots_maxfrags?\n0 = NO\n1 = YES"_true0.0true1.0


Impact123 07-29-2013 18:08

Re: [INCLUDE] Autoexecconfig read and append beta
 
Well, the original autoexecconfig does the same, i don't know if it would be a good thing to alter this behavior.

Yours sincerely
Impact

TnTSCS 07-29-2013 18:09

Re: [INCLUDE] Autoexecconfig read and append beta
 
The sourcemod autoexecconfig puts //'s on the new line created by the \n in the description

...:: TnT Edit ::...
You were probably talking about the \r\n thing, right? Not the //'s thing

Impact123 07-29-2013 18:37

Re: [INCLUDE] Autoexecconfig read and append beta
 
Yeah, i see, it's this part that does it.
I see if i can implement it tomorrow.

Yours sincerely
Impact

TnTSCS 07-29-2013 21:19

Re: [INCLUDE] Autoexecconfig read and append beta
 
Cool, thanks... I was going to try and update the code on github, but if you're going to do it, that's better, I'll learn by looking :)

Impact123 07-30-2013 07:15

Re: [INCLUDE] Autoexecconfig read and append beta
 
Well, feel free to contribute if you want :)
I added support for multiline comments, i used a different approach than the original autoexecconifig function, but it seems to work fine.
It was important to me that it doesn't slow things down when you don't use newlines, i think i found a good way between some overhead and easyness.
My only concern is that you might run into a "Not enough space on the stack" error if you have dozens of newlines, but we'll see.
Here is the commit.

Yours sincerely
Impact


All times are GMT -4. The time now is 08:58.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.