AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   nVault bug? (https://forums.alliedmods.net/showthread.php?t=187882)

Misery 06-19-2012 09:23

nVault bug?
 
Hi,

I'm maintaining a ban vault... It's a short one, since all bans contained in it are only temporary.
I'm running down problems...

You see, I don't need to put a value in the key. So the key can be empty. In fact only timestamp and the key name are what matters.
I use nvault_touch() to set the empty key and update the timestamp to make it the an unban timestamp (i.e. time() + banlength_in_seconds). The advantage is that I can then prune the vault to remove exprired bans... based on timestamps.

However, the vault crashes miserably...
Give it a look too...

Code:

#include <amxmodx>
#include <nvault>

public plugin_init()
{
        new pvault = nvault_open("testvault");
        nvault_touch(pvault, "STEAM_0:0:56423", time() + 3600); // Will create an empty key
        nvault_close(pvault);
}

Now, add it to plugins.ini, load your hlds install. Once AMXX plugins are all loaded, type "exit" in the server console. Repeat once and you will get a nice crash...

Do I miss something?

Cordially,
Misery

Liverwiz 06-19-2012 18:09

Re: nVault bug?
 
Why don't you use the ID as the key (who you want to ban) the touch as the ban-begin, and the data as the ban-end. and each load you iterate and check weather the data is equal to the current time. Then delete it if it is. That way you can also have a way to find out when someone was banned-i've found a need for this many a day as an owner. This will also give you easy ways to remove bans, check bans, extend bans, and would be easier to implement as well.

Misery 06-20-2012 02:12

Re: nVault bug?
 
Well, it's an automatic ban system made for different rules breaking. Does not need really all these cosmetics. It's really only for misc. bans...

I guess nVault is a crappy implementation... crashing like that because the key is empty. Ill put some shitty value in the key string to circumvent the bug...

Still, Thank you,
Misery

Liverwiz 06-20-2012 11:33

Re: nVault bug?
 
No matter what you do, unless you write your own, the persistence system you use (sQL/nVault/fVault) requires some sort of identifier for the data. Otherwise it doesn't know what its retrieving. So it crashes. Its the rules of data handling. You need some sort of hook for the data, otherwise its just data with no use to the system. Anyways....it'd be silly not to have a key, especially if you want to iterate through.

Misery 06-21-2012 03:59

Re: nVault bug?
 
No. Lots of binary vaults including ones in UNIX flavors support PERFECTLY empty keys.

The data is identified by a hash table, and the key name is retrireved through this. Not with the value inside the key, but rather with the key name.
What I told you is that only two things are important in my case:
1- Key name
2- Timestamps

I don't need to have a value assigned to the key, since the timestamp supercedes the key value in this context. Hance why I wanted empty keys (not empty key name, but a null string as the key value).

Thanks anyways for trying to help Liverwiz, but I just used a workaround... assign the character "@" to each key.

Misery


All times are GMT -4. The time now is 06:13.

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