Raised This Month: $51 Target: $400
 12% 

Save Money


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
-Acid-
Senior Member
Join Date: Feb 2009
Old 06-24-2009 , 17:58   Save Money
Reply With Quote #1

Will this work?
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <cstrike>

new g_szAuthID[33][33];
new 
g_iBot[33];
new 
g_iMoney[33];
new 
g_pEnabled;
new 
g_iVault;
new const 
g_szVaultFile[] = "Save_Money";

public 
plugin_init()
{
    
register_plugin"Save_money" "1.0" "-Acid-" );
    
g_pEnabled register_cvar"sm_enabled" "1" );
    
    
}

public 
plugin_cfg()
{
    
g_iVault nvault_openg_szVaultFile );
    
    if ( 
g_iVault == INVALID_HANDLE )
        
set_fail_state"Error opening nVault" );
}

public 
plugin_end()
{
    
nvault_closeg_iVault );
}

public 
client_putinserverid )
{
    if ( !
get_pcvar_numg_pEnabled ) )
        return 
PLUGIN_CONTINUE;
    
    
g_iBotid ] = is_user_botid );
    
    if ( !
g_iBotid ] )
    {
        
get_user_authidid g_szAuthIDid ] , 32 );
        
        new 
iMoney nvault_getg_iVault g_szAuthIDid ] );
        
        if ( 
iMoney )
        {
            
g_iMoneyid ] = iMoney;
            
cs_set_user_moneyid iMoney );
        }
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
client_disconnectid )
{
    if ( !
get_pcvar_numg_pEnabled ) )
        return 
PLUGIN_CONTINUE;
    
    if ( !
g_iBotid ] && g_iMoneyid ] )
    {
        new 
szMoney];
        
num_to_strg_iMoney[id] , szMoney );
        
        
nvault_setg_iVault g_szAuthIDid ] , szMoney );
    }
    
    
g_iMoneyid ] = 0;
    
g_iBotid ] = 0;
    
    return 
PLUGIN_CONTINUE;


Save a players money
__________________
-Acid- is offline
shadow.hk
Senior Member
Join Date: Dec 2008
Location: WA, Australia
Old 06-24-2009 , 23:38   Re: Save Money
Reply With Quote #2

I'm sure there's a tutorial that does exactly this, why don't you search for it, nvault by bugsy, if i recall correctly.

http://forums.alliedmods.net/showthread.php?t=91503

Saves score and money.
shadow.hk is offline
Send a message via MSN to shadow.hk
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-25-2009 , 00:17   Re: Save Money
Reply With Quote #3

You never save the players current money so there's no way for a vault entry to ever exist for a player. I would hook the Money event to keep g_iMoney[] updated with the users current money at all times.

PHP Code:
register_event"Money" "fw_EvMoney" "be" );

public 
fw_EvMoneyid )
{
    
g_iMoneyid ] = read_data);

Also, you sometimes may run into issues when you try to set things on players @ putinserver. You may need to set_task the money restore with an interval of 0.1 to 0.4. Try it first though as-is because it may work, I've never tried to set a users money at putinserver.
__________________
Bugsy is offline
-Acid-
Senior Member
Join Date: Feb 2009
Old 06-25-2009 , 01:07   Re: Save Money
Reply With Quote #4

KK cool bugsy thnx
__________________
-Acid- is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-25-2009 , 15:03   Re: Save Money
Reply With Quote #5

Quote:
Originally Posted by -Acid- View Post
Will this work?
Why would you ask such a question instead of testing it yourself?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Old 07-02-2011, 03:07
r0ck
This message has been deleted by xPaw.
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 15:22.


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