Raised This Month: $ Target: $400
 0% 

Solved Save, read and compare user IP in fvault


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-04-2021 , 10:07   Re: Save, read and compare user IP in fvault
Reply With Quote #5

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_DataVAULT_IPcharsmax(VAULT_IP))
        
        new 
iIPPos bool:bFound;
        for (new 
0size_vaulti++)
        {
            
fvault_get_keyname(VaultiSZ_NAMEcharsmax(SZ_NAME));
            
fvault_get_data(VaultSZ_NAMESZ_Datacharsmax(SZ_Data));
            
            
iIPPos strfindSZ_Data "IP: " );
            
            if ( 
iIPPos > -)
            {
                if ( 
equalg_szUserIPid ] , SZ_DataiIPPos ] ) )
                {
                    
client_print(0print_chat"The user ip is already saved in the file.");
                    
bFound true;
                    break;
                }
            }
        }
    }
    
    if ( 
bFound == false )
    {
        
client_print(0print_chat"The user ip is not saved in the file.");
    }

__________________

Last edited by Bugsy; 07-04-2021 at 10:28.
Bugsy is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:29.


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