Raised This Month: $ Target: $400
 0% 

[CS:S/CS:GO] CSS Bank (including MySQL support) v1.6.6


Post New Thread Reply   
 
Thread Tools Display Modes
rautamiekka
Veteran Member
Join Date: Jan 2009
Location: Finland
Old 10-17-2010 , 01:42   Re: CSS Bank (including MySQL support)
Reply With Quote #121

I came to idea that possibilities of accidently erasing money could be well avoided if the Plugin cached present Players' money info (because same ID can only be in one Server (of similar Engines) at once, there won't be mistakes) from database and uploads new after changing the cached info, instead of uploading new straight away this way it does now (although MySQL should (and seems) to add/subtract the current money to/from the one already in database).

To put it simply:
1) Cache the info from database by present Players' Steam ID (again because same ID can only be in one Server (of similar Engines) at once, there won't be mistakes)
2) Add/subtract the current money to/from the downloaded information
3) Upload (& commit) the new information. We now have the same info in database and cached on Server.
*) Upon a Player leaving, drop his information from the Server (because his information is already in database)
*) Upon an non-banned Player joins, cache his information

The sourcecode and the database told me that even bots are added into the database, which is more or less wasting of resources.
__________________
Links to posts I received Karma from:
Big thanks to all who gave Karma

Last edited by rautamiekka; 10-17-2010 at 03:22. Reason: Improved the idea
rautamiekka is offline
Send a message via ICQ to rautamiekka Send a message via AIM to rautamiekka Send a message via MSN to rautamiekka Send a message via Yahoo to rautamiekka Send a message via Skype™ to rautamiekka
Miraculix
Senior Member
Join Date: Dec 2009
Location: Germany
Old 10-19-2010 , 13:38   Re: CSS Bank (including MySQL support)
Reply With Quote #122

Sorry for the late reply

1. At first you can try to change
Code:
new bool:DebugMode = false;
to
Code:
new bool:DebugMode = true;
in the source to get more information in the logs. Especially to the querys.

2. A player's money is cached on the server and stored after every modification to the db. Its a decision to make it more stable to sudden crashes or similar. Instead of only store at player disconnect and/or mapchange.

3. Bots shouldn't appear in the db.
__________________
greeetz Miraculix ;-)
Miraculix is offline
rautamiekka
Veteran Member
Join Date: Jan 2009
Location: Finland
Old 10-20-2010 , 06:01   Re: CSS Bank (including MySQL support)
Reply With Quote #123

