AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   New Plugin Submissions (https://forums.alliedmods.net/forumdisplay.php?f=26)
-   -   Bank System Nvault/SQL Support (https://forums.alliedmods.net/showthread.php?t=327200)

Supremache 09-05-2020 13:50

Bank System Nvault/SQL Support
 
6 Attachment(s)
Bank System 2.0
Release: September, 05, 2020 | Last Update: April, 15, 2022

Table of Contents

Description top

The plugin adds save players money in the form of the bank.

1.Bank System features:
  • Deposit (Save Cash).
  • Deposit All (Save All Cash).
  • Withdraw (Take Cash).
  • Withdraw All (Take All Cash).
  • Bank balance (Check how much cash you have in your bank).
  • Donate Cash (Transforming cashs).
  • Reset Bank (Opens a menu that shows online players for reset bank).
Images top


Installation top

To install the plugin:
  1. Download the zip file..
  2. Put BankSystem.ini in cstrike/addons/amxmodx/confings
  3. Open addons/amxmodx/configs/plugins.ini and add at the end of this file BankSystem.amxx
  4. Restart the server/change map.

To compile locally:

Credits top
Using this plugin with other currencies top

The plugin also has the option to use native plugins in place of money. In simple words - you can make this plugin work with Ammo Packs, BaseBuilder Credits, JBPacks and more. To do this, you need to edit the following lines (11/12):
Spoiler


ChangeLog top
  • V 1.0 ( September, 05,2020 ):
    • Initial release.
  • V 1.1 ( September, 09,2020 ):
    • Fixed some codes.
    • Added bank system.
    • Added doante money from bank to bank.
  • V 1.2 ( September, 10,2020 ):
    • Added time presents.
  • V 1.3 ( September, 10,2020 ):
    • Edited Codes to use native plugins in place of money, You can make this plugin work with Ammo Packs, BaseBuilder Credits, JBPacks and Other's.
  • V 1.4 ( September, 14,2020 ):
    • Fixed Some codes.
    • Added Lang file.
    • Added CFG file.
    • Transformed define's to cvar's
  • V 1.5 ( September, 16,2020 ):
    • Edited Some codes.
  • V 1.6 ( October, 10,2020 ):
    • Code cleaned.
    • New cvar's for enable/disable options.
    • Used CromChat.
  • V 1.7 ( August, 8, 2021 ):
    • Plugin Remaded.
    • Code Optimized.
    • Add SQL support.
    • Add ini file.
    • Removed GIVE/TAKE/TIMEPRESENT became as bank.
    • Added Natives get_user_bank_cash.
    • Added Natives set_user_bank_cash.
  • V 1.8 ( February, 08, 2022 ):
    • Code Optimized.
    • Natives has been edited to get_user_bank & set_user_bank.
  • V 1.9 ( February, 11, 2022 ):
    • Added an option to to select MySql or Sqlite.
    • Added an option to name nvault.
  • V 2.0 ( April, 15, 2022 ):
    • Added option to save SQL date using IP, name.
Downloads top
  • Need to download CromChat file to compile this plugin.

HowToRuski 09-05-2020 14:29

Re: Money System [Donate | Give | Take]
 
Thanks, works great :)

Supremache 09-05-2020 14:41

Re: Money System [Donate | Give | Take]
 
Quote:

Originally Posted by HowToRuski (Post 2716793)
Thanks, works great :)

Enjoy, I will try to add bank system to this plugin when i do new updates

Shadows Adi 09-05-2020 16:09

Re: Money System [Donate | Give | Take]
 
Some optimization:
1.
Code:

client_print(id, print_console
-->>
console_print()

Code:

sizeof() -1 ???
->>
charsmax()

Code:
format(filename, sizeof(filename) - 1, "%s/MoneySystem_%s.log", dir, filename); -->> static log_file[64]; formatex(log_file, charsmax(log_file), "%s/MoneySystem_%s.log", dir, filename); /* Much faster than what format() can do */ log_to_file(log_file, "%s", message);

stock ChatColor /* ???? client_print_color() */

And you can get the name of player in a global var ( or a hash map ). When he's connecting you retrive his name and use it instead of this:
Code:

get_user_name( id, ... )
get_user_name( iTarget, ... )

Same thing with the steamid :)

Supremache 09-05-2020 16:53

Re: Money System [Donate | Give | Take]
 
Quote:

Originally Posted by Shadows Adi (Post 2716810)
Some optimization:
1.
Code:

