Raised This Month: $ Target: $400
 0% 

Saving/Loading API for .ini/.cfg?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SkumTomteN
Veteran Member
Join Date: Oct 2013
Location: Asgard
Old 02-12-2016 , 20:07   Saving/Loading API for .ini/.cfg?
Reply With Quote #1

Hello, is there a api or plugin example for saving/loading with a file (ini/cfg) ?, just like nvault for example.
__________________
Contact: Steam
Videos: Youtube
SkumTomteN is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-12-2016 , 20:23   Re: Saving/Loading API for .ini/.cfg?
Reply With Quote #2

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
__________________
Depresie is offline
SkumTomteN
Veteran Member
Join Date: Oct 2013
Location: Asgard
Old 02-12-2016 , 21:24   Re: Saving/Loading API for .ini/.cfg?
Reply With Quote #3

Quote:
Originally Posted by Depresie View Post
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.
__________________
Contact: Steam
Videos: Youtube
SkumTomteN is offline
wickedd
Veteran Member
Join Date: Nov 2009
Old 02-12-2016 , 21:47   Re: Saving/Loading API for .ini/.cfg?
Reply With Quote #4

Quote:
Originally Posted by SkumTomteN View Post
Ive never had a safe nvault or sql. i tried my absoulte best to code the safest mysql possible.
What do you mean safe?
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 02-13-2016 , 04:35   Re: Saving/Loading API for .ini/.cfg?
Reply With Quote #5

Mysql api is under your nose, I mean look into admin.sma , it has defined MySQL for loading and saving admins. =)
siriusmd99 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-13-2016 , 12:24   Re: Saving/Loading API for .ini/.cfg?
Reply With Quote #6

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.
__________________

Last edited by Bugsy; 02-13-2016 at 12:26.
Bugsy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-13-2016 , 21:36   Re: Saving/Loading API for .ini/.cfg?
Reply With Quote #7

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
__________________
Depresie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-13-2016 , 22:05   Re: Saving/Loading API for .ini/.cfg?
Reply With Quote #8

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.
__________________

Last edited by Bugsy; 02-13-2016 at 22:06.
Bugsy is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-14-2016 , 02:33   Re: Saving/Loading API for .ini/.cfg?
Reply With Quote #9

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.

Last edited by klippy; 02-14-2016 at 02:33.
klippy 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 09:33.


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