Raised This Month: $51 Target: $400
 12% 

[EXTENSION] Config (1.0.2)


Post New Thread Reply   
 
Thread Tools Display Modes
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 02-15-2010 , 05:40   Re: [EXTENSION] Config (1.0.0)
Reply With Quote #11

Works great now.
Could you also add a function for reading a config array into an adt array ?
Not important tho, can write that function myself

Yah ! no more stupid keyvalue files

Thanks, greetings ~Berni
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
sfPlayer
Senior Member
Join Date: Dec 2007
Location: Germany
Old 02-15-2010 , 14:06   Re: [EXTENSION] Config (1.0.0)
Reply With Quote #12

I don't think that's worth it since you already have random access using ConfigLookup* without too much overhead, at least if it's not in OnGameFrame.

An ADT_Array can cover only simple 1-dimensional config files so it's up to you to build one if you need it.
sfPlayer is offline
Thraka
AlliedModders Donor
Join Date: Aug 2005
Old 02-22-2010 , 11:56   Re: [EXTENSION] Config (1.0.1)
Reply With Quote #13

0_0

This extension is awesome!
Thraka is offline
Chanz
Veteran Member
Join Date: Aug 2008
Location: Germany - Stuttgart
Old 02-25-2010 , 17:48   Re: [EXTENSION] Config (1.0.1)
Reply With Quote #14

Very nice extension. :-)

But I found a small issue:
In my config file I wrote:
PHP Code:
cvar_enable 1
Then I try:
PHP Code:
ConfigLookupBool(config"cvar_enable"
It returns 0 instead of 1.

But when I write:
PHP Code:
cvar_enable true
it works.
__________________
[ SourceModPlugins.org ][ My Plugins ]

Thank you for donations: [ Paypal ]

Video Tutorial (German): [ Gameserver & SourceMod Plugins mit HLSW verwalten ]
Chanz is offline
sfPlayer
Senior Member
Join Date: Dec 2007
Location: Germany
Old 02-26-2010 , 00:43   Re: [EXTENSION] Config (1.0.1)
Reply With Quote #15

It'll always return 0 if the type is wrong (1 is no bool).
sfPlayer is offline
Chanz
Veteran Member
Join Date: Aug 2008
Location: Germany - Stuttgart
Old 02-26-2010 , 00:59   Re: [EXTENSION] Config (1.0.1)
Reply With Quote #16

Oh ok means clean coding huh?
Unfortunately the 0815 server admin doesn't know about booleans and variable types. I see many post coming up with the question why my plugin does not work and the only problem is that those server admins can't enter true and false instead of 0 and 1.

btw: It's already hard enough for them to find the config file. ;)

I'm not asking to change that behavior, since there are other possibilities to ask the SA (or the client) for the desired configuration. But this takes again some lines of codes and weakens the the improvement of your extension in making the plugin code shorter and more powerful.
Or you need a more time intensive explanation how the new config file works.

Don't get me wrong its just a small issue that itches me, I think your ext is great and should be implemented in SM, since I really hate the kv config file system.
__________________
[ SourceModPlugins.org ][ My Plugins ]

Thank you for donations: [ Paypal ]

Video Tutorial (German): [ Gameserver & SourceMod Plugins mit HLSW verwalten ]

Last edited by Chanz; 02-26-2010 at 01:09.
Chanz is offline
sfPlayer
Senior Member
Join Date: Dec 2007
Location: Germany
Old 02-26-2010 , 01:09   Re: [EXTENSION] Config (1.0.1)
Reply With Quote #17

you can easily allow multiple types:

new value = ConfigLookupBool(config, "cvar_enable");
if (value == 0) value = ConfigLookupInt(config, "cvar_enable");

true: value = 1, if doesn't trigger
false: value = 0, if triggers and ConfigLookupInt returns 0 (no int) -> value = 0
1: value = 0 (no bool), if triggers and ConfigLookupInt returns 1 -> value = 1
0: value = 0 (no bool), if triggers and ConfigLookupInt returns 0 -> value = 0

Last edited by sfPlayer; 02-26-2010 at 01:16.
sfPlayer is offline
Chanz
Veteran Member
Join Date: Aug 2008
Location: Germany - Stuttgart
Old 02-26-2010 , 01:23   Re: [EXTENSION] Config (1.0.1)
Reply With Quote #18

Oh lol yeah thats easy I just kept my head in the config file instead within the code.
<- through-face-palm
__________________
[ SourceModPlugins.org ][ My Plugins ]

Thank you for donations: [ Paypal ]

Video Tutorial (German): [ Gameserver & SourceMod Plugins mit HLSW verwalten ]
Chanz is offline
Thraka
AlliedModders Donor
Join Date: Aug 2005
Old 03-01-2010 , 09:10   Re: [EXTENSION] Config (1.0.1)
Reply With Quote #19

Shouldn't you be using
new bool:cvar_enable = ConfigLookupBool(config, "cvar_enable")
Thraka is offline
Chanz
Veteran Member
Join Date: Aug 2008
Location: Germany - Stuttgart
Old 03-01-2010 , 12:09   Re: [EXTENSION] Config (1.0.1)
Reply With Quote #20

yeah you are right but then you need to typecast later when using:
PHP Code:
  if (value == falsevalue bool:ConfigLookupInt(config,  "cvar_enable"); 
I would use the first one since I can then check the cvar with
PHP Code:
 if (value 0) { SetConVarBool(...); } else { SetConVarBool(...); } 
__________________
[ SourceModPlugins.org ][ My Plugins ]

Thank you for donations: [ Paypal ]

Video Tutorial (German): [ Gameserver & SourceMod Plugins mit HLSW verwalten ]

Last edited by Chanz; 03-01-2010 at 12:18.
Chanz is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:39.


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