Raised This Month: $ Target: $400
 0% 

save connections with nvault


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Afro-Ankan
Member
Join Date: Jul 2009
Location: Sweden
Old 07-29-2010 , 18:17   save connections with nvault
Reply With Quote #1

hello, im trying to make a Connect plugin with "save Connections".


ex: Afro-ankan has connected from sweden [connections: 33]

next time i connect to thesame server:

Afro-ankan has connected from sweden [connections: 34]

need some help plz
Afro-Ankan is offline
Send a message via MSN to Afro-Ankan
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-29-2010 , 18:31   Re: save connections with nvault
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <nvault>

new gConnectVault

public plugin_init()
{
    
gConnectVault nvault_open("ConnectVault")
    if(
gConnectVault == INVALID_HANDLE)
        
set_fail_state("nVault failed to open")
}

public 
client_connect(id)
{
    new 
AuthID[34]
    
get_user_authid(idAuthID33)
    
    new 
tempdata[12]
    
nvault_get(gConnectVaultAuthIDtempdata)
    
    new 
connections str_to_num(tempdata)
    
    
connections++
    
    
num_to_str(connectionstempdata11)
    
    
nvault_set(gConnectVaultAuthIDtempdata)

That should save connections using nVault, but it uses SteamID.
RedRobster is offline
Afro-Ankan
Member
Join Date: Jul 2009
Location: Sweden
Old 07-29-2010 , 18:39   Re: save connections with nvault
Reply With Quote #3

thank you. it works
Afro-Ankan is offline
Send a message via MSN to Afro-Ankan
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-29-2010 , 19:31   Re: save connections with nvault
Reply With Quote #4

When using nvault_get to retrieve a string, you need to pass the string variable along w\ maxlen value. Passing only 3 parameters will make the function think you are trying to retrieve a float byref. In this instance, it would be best to use nvault_get to retrieve an integer (only pass vault handle and key). Also, make sure to close the vault. There is a tutorial in the code snippets\tuts section.

How nvault_get functions based on # params:
2 parameters - function returns integer value
3 parameters - function sets float byref
4 parameters - function sets string byref for maxlen chars

Untested
PHP Code:
#include <amxmodx>
#include <nvault>

new gConnectVault

public plugin_init()
{
    
gConnectVault nvault_open("ConnectVault")
    
    if(
gConnectVault == INVALID_HANDLE)
        
set_fail_state("nVault failed to open")
}

public 
plugin_end()
{
    
nvault_closegConnectVault );
}

public 
client_putinserverid )
{
    static 
szAuthID34 ] , szName33 ] , szTemp] , iConnections;
    
get_user_authidid szAuthID charsmaxszAuthID ) );
    
get_user_nameid szName charsmaxszName ) );

    
iConnections nvault_getgConnectVault szAuthID );
    
    
num_to_str( ++iConnections szTemp charsmaxszTemp ) );
    
nvault_setgConnectVault szAuthID szTemp );

    
client_printprint_chat "* %s has connected and now has %d connections" szName iConnections );

__________________

Last edited by Bugsy; 07-29-2010 at 19:34.
Bugsy is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 07-29-2010 , 19:45   Re: save connections with nvault
Reply With Quote #5

Using client_authorized() is not better than client_putinserver() for the SteamID ?
__________________
You can do anything you set your mind to, man.

Devil259 is offline
Afro-Ankan
Member
Join Date: Jul 2009
Location: Sweden
Old 07-29-2010 , 19:49   Re: save connections with nvault
Reply With Quote #6

thanks guys
Afro-Ankan is offline
Send a message via MSN to Afro-Ankan
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-29-2010 , 20:01   Re: save connections with nvault
Reply With Quote #7

IIRC, authorized its called prior to putinserver but either way works.
__________________
Bugsy is offline
Afro-Ankan
Member
Join Date: Jul 2009
Location: Sweden
Old 07-29-2010 , 20:09   Re: save connections with nvault
Reply With Quote #8

should look like this ?

PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <nvault>
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"
new gConnections[33]
new 
gConnectVault
public plugin_init()
{
 
gConnectVault nvault_open("ConnectVault")
 if(
gConnectVault == INVALID_HANDLE)
  
set_fail_state("nVault failed to open")
}
public 
client_connect(id)
{
 new 
AuthID[34]
 
get_user_authid(idAuthID33)
 
 new 
tempdata[12]
 
nvault_get(gConnectVaultAuthIDtempdata)
 
 new 
connections str_to_num(tempdata)
 
 
connections++
 
gConnections[id] = connections
 
 num_to_str
(connectionstempdata11)
 
 
nvault_set(gConnectVaultAuthIDtempdata)
 
 new 
name[34]
 
get_user_name(idname33)
 
client_print(0print_chat"%s has connected. [%i Connections]"namegConnections[id])

Afro-Ankan is offline
Send a message via MSN to Afro-Ankan
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-29-2010 , 20:19   Re: save connections with nvault
Reply With Quote #9

The plugin I posted is better. Do you need each players connection count elsewhere in the plugin? If not then no need for that global array.
__________________
Bugsy is offline
Afro-Ankan
Member
Join Date: Jul 2009
Location: Sweden
Old 07-29-2010 , 20:23   Re: save connections with nvault
Reply With Quote #10

ok. thanks
__________________
My Current Projects:
Pistols vs Pistols Public
Progress [ | | | | | | | | | | ]
Only 10% Completed
Afro-Ankan is offline
Send a message via MSN to Afro-Ankan
Reply



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 00:18.


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