AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Saving/Loading API for .ini/.cfg? (https://forums.alliedmods.net/showthread.php?t=278993)

SkumTomteN 02-12-2016 20:07

Saving/Loading API for .ini/.cfg?
 
Hello, is there a api or plugin example for saving/loading with a file (ini/cfg) ?, just like nvault for example.

Depresie 02-12-2016 20:23

Re: Saving/Loading API for .ini/.cfg?
 
Mhmm... for loading cvars, or file paths, such as sounds/sprites/models there is an API in zp 5.0, called amx_settings_api

For saving data per player and stuff, i recommend nvault or sql

SkumTomteN 02-12-2016 21:24

Re: Saving/Loading API for .ini/.cfg?
 
Quote:

Originally Posted by Depresie (Post 2392440)
Mhmm... for loading cvars, or file paths, such as sounds/sprites/models there is an API in zp 5.0, called amx_settings_api

For saving data per player and stuff, i recommend nvault or sql

Ive never had a safe nvault or sql. i tried my absoulte best to code the safest mysql possible.

There was an API for mysql, but i forgot who posted it, and i cannot find it.


I already make a plugin that saves a value successfully after changing map. via CFG.
Im not sure if i will use it.

wickedd 02-12-2016 21:47

Re: Saving/Loading API for .ini/.cfg?
 
Quote:

Originally Posted by SkumTomteN (Post 2392448)
Ive never had a safe nvault or sql. i tried my absoulte best to code the safest mysql possible.

What do you mean safe?

siriusmd99 02-13-2016 04:35

Re: Saving/Loading API for .ini/.cfg?
 
Mysql api is under your nose, I mean look into admin.sma , it has defined MySQL for loading and saving admins. =)

Bugsy 02-13-2016 12:24

Re: Saving/Loading API for .ini/.cfg?
 
You have many options, easiest would be vault or nvault.

With regular vault (get_vaultdata, set_vaultdata, remove_vaultdata, vaultdata_exists), it is saved in plain-text format so you could go into amxmodx\data\vault.ini and see your saved values. The only thing you will need to do is prefix your key(s) with your plugin name or some other identifier so another plugin doesn't use your data. You cannot specify an individual vault file like nvault allows.
Code:

; Don't modify!
server_language        en
SomeNumber        28
ABCPluginTimeStamp        1452397473
ABCPluginStartDate        12/26/2015 22:44
ABCPluginEndDate        01/09/2016 22:44

With nvault, you can specify the vault file name so you do not need to differentiate your keys for your plugin. But, you do need to differeniate your keys if you are saving multiple types of data using the steam-id as a 'base key'. eg. XPPoints_STEAM_0:0:12345, Health_STEAM_0:0:12345. Or, you can use nvault_get/setarray from nVault Utility and save multiple data items under the same key.

Depresie 02-13-2016 21:36

Re: Saving/Loading API for .ini/.cfg?
 
So nvault looks like what you were looking for... it is also easy to use
Plus you will never run into trouble with it as long as bugs is around, believe me, he can make it cook even pancakes

Bugsy 02-13-2016 22:05

Re: Saving/Loading API for .ini/.cfg?
 
The thing with nvault is it is saved in binary format so you cannot read/modify the data in a text editor. You need to use an nvault editor for this (see signature). I'm not sure if this matters to you or not.

klippy 02-14-2016 02:33

Re: Saving/Loading API for .ini/.cfg?
 
There are INI and SMC (SourceMod Configuration format) parsers in 1.8.3-dev version, if you are willing to use it.
I believe Mercylezz published his INI parser as a standalone plugin around here.
Also, writing your own "key=value" parser shouldn't be difficult at all.


All times are GMT -4. The time now is 09:33.

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