To stop needless SQL traffic done by bots, I replaced
Code:
SaveClientInfo(client)
{
    new String:MysqlQuery[512], String:Name[MAX_NAME_LENGTH+1];
    new String:SafeName[(sizeof(Name)*2)+1];
    
    if(!GetClientName( client, Name, sizeof(Name)))
        Format(SafeName, sizeof(SafeName), "<noname>");
    else
    {
        TrimString(Name);
        SQL_EscapeString(db, Name, SafeName, sizeof(SafeName));
    }

    if(DBid[client] < 1)
    {
        new String:AuthStr[32];
        if(!GetClientAuthString(client, AuthStr, sizeof(AuthStr)))
            return;
        Format(MysqlQuery, sizeof(MysqlQuery), "UPDATE css_bank SET amount = %d, auto_deposit = %d, auto_withdraw = %d, plugin_message = %d, player_name = '%s', hide_rank = %d WHERE steam_id = '%s';", BankMoney[client], AutoDeposit[client], AutoWithdraw[client], PlugMes[client], SafeName, HideRank[client], AuthStr);

        if(DebugMode)
            LogMessage("[%s]: %s", cvplugin_name, MysqlQuery);
    }
    else
    {
        Format(MysqlQuery, sizeof(MysqlQuery), "UPDATE css_bank SET amount = %d, auto_deposit = %d, auto_withdraw = %d, plugin_message = %d, player_name = '%s', hide_rank = %d WHERE id = %d;", BankMoney[client], AutoDeposit[client], AutoWithdraw[client], PlugMes[client], SafeName, HideRank[client], DBid[client]);

        if(DebugMode)
            LogMessage("[%s]: %s", cvplugin_name, MysqlQuery);
    }
    
    if (!SQL_FastQuery(db, MysqlQuery))
    {
        new String:error2[255];
        SQL_GetError(db, error2, sizeof(error2));
        LogError("[%s] Query failure: %s", cvplugin_name, error2);
        LogError("[%s] Query: %s", cvplugin_name, MysqlQuery);
    }
}
with
Code:
SaveClientInfo(client)
{
    new String:MysqlQuery[512], String:Name[MAX_NAME_LENGTH+1];
    new String:SafeName[(sizeof(Name)*2)+1];
    
    if(!GetClientName( client, Name, sizeof(Name)))
        Format(SafeName, sizeof(SafeName), "<noname>");
    else
    {
        TrimString(Name);
        SQL_EscapeString(db, Name, SafeName, sizeof(SafeName));
    }

    if(DBid[client] < 1)
    {
        new String:AuthStr[32];
        if(!GetClientAuthString(client, AuthStr, sizeof(AuthStr)))
            return;

        if(!IsFakeClient(client)){
            Format(MysqlQuery, sizeof(MysqlQuery), "UPDATE css_bank SET amount = %d, auto_deposit = %d, auto_withdraw = %d, plugin_message = %d, player_name = '%s', hide_rank = %d WHERE steam_id = '%s';", BankMoney[client], AutoDeposit[client], AutoWithdraw[client], PlugMes[client], SafeName, HideRank[client], AuthStr);

            if(DebugMode)
                LogMessage("[%s]: %s", cvplugin_name, MysqlQuery);
        }
    }
    else
    {
        if(!IsFakeClient(client)){
            Format(MysqlQuery, sizeof(MysqlQuery), "UPDATE css_bank SET amount = %d, auto_deposit = %d, auto_withdraw = %d, plugin_message = %d, player_name = '%s', hide_rank = %d WHERE id = %d;", BankMoney[client], AutoDeposit[client], AutoWithdraw[client], PlugMes[client], SafeName, HideRank[client], DBid[client]);

            if(DebugMode)
                LogMessage("[%s]: %s", cvplugin_name, MysqlQuery);
        }
    }
    
    if (!SQL_FastQuery(db, MysqlQuery))
    {
        new String:error2[255];
        SQL_GetError(db, error2, sizeof(error2));
        LogError("[%s] Query failure: %s", cvplugin_name, error2);
        LogError("[%s] Query: %s", cvplugin_name, MysqlQuery);
    }
}
The modified Plugin is in the attachments below.
Attached Files
File Type: sp Get Plugin or Get Source (cssbank--edited0.sp - 349 views - 59.4 KB)
__________________
Links to posts I received Karma from:
Big thanks to all who gave Karma
rautamiekka is offline
Send a message via ICQ to rautamiekka Send a message via AIM to rautamiekka Send a message via MSN to rautamiekka Send a message via Yahoo to rautamiekka Send a message via Skype™ to rautamiekka
rautamiekka
Veteran Member
Join Date: Jan 2009
Location: Finland
Old 11-04-2010 , 15:44   Re: CSS Bank (including MySQL support)
Reply With Quote #124

Feature requests:
1) toggle auto-setting (defaulting to disabled)
- auto-deposit
and/or
- auto-withdraw
to 0-16k for new Players.

2) toggle auto-purging bank of Players (defaulting to disabled) with
- money=0
- auto-deposit=0
- auto-withdraw=0
- plugin message=1
, in configurable interval defaulting to one month.

3) Possibly an alternative for #2, once in a week (defaulting to disabled) check up is any of the bank's Steam IDs banned. After going through the bank, share the banneds' money with non-banneds and delete the banneds.
__________________
Links to posts I received Karma from:
Big thanks to all who gave Karma

Last edited by rautamiekka; 11-04-2010 at 16:31. Reason: 1) Removed 'plugin message'; 2) Put "plugin message=1", add #3.
rautamiekka is offline
Send a message via ICQ to rautamiekka Send a message via AIM to rautamiekka Send a message via MSN to rautamiekka Send a message via Yahoo to rautamiekka Send a message via Skype™ to rautamiekka
rautamiekka
Veteran Member
Join Date: Jan 2009
Location: Finland
Old 11-04-2010 , 16:32   Re: CSS Bank (including MySQL support)
Reply With Quote #125

