I really didn't try to use that JSON, because I simply can't understand even a bit of it...
So, here is what I though out, but unfortunately it's not working (maybe because it's not properly coded).
What I actually did? Well, I pushed new string into the array enum - it's players ID. After this I save it as a string and used it as a key for retrieving the data from the trie.
Btw, I don't know if it's possible to return a string via nvault, but since all the numbers must be converted to strings, I think it will be okay.
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <nvault>
#define PLUGIN "Save Array With Trie"
#define VERSION "1.0"
#define AUTHOR "Flicker"
enum _:GagInfo
{
Trie:Gagged,
Reason[64],
AdminName[32],
Date[32],
Len,
Systime,
ID[32]
}
new gVault
new Array:g_aGaggedPlayers
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
g_aGaggedPlayers = ArrayCreate(GagInfo)
gVault = nvault_open("ArrayData")
LoadGags()
}
public plugin_end()
SaveGags()
new const SizeKey[] = "sasasaisajoda"
new g_arraysize
public SaveGags()
{
new aData[GagInfo]
new szKey[64], szData[526]
g_arraysize = ArraySize(g_aGaggedPlayers)
new szSize[64]
num_to_str(g_arraysize, szSize, charsmax(szSize))
nvault_set(gVault, SizeKey, szSize)
for(new i; i < g_arraysize; i++)
{
ArrayGetArray(g_aGaggedPlayers, i, aData)
formatex(szData, charsmax(szData), "%s %s %s %d %d %s", aData[Reason], aData[AdminName], aData[Date], aData[Len], aData[Systime], aData[ID])
num_to_str(i, szKey, charsmax(szKey))
nvault_set(gVault, szKey, szData)
}
}
public LoadGags()
{
new aData[GagInfo]
new szKey[64], szData[526]
new szSize[64]
nvault_get(gVault, SizeKey, szSize)
g_arraysize = str_to_num(szSize)
for(new i; i < g_arraysize; i++)
{
formatex(szData, charsmax(szData), "%s %s %s %d %d %s", aData[Reason], aData[AdminName], aData[Date], aData[Len], aData[Systime], aData[ID])
num_to_str(i, szKey, charsmax(szKey))
nvault_get(gVault, szKey, szData)
new szLen[32], szSys[32]
parse(szData, aData[Reason], charsmax(aData[Reason]), aData[AdminName], charsmax(aData[AdminName]), aData[Date], charsmax(aData[Date]), szLen, charsmax(szLen), szSys, charsmax(szSys), aData[ID], charsmax(aData[ID]))
aData[Len] = str_to_num(szLen)
aData[Systime] = str_to_num(szSys)
aData[Gagged] = _: TrieCreate()
TrieSetCell(aData[Gagged], aData[ID], 1)
ArrayPushArray(g_aGaggedPlayers, aData)
}
}
__________________