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-05-2021 , 10:40   Re: Save, read and compare user IP in fvault
Reply With Quote #7

You do not need to store both the name and IP in the vault data since the name is stored as the key, so you'll always have it. Try this:

An assumption is 1 ip per player name
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fvault>

#define PLUGIN "fvault test"
#define VERSION "1.0"
#define AUTHOR "Maniatico"

#define MAX_PLAYERS 32

#if AMXX_VERSION_NUM >= 190
#define client_disconnect client_disconnected
#endif

new g_szUserIPMAX_PLAYERS ][ 27 ];

new const 
Vault[] = "_ips";

public 
plugin_init() 
{
    
register_pluginPLUGIN VERSION AUTHOR );
    
    
register_clcmd"amx_save_ip" "SaveIP" ADMIN_IMMUNITY );
}


public 
client_putinserverid )
{
    
get_user_ipid g_szUserIPid ], charsmaxg_szUserIP[] ) , );
    
set_task5.0 "CheckVault" id );
}

public 
client_disconnectid )
{
    
remove_taskid );
}

public 
SaveIPid )
{
    new 
szIP16 ] , szName32 ];
    
    if ( 
get_user_flagsid ) & ADMIN_IMMUNITY )
    {
        
read_argvszIP charsmaxszIP ) );
        
        
//Ideally should use regex here to check for IP format
        
if ( szIP] == EOS || ( containszIP ".") == -) || ( strlenszIP ) < ) )
        {
            
console_printid "Cant take that ip [%s]" szIP );
        }
        else 
        {
            
get_user_nameid szName charsmaxszName ) );
            
fvault_set_dataVault szName szIP );
            
console_printid "IP %s saved" szIP );
        }
    }
    
    return 
PLUGIN_HANDLED;
}
 
public 
CheckVaultid )
{
    new 
szVaultIP16 ] , szName32 ];
    
    
get_user_nameid szName charsmaxszName ) );
    
    if ( 
fvault_get_dataVault szName szVaultIP charsmaxszVaultIP ) ) && equalszVaultIP g_szUserIPid ] ) )
    {
        
client_printprint_chat "The user ip is saved in the file." );
    }
    else
    {
        
client_printprint_chat "The user ip is not saved in the file." );
    }

__________________

Last edited by Bugsy; 07-05-2021 at 11:16.
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