[Improved the request one post behind]
__________________
Links to posts I received Karma from:
Big thanks to all who gave Karma
rautamiekka is offline
Send a message via ICQ to rautamiekka Send a message via AIM to rautamiekka Send a message via MSN to rautamiekka Send a message via Yahoo to rautamiekka Send a message via Skype™ to rautamiekka
UncLeMax
New Member
Join Date: Nov 2010
Location: Russian Federation
Old 11-05-2010 , 09:55   Re: CSS Bank (including MySQL support)
Reply With Quote #126

Good plugin, thank you all works fine. Translated into Russian who needed.

cssbank.phrases.txt

Last edited by UncLeMax; 11-05-2010 at 09:58.
UncLeMax is offline
Send a message via Skype™ to UncLeMax
rautamiekka
Veteran Member
Join Date: Jan 2009
Location: Finland
Old 11-06-2010 , 12:08   Re: CSS Bank (including MySQL support)
Reply With Quote #127

Feature request: allow handling of more than 16k money everywhere, primarily in
- Bank Admin; an live example: one Player lost his 5 million for any reason. To add them to his acc', you have to transfer 312½ times the 16k.
- money transfer; an live example: you want to give a Player 100k money for any reason. To give them to him, you have to transfer 6.25 times the 16k.

DETAIL TO THE REQUEST: If you choose to deposit or otherwise handle more than 16k (the max of cash one can carry), naturally it's handled silently as if you chose 16k just like you used "deposit all".


Another thing: when you {un|re}load the Plugin, the ones connected lose their deposited money. This, in my mind, would be avoided if the Plugin uploads+verifies the uploaded information before {un|re}loading. It sounds to me like the Plugin uploads zero information upon {un|re}loading.
__________________
Links to posts I received Karma from:
Big thanks to all who gave Karma
rautamiekka is offline
Send a message via ICQ to rautamiekka Send a message via AIM to rautamiekka Send a message via MSN to rautamiekka Send a message via Yahoo to rautamiekka Send a message via Skype™ to rautamiekka
Miraculix
Senior Member
Join Date: Dec 2009
Location: Germany
Old 11-06-2010 , 17:35   Re: CSS Bank (including MySQL support)
Reply With Quote #128

I will think about your requests. Especially the last sounds good.
But at the time I have no time.
And to do/check sth. at stated intervals will not be practicable.

To your "another thing": You shouldn't lost any data at re/un-loading the plugin or mapchange or server-crash or sth. else. Everything is stored in realtime.
e.g.: If someone deposit sth. it's stored after input and need no storage once more at un/re-loading.
__________________
greeetz Miraculix ;-)
Miraculix is offline
nismoskyline86
Member
Join Date: Nov 2010
Old 11-20-2010 , 21:02   Re: CSS Bank (including MySQL support)
Reply With Quote #129

Is there a way to make this plugin exclusive to donating members? perhaps only members with a particular admin flag have access to the bank and everyone else that trys to use it gets a message stating "The Bank Feature is only available to VIP members! find out how to become a VIP at www.site.com"
nismoskyline86 is offline
uspgrade
New Member
Join Date: Nov 2010
Location: United States
Old 11-23-2010 , 00:08   Re: CSS Bank (including MySQL support)
Reply With Quote #130

This is a really great and useful plugin for sure. First, thanks so much Miraculix! I think I have it all working... I'm running a wcs server from my home connection.

I have a couple requests...
When I'm the only one online, the bank will not let me deposit money... this can be a very good thing. However, is there a way I can modify this so when only I, the head administrator, am on I can use and deposit to the bank.

I would honestly just be real grateful if that is easily enough done.

My other inquery is... can donators/non-donators be separated into two groups... letting donators have a higher bank limit for instance? Which I suppose this is somewhat similar to nismoskyline86's post... just making them different in another way.

Last edited by uspgrade; 11-23-2010 at 00:09. Reason: add a correction
uspgrade 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:08.


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