Raised This Month: $ Target: $400
 0% 

nVault/stock problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TitANious
Veteran Member
Join Date: Feb 2009
Location: Denmark
Old 06-21-2009 , 14:41   nVault/stock problem
Reply With Quote #1

I got a problem with a point plugin. The deal is that i want to save with nVault and i got a stock i want to save (get_user_points ( id ))
Variables
PHP Code:
new gPlayerPoints33 ]

new 
iAuthId33 ][ 40 ]

new 
iVault 
Plugin_init()
PHP Code:
public plugin_init ( ) 
{
    
register_plugin PLUGINVERSIONAUTHOR )
    
iVault nvault_open "ps_dr_points" )

The function
PHP Code:
public plugin_end ( ) 
{
    
// Close the vault with all the points stored.
    
nvault_close iVault )
}

public 
client_authorized id 
{
    
// Get players authid.
    
get_user_authid idiAuthIdid ], 39 )
    
    
// Load players points.
    
ps_load_points id )
}

public 
client_disconnect id 
{
    
// Save players points.
    
ps_save_points id )
}

ps_load_points id 
{
    new 
szData32 ], iTimeStamp
    
    
// Look up players authid, points and timestamp.
    
if ( nvault_lookup iVaultiAuthIdid ], szData31iTimeStamp ) ) 
    {
        static 
num]
        
        
strbreak szDatanumsizeof num ) - 1szDatasizeof(szData) - )
        
        
get_user_points id ) = str_to_num num )
    } 
    else 
    { 
// If it wasnt found, set players points to 0.
        
set_user_points id)
    }
}

ps_save_points id 
{
    new 
szData32 ]
    
    
// Format the players points in to szData.
    
format szDatasizeofszData ) - 1"%i"get_user_points id ) )
    
    
// Save players authid with the points.
    
nvault_set iVaultiAuthIdid ], szData )

The stock(s)
PHP Code:
stock set_user_points indexvalue 
{
    
gPlayerPointsindex ] = value;
}

stock get_user_points index )
{
    return 
gPlayerPointsindex ]

__________________
I dislike this.

"A sneeze never comes alone!" <-- Important to remember.
TitANious is offline
Send a message via MSN to TitANious
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-21-2009 , 14:43   Re: nVault/stock problem
Reply With Quote #2

PHP Code:
ps_load_points id 
{
    new 
szData32 ], iTimeStamp
    
    
// Look up players authid, points and timestamp.
    
if ( nvault_lookup iVaultiAuthIdid ], szData31iTimeStamp ) ) 
    {
        static 
num]
        
        
strbreak szDatanumsizeof num ) - 1szDatasizeof(szData) - )
        
        
set_user_points idstr_to_numnum ) )
    } 
    else 
    { 
// If it wasnt found, set players points to 0.
        
set_user_points id)
    }

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
TitANious
Veteran Member
Join Date: Feb 2009
Location: Denmark
Old 06-21-2009 , 14:47   Re: nVault/stock problem
Reply With Quote #3

I hope it will work. Thanks for the fast reply Exolent!
__________________
I dislike this.

"A sneeze never comes alone!" <-- Important to remember.
TitANious is offline
Send a message via MSN to TitANious
Reply


Thread Tools
Display Modes

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 15:30.


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