There are a few things that need fixing in your code, below is part of your problem. I recommend you instead use nvault with nvault array, it will be easier to store multiple pieces of data for a player, in this case name and IP, and also steam id if you want. With fvault, you'll need to string it all together and then pull the info back out. "Name: bugsy IP: 255.255.255.255:12345 SteamID: STEAM_0:0:12345"
Code:
for (new i = 0; i < size_vault; i++){
fvault_get_keyname(Vault, i, SZ_NAME, charsmax(SZ_NAME));
fvault_get_data(Vault, SZ_NAME, SZ_Data, charsmax(SZ_Data));
//You are comparing the wrong variable here, you are reading the value from fvault into SZ_Data while you are
//using g_szUserIP[id] and g_szSavedIP[] in the check. Avoid declaring variables globally when its not needed,
//such as g_szSavedIP[]. This should be local to the function.
//Also, your data is saved in the below format, you will need to parse the IP value from it.
//"Name: %s - IP: %s" - You need to pull just the IP out of this for the compare.
//Do you want to check the name too, if so that will be an additional parse/check.
if(equal(g_szUserIP[id], g_szSavedIP[i])){
client_print(0, print_chat, "The user ip is already saved in the file.");
}
else{
client_print(0, print_chat, "The user ip is not saved in the file.");
}
}
return PLUGIN_HANDLED;
Not tested:
PHP Code:
parse(SZ_Data, VAULT_IP, charsmax(VAULT_IP))
new iIPPos , bool:bFound;
for (new i = 0; i < size_vault; i++)
{
fvault_get_keyname(Vault, i, SZ_NAME, charsmax(SZ_NAME));
fvault_get_data(Vault, SZ_NAME, SZ_Data, charsmax(SZ_Data));
iIPPos = strfind( SZ_Data , "IP: " );
if ( iIPPos > -1 )
{
if ( equal( g_szUserIP[ id ] , SZ_Data[ iIPPos + 4 ] ) )
{
client_print(0, print_chat, "The user ip is already saved in the file.");
bFound = true;
break;
}
}
}
}
if ( bFound == false )
{
client_print(0, print_chat, "The user ip is not saved in the file.");
}
}
__________________