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

Saving On Hand Money / Bank Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lobopack23
Senior Member
Join Date: Jun 2009
Location: California , United Stat
Old 08-11-2013 , 04:52   Saving On Hand Money / Bank Problem
Reply With Quote #1

I am having a problem with a saving on hand money plugin that bugsy posted a while back

*mp_startmoney set to 800

If a user disconnects with 16000, and reconnects back to the server, his money is restored back to 16000, which is correct.

The problem occurs when someone joins the server, and another person joins. (Game Will Start In 3.2.1 is initialized) and when that happens the money that was loaded, disappears and you get whatever mp_startmoney is set to (16000 becomes 800).

Plugin (Restore Money by Bugsy):
Code:
#include <amxmodx>
#include <cstrike>
#include <nvault>
#include <fakemeta>
#include <hamsandwich>

const OFFSET_CSMONEY = 115;

new g_szAuthID[33][35];
new g_iMoney[33];
new g_Vault;
new g_pStartMoney;
new bool:g_bRestored[33];    

public plugin_init()
{
    register_plugin("Restore Money" , "0.1" , "bugsy");
    RegisterHam(Ham_Spawn , "player" , "fw_HamSpawn_Post" , 1);

    g_pStartMoney = get_cvar_pointer("MP_STARTMONEY");
    g_Vault = nvault_open("LoadMoney");
}

public plugin_end()
{
    nvault_close(g_Vault);
}

public client_authorized(id)
{
    get_user_authid( id , g_szAuthID[id] , charsmax( g_szAuthID[] ) );
}

public client_putinserver(id)
{
    if ( g_szAuthID[id][0] )
    {
        g_bRestored[id] = true;
        set_task( 1.0 , "LoadMoney" , id );
    }
}

public client_disconnect(id)
{
    remove_task(id);
    SaveMoney(id);
    g_szAuthID[id][0] = EOS;
}

public fw_HamSpawn_Post(id)
{
    if( ( g_szAuthID[id][0] && !g_bRestored[id] ) && is_user_alive(id) )
    {
        g_bRestored[id] = true;
        LoadMoney(id);
        }
}

public SaveMoney(id)
{  
    new szKey[39] , szData[9];
    formatex( szKey , charsmax(szKey) , "%s-SVB" , g_szAuthID[id] );
    num_to_str( get_pdata_int(id , OFFSET_CSMONEY) , szData , charsmax(szData) );
    g_bRestored[id] = false;
    nvault_set( g_Vault , szKey , szData );
}  

public LoadMoney(id)
{ 
    new szKey[39];
    formatex( szKey , charsmax(szKey) , "%s-SVB" , g_szAuthID[id] );

    if ( (g_iMoney[id] = nvault_get( g_Vault ,szKey) ) && ( g_iMoney[id] != get_pcvar_num(g_pStartMoney) ) )
    {
        cs_set_user_money( id , g_iMoney[id] );
        client_print( id , print_chat , "* Your money has been restored from a previous session: $%d" , g_iMoney[id] );
    }
}
__________________
- Steam: Lobopack23 - Link
Contact me if you need any help with Pokemod.
- 2nd Generation Pokemod - Link
(new skills, items, and pokemons)
- Buy Xp - Link

Last edited by lobopack23; 08-11-2013 at 14:47.
lobopack23 is offline
Old 08-22-2013, 04:37
lobopack23
This message has been deleted by YamiKaitou. Reason: wait 14 days before you bump
lobopack23
Senior Member
Join Date: Jun 2009
Location: California , United Stat
Old 08-27-2013 , 19:02   Re: Saving On Hand Money / Bank Problem
Reply With Quote #2

bump -.-
__________________
- Steam: Lobopack23 - Link
Contact me if you need any help with Pokemod.
- 2nd Generation Pokemod - Link
(new skills, items, and pokemons)
- Buy Xp - Link
lobopack23 is offline
Clauu
Senior Member
Join Date: Feb 2008
Location: RO
Old 08-27-2013 , 19:21   Re: Saving On Hand Money / Bank Problem
Reply With Quote #3

