About plugin
plugin is working well while saving and retrying at load and save but nvault lookup is not working it is not able to check the data is already exist or not
someone please help me
PHP Code:
#include <amxmodx>
#include <nvault>
#define PLUGIN "Test_lookup"
#define VERSION "1.0"
#define AUTHOR "26-{indra}"
new g_Vault;
new szName[33],szKey[10],Text[10];
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("Enter_string","get_strings");
register_clcmd("say /test","testmenu");
}
public plugin_cfg()
{
g_Vault = nvault_open( "Test_lookup" );
}
public client_putinserver(id)
{
load_string(id);
}
public client_disconnect(id)
{
save_string(id);
}
public plugin_end()
{
nvault_close( g_Vault );
}
public testmenu(id)
{
new menu = menu_create("Enter a string", "mh_testMenu");
menu_additem(menu, "Enter a string", "", 0);
menu_additem(menu, "Submit ", "", 0);
menu_display(id, menu, 0);
}
public mh_testMenu(id, menu, item)
{
switch(item)
{
case 0:
{
new szVal[10];
new iExists,iTimestamp;
get_user_name( id , szName , charsmax( szName ) );
iExists = nvault_lookup( g_Vault , "szName" , szVal , charsmax( szVal ) , iTimestamp );
if(iExists)
{
client_print(id,print_chat,"This user already entered string")
}
else
{
client_cmd(id, "messagemode Enter_string");
testmenu(id)
}
}
case 1:
{
client_print(id, print_chat,"Your string is saved");
save_string(id);
}
}
menu_destroy(menu);
}
public get_strings(id)
{
read_args(Text, charsmax(Text));
remove_quotes(Text);
if(equal(Text, ""))
return PLUGIN_HANDLED;
client_print(id,print_chat,"the enter string is %s",Text);
return PLUGIN_CONTINUE;
}
public load_string(id)
{
get_user_name( id , szName , charsmax( szName ) );
formatex( szKey , charsmax( szKey ) , "%s-string", szName );
nvault_get( g_Vault , szKey , Text);
server_print("the data is retry %s",Text);
return PLUGIN_CONTINUE;
}
public save_string(id)
{
get_user_name( id , szName , charsmax( szName ) );
formatex( szKey , charsmax( szKey ) , "%s-string", szName );
nvault_set( g_Vault , szKey , Text );
server_print("the data is saved %s",Text);
return PLUGIN_CONTINUE;
}
Thanks everyone. #miss_you_all