AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   nVault/stock problem (https://forums.alliedmods.net/showthread.php?t=95238)

TitANious 06-21-2009 14:41

nVault/stock problem
 
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 ]



Exolent[jNr] 06-21-2009 14:43

Re: nVault/stock problem
 
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)
    }



TitANious 06-21-2009 14:47

Re: nVault/stock problem
 
I hope it will work. Thanks for the fast reply Exolent!


All times are GMT -4. The time now is 15:30.

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