You have to add the new game event and then force load money from saved data, maybe someone more experienced in global events can help you giving the right register_event.
Clauu is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 08-27-2013 , 20:57   Re: Saving On Hand Money / Bank Problem
Reply With Quote #4

Try This:
Attached Files
File Type: sma Get Plugin or Get Source (Restore-Money.sma - 554 views - 2.3 KB)
__________________
Blizzard_87 is offline
lobopack23
Senior Member
Join Date: Jun 2009
Location: California , United Stat
Old 08-30-2013 , 12:55   Re: Saving On Hand Money / Bank Problem
Reply With Quote #5

I believe it doesn't work, i still need to do further testing..kinda hard finding time especially when like at school the whole day -.-
__________________
- Steam: Lobopack23 - Link
Contact me if you need any help with Pokemod.
- 2nd Generation Pokemod - Link
(new skills, items, and pokemons)
- Buy Xp - Link
lobopack23 is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 08-30-2013 , 15:50   Re: Saving On Hand Money / Bank Problem
Reply With Quote #6

Haven't looked into the code, but from what you are saying, just save in round restart event with global array, also add global that will show round is retarting, then in HLTV event check that global and set that money from array.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-30-2013 , 16:25   Re: Saving On Hand Money / Bank Problem
Reply With Quote #7

Easiest fix. Not tested.

Code:
#include <amxmodx> #include <cstrike> #include <nvault> #include <fakemeta> #include <hamsandwich> const OFFSET_CSMONEY = 115; new g_szAuthID[33][35]; new g_iMoney[33]; new g_Vault; new g_pStartMoney; new bool:g_bRestored[33]; public plugin_init() {     register_plugin("Restore Money" , "0.1" , "bugsy/blizzard");     RegisterHam(Ham_Spawn , "player" , "fw_HamSpawn_Post" , 1);     register_logevent("GameCommencing", 2, "1=Game_Commencing");         g_pStartMoney = get_cvar_pointer("MP_STARTMONEY");     g_Vault = nvault_open("LoadMoney"); } public plugin_end() {     nvault_close(g_Vault); } public client_authorized(id) {     get_user_authid( id , g_szAuthID[id] , charsmax( g_szAuthID[] ) ); } public client_putinserver(id) {     if ( g_szAuthID[id][0] )     {         g_bRestored[id] = true;         set_task( 1.0 , "LoadMoney" , id );     } } public client_disconnect(id) {     remove_task(id);     SaveMoney(id);     g_szAuthID[id][0] = EOS; } public fw_HamSpawn_Post(id) {     if( ( g_szAuthID[id][0] && !g_bRestored[id] ) && is_user_alive(id) )     {         g_bRestored[id] = true;         LoadMoney(id);     } } public GameCommencing( ) {     new iPlayers[32], iNum, i, Players;     get_players( iPlayers, iNum, "h");     for( i = 0; i < iNum; i++ ) {         Players = iPlayers[i];         if ( g_bRestored[Players] ) {             SaveMoney(Players);             g_bRestored[Players] = false;         }     } } public SaveMoney(id) {     new szKey[39] , szData[9];     formatex( szKey , charsmax(szKey) , "%s-SVB" , g_szAuthID[id] );     num_to_str( get_pdata_int(id , OFFSET_CSMONEY) , szData , charsmax(szData) );     g_bRestored[id] = false;     nvault_set( g_Vault , szKey , szData ); } public LoadMoney(id) {     new szKey[39];     formatex( szKey , charsmax(szKey) , "%s-SVB" , g_szAuthID[id] );         if ( (g_iMoney[id] = nvault_get( g_Vault ,szKey) ) && ( g_iMoney[id] != get_pcvar_num(g_pStartMoney) ) )     {         cs_set_user_money( id , g_iMoney[id] );         client_print( id , print_chat , "* Your money has been restored from a previous session: $%d" , g_iMoney[id] );     } }
__________________

Last edited by Black Rose; 08-30-2013 at 16:33.
Black Rose 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 11:30.


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