client_print(id, print_console
-->>
console_print()

Code:

sizeof() -1 ???
->>
charsmax()

Code:
format(filename, sizeof(filename) - 1, "%s/MoneySystem_%s.log", dir, filename); -->> static log_file[64]; formatex(log_file, charsmax(log_file), "%s/MoneySystem_%s.log", dir, filename); /* Much faster than what format() can do */ log_to_file(log_file, "%s", message);

stock ChatColor /* ???? client_print_color() */

And you can get the name of player in a global var ( or a hash map ). When he's connecting you retrive his name and use it instead of this:
Code:

get_user_name( id, ... )
get_user_name( iTarget, ... )

Same thing with the steamid :)

Thx i understand you, But client_print_color() working only for amxmodx 1.8.3 so i can't use it because i want my plugin working on all versions and thanks and again i will edit all that when i add new updates

Natsheh 09-06-2020 21:10

Re: Money System [Donate | Give | Take]
 
Quote:

Originally Posted by Supremache (Post 2716816)
Thx i understand you, But client_print_color() working only for amxmodx 1.8.3 so i can't use it because i want my plugin working on all versions and thanks and again i will edit all that when i add new updates

He never mentioned client_print_color

Supremache 09-07-2020 08:06

Re: Money System [Donate | Give | Take]
 
Quote:

Originally Posted by Natsheh (Post 2716978)
He never mentioned client_print_color

Check it again, i think he mean, why i used stock chatcolor and there's client_print_color for amxmodx

Quote:

stock ChatColor /* ???? client_print_color() */

iceeedr 09-08-2020 10:57

Re: Money System [Donate | Give | Take]
 
Using amx 1.9> you can do something like:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
 
#define PLUGIN "Money Donate"
#define VERSION "1.0"
#define AUTOR "iceeedR"

new const Prefix[] = "Allied Donators"
new DonateTarget[MAX_PLAYERS +1]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTOR);
    
register_clcmd("say /donate""DonateCmd")
    
register_clcmd("plugin_donate""DonateHandler")
}
 
public 
client_disconnected(id)
{
    
DonateTarget[id] = -// just for secure
}

public 
client_putinserver(id)
{
    
DonateTarget[id] = -// just for secure
}

public 
DonateCmd(id)
{
    new 
iMenu menu_create(fmt("\y[\w%s\d - \rDonate Menu \y ]"Prefix), "donate_handler")

    new 
iPlayers[MAX_PLAYERS], iNum
    get_players_ex
(iPlayersiNumGetPlayers_MatchTeam, (cs_get_user_team(id) == CS_TEAM_T) ? "TERRORIST" "CT")
    for(new 
iszTempid[10], iPlayer;iNum;i++)
    {
        
iPlayer iPlayers[i]

        if(
iPlayer != id)
        {
            
num_to_str(iPlayerszTempidcharsmax(szTempid))

            
menu_additem(iMenufmt("%n"iPlayer), szTempid)
        }
    }
    
    
menu_display(idiMenu)
    return 
PLUGIN_HANDLED
}

public 
donate_handler(idiMenuiItem)
{
    if(
iItem == MENU_EXIT)
    {
        
menu_destroy(iMenu)
        return 
PLUGIN_HANDLED
    
}
    new 
iData[6], szItemName[MAX_PLAYERS 2], iAccessiCallback
    menu_item_getinfo
(iMenuiItemiAccessiDatacharsmax(iData), szItemNamecharsmax(szItemName), iCallback)
    
    
DonateTarget[id] = str_to_num(iData)
    
    if(!
DonateTarget[id])
    {
        
client_print_color(idprint_team_default"%s This player does not exist."Prefix)
        
menu_display(idiMenu)
        
DonateTarget[id] = -1
        
return PLUGIN_HANDLED
    
}
    
    
client_cmd(id"messagemode plugin_donate")
            
    
client_print_color(idprint_team_default"%s Type how much you want to give."Prefix)
    return 
PLUGIN_HANDLED
}

public 
DonateHandler(id)
{
    new 
iValue read_argv_int(1)
        
    new 
iPlayerMoney cs_get_user_money(id)
    
    if( 
iPlayerMoney iValue || iValue <= 0)
    {
        
client_print_color(idprint_team_default"%s You do not have enough money or invalid value."Prefix)
        return 
PLUGIN_CONTINUE
    
}
    
    
cs_set_user_moneyDonateTarget[id], cs_get_user_money(DonateTarget[id]) + iValue)
    
cs_set_user_moneyidcs_get_user_money(id) - iValue)
    
    new 
iPlayers[MAX_PLAYERS], iNum
    get_players_ex
