amxmodx/amxmodx/vault.cpp

61 lines
1.4 KiB
C++
Raw Normal View History

2014-08-04 08:36:20 +00:00
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
2004-01-31 20:56:22 +00:00
2004-03-24 01:35:44 +00:00
#include "amxmodx.h"
2004-04-22 08:10:29 +00:00
#include "CVault.h"
2004-01-31 20:56:22 +00:00
Vault g_vault;
2005-09-10 20:09:14 +00:00
static cell AMX_NATIVE_CALL set_vaultdata(AMX *amx, cell *params)
2004-01-31 20:56:22 +00:00
{
2005-09-10 20:09:14 +00:00
int iLen;
2004-01-31 20:56:22 +00:00
2005-09-10 20:09:14 +00:00
g_vault.put(get_amxstring(amx, params[1], 0, iLen), get_amxstring(amx, params[2], 1, iLen));
g_vault.saveVault();
2004-01-31 20:56:22 +00:00
2005-09-10 20:09:14 +00:00
return 1;
2004-01-31 20:56:22 +00:00
}
2005-09-10 20:09:14 +00:00
static cell AMX_NATIVE_CALL get_vaultdata(AMX *amx, cell *params)
2004-01-31 20:56:22 +00:00
{
2005-09-10 20:09:14 +00:00
int iLen;
const char* key = get_amxstring(amx, params[1], 0, iLen);
2004-01-31 20:56:22 +00:00
2005-09-10 20:09:14 +00:00
if (params[3])
return set_amxstring(amx, params[2], g_vault.get(key), params[3]);
2004-01-31 20:56:22 +00:00
2005-09-10 20:09:14 +00:00
return g_vault.get_number(key);
2004-01-31 20:56:22 +00:00
}
2005-09-10 20:09:14 +00:00
static cell AMX_NATIVE_CALL remove_vaultdata(AMX *amx, cell *params)
2004-01-31 20:56:22 +00:00
{
2005-09-10 20:09:14 +00:00
int iLen;
2004-01-31 20:56:22 +00:00
2005-09-10 20:09:14 +00:00
g_vault.remove(get_amxstring(amx, params[1], 0, iLen));
g_vault.saveVault();
2004-01-31 20:56:22 +00:00
2005-09-10 20:09:14 +00:00
return 1;
2004-01-31 20:56:22 +00:00
}
2005-09-10 20:09:14 +00:00
static cell AMX_NATIVE_CALL vaultdata_exists(AMX *amx, cell *params)
2004-01-31 20:56:22 +00:00
{
2005-09-10 20:09:14 +00:00
int iLen;
return g_vault.exists(get_amxstring(amx, params[1], 0, iLen)) ? 1 : 0;
2004-01-31 20:56:22 +00:00
}
2005-09-10 20:09:14 +00:00
AMX_NATIVE_INFO vault_Natives[] =
{
{"set_vaultdata", set_vaultdata},
{"get_vaultdata", get_vaultdata},
{"remove_vaultdata", remove_vaultdata},
{"delete_vaultdata", remove_vaultdata},
{"vaultdata_exists", vaultdata_exists},
{0, 0}
2004-04-01 05:53:22 +00:00
};