Raised This Month: $ Target: $400
 0% 

Need help about nVault


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JocAnis
Veteran Member
Join Date: Jun 2010
Old 06-22-2011 , 09:08   Need help about nVault
Reply With Quote #1

hi, i m trying to make plugin wich will save admin's time (like played time by alka), but it doesn't work = when reconnect my (admin) time is like reseted (0 minutes)..code:

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

#define PLUGIN "Odigrano vreme admina"
#define VERSION "1.0"
#define AUTHOR "Alka"

new TotalnoVreme33 ]
new 
g_Vault
new name32 ]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd"say /vreme""VremeShow" )
    
register_clcmd"say_team /vreme""VremeShow" )
}
public 
plugin_cfg()
{
    
g_Vault nvault_open"Odigrano-Vreme" )

    if ( 
g_Vault == INVALID_HANDLE )
        
set_fail_state"Greska u otvaranju nVaulta" );
}
public 
plugin_end()
{
    
nvault_closeg_Vault );
}
public 
VremeShowid )
{
    new 
menu menu_create"Izaberi:""Vreme_keys" )
    static 
ctime64 ], timem
    
new showtime100 ]
        
    
timem get_user_timeid) / 60
    get_time
"%H:%M:%S"ctime63 )
    
    
formatshowtime99"Tvoje vreme je\y %d\d minuta.^n"timem TotalnoVremeid ] )
    
    
menu_additemmenushowtime"1" )
    if( 
is_user_adminid ) )
        
menu_additemmenu"Vremena ostalih admina""2" )
    else
        
menu_additemmenu"\dVremena ostalih admina\y (\r Nisi admin\y )""2" )
    
    
menu_displayidmenu)
    return 
PLUGIN_CONTINUE
}
public 
Vreme_keysidmenuitem )
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroymenu )
        return 
PLUGIN_HANDLED
    
}
    new 
data[6], szName[64];
    new 
accesscallback;
    
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    
    new 
key str_to_num(data);
    
    switch( 
key )
    {
        case 
1:
        {
            
VremeShowid )
            
client_printidprint_chat"Tvoje ukupno vreme na serveru je %d minuta."get_user_timeid) / 60 TotalnoVremeid ] )
        }
        case 
2:
        {
            if( 
is_user_adminid ) )
            {
                
VremeAdminaid )
            }
            else
            {
                
VremeShowid )
                
client_printidprint_chat"Potreban ti je admin za ovu komandu." )
            }
        }
    }
    return 
PLUGIN_CONTINUE
}
VremeAdminaid )
{
    
client_printidprint_console"----------^nVreme     Ime^n" )
    new 
broj_admina 4ctime64 ]
    
get_time"%H:%M:%S"ctime63 )
    for( new 
igrac 1igrac broj_adminaigrac++ )
    {
        
client_printidprint_console"%d min. = %s",  get_user_timeigrac) / 60 TotalnoVremeigrac ], name )
    }
    
client_printidprint_console"^nTrenutno vreme: %s^n----------"ctime )
    
client_cmdid"toggleconsole" )
    return 
PLUGIN_HANDLED
}
public 
client_putinserverid )
{
    if( 
is_user_adminid ) )
    {
        
TotalnoVremeid ] = UcitajVremeid )
    }
}
public 
client_disconnectid )
{
    if( 
is_user_adminid ) )
    {
        
TotalnoVremeid ] = TotalnoVremeid ] + ( get_user_timeid) / 60 )
        
SnimiVremeidTotalnoVremeid ] )
    }
}

public 
UcitajVremeid 
{
    new 
vaultkey64 ], vaultdata64 ]
    
    
get_user_name(idname32)
    
    
formatvaultkey63"%sVreme"name )
    
    
nvault_get(g_Vaultvaultkeyvaultdata63)
    
nvault_close(g_Vault)
    
    return 
str_to_numvaultdata )
}
public 
SnimiVreme(idTotalnoVreme )
{
    new 
vaultkey64 ], vaultdata64 ]
    
    
get_user_nameidname32 )
    
    
formatvaultkey63"%sVreme"name )
    
formatvaultdata63"%d"TotalnoVreme )
    
    
nvault_setg_Vaultvaultkeyvaultdata )
    
nvault_closeg_Vault )

ps:i get this is 'Odigrano-Vreme':
Code:
TLVn 
JocAnis is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-22-2011 , 10:36   Re: Need help about nVault
Reply With Quote #2

Remove the nvault_close() calls except for at plugin_end().

Also, it would be better to save it as seconds, and then calculate to minutes when displaying it.
This would make it more accurate for those leftover seconds that weren't part of a full minute.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 06-22-2011 , 16:14   Re: Need help about nVault
Reply With Quote #3

i tested that with one player (me = admin) and it works, thanks, now, i m going to test with 5+..

Last edited by JocAnis; 06-22-2011 at 16:18.
JocAnis is offline
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 01:09.


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