(iPlayersiNumGetPlayers_MatchTeam, (cs_get_user_team(id) == CS_TEAM_T) ? "TERRORIST" "CT")
    for(new 
i;iNum;i++)
    {
        
client_print_color(iPlayers[i], print_team_default"%s^x04 %n^x01 donated^x04 $%i^x01 for^x04 %n."PrefixidiValueDonateTarget[id])
    }
    
client_cmd(DonateTarget[id], "spk ^"items/9mmclip1.wav^"")
    
    
DonateTarget[id] = -1
    
return PLUGIN_HANDLED



Supremache 09-08-2020 16:23

Re: Money System [Donate | Give | Take]
 
Quote:

Originally Posted by iceeedr (Post 2717154)
Using amx 1.9> you can do something like:

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
 
#define PLUGIN "Money Donate"
#define VERSION "1.0"
#define AUTOR "iceeedR"

new const Prefix[] = "Allied Donators"
new DonateTarget[MAX_PLAYERS +1]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTOR);
    
register_clcmd("say /donate""DonateCmd")
    
register_clcmd("plugin_donate""DonateHandler")
}
 
public 
client_disconnected(id)
{
    
DonateTarget[id] = -// just for secure
}

public 
client_putinserver(id)
{
    
DonateTarget[id] = -// just for secure
}

public 
DonateCmd(id)
{
    new 
iMenu menu_create(fmt("\y[\w%s\d - \rDonate Menu \y ]"Prefix), "donate_handler")

    new 
iPlayers[MAX_PLAYERS], iNum
    get_players_ex
(iPlayersiNumGetPlayers_MatchTeam, (cs_get_user_team(id) == CS_TEAM_T) ? "TERRORIST" "CT")
    for(new 
iszTempid[10], iPlayer;iNum;i++)
    {
        
iPlayer iPlayers[i]

        if(
iPlayer != id)
        {
            
num_to_str(iPlayerszTempidcharsmax(szTempid))

            
menu_additem(iMenufmt("%n"iPlayer), szTempid)
        }
    }
    
    
menu_display(idiMenu)
    return 
PLUGIN_HANDLED
}

public 
donate_handler(idiMenuiItem)
{
    if(
iItem == MENU_EXIT)
    {
        
menu_destroy(iMenu)
        return 
PLUGIN_HANDLED
    
}
    new 
iData[6], szItemName[MAX_PLAYERS 2], iAccessiCallback
    menu_item_getinfo
(iMenuiItemiAccessiDatacharsmax(iData), szItemNamecharsmax(szItemName), iCallback)
    
    
DonateTarget[id] = str_to_num(iData)
    
    if(!
DonateTarget[id])
    {
        
client_print_color(idprint_team_default"%s This player does not exist."Prefix)
        
menu_display(idiMenu)
        
DonateTarget[id] = -1
        
return PLUGIN_HANDLED
    
}
    
    
client_cmd(id"messagemode plugin_donate")
            
    
client_print_color(idprint_team_default"%s Type how much you want to give."Prefix)
    return 
PLUGIN_HANDLED
}

public 
DonateHandler(id)
{
    new 
iValue read_argv_int(1)
        
    new 
iPlayerMoney cs_get_user_money(id)
    
    if( 
iPlayerMoney iValue || iValue <= 0)
    {
        
client_print_color(idprint_team_default"%s You do not have enough money or invalid value."Prefix)
        return 
PLUGIN_CONTINUE
    
}
    
    
cs_set_user_moneyDonateTarget[id], cs_get_user_money(DonateTarget[id]) + iValue)
    
cs_set_user_moneyidcs_get_user_money(id) - iValue)
    
    new 
iPlayers[MAX_PLAYERS], iNum
    get_players_ex
(iPlayersiNumGetPlayers_MatchTeam, (cs_get_user_team(id) == CS_TEAM_T) ? "TERRORIST" "CT")
    for(new 
i;iNum;i++)
    {
        
client_print_color(iPlayers[i], print_team_default"%s^x04 %n^x01 donated^x04 $%i^x01 for^x04 %n."PrefixidiValueDonateTarget[id])
    }
    
client_cmd(DonateTarget[id], "spk ^"items/9mmclip1.wav^"")
    
    
DonateTarget[id] = -1
    
return PLUGIN_HANDLED



I can do the same but with amxmodx 1.8.x , i want my plugin working on any versions

iceeedr 09-08-2020 17:54

Re: Money System [Donate | Give | Take]
 
Quote:

Originally Posted by Supremache (Post 2717172)
I can do the same but with amxmodx 1.8.x , i want my plugin working on any versions

At no time did I say otherwise, I just left a version for amx 1.9 in case anyone wants to, if you want I delete it.


All times are GMT -4. The time now is 12:33.

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