mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-10-20 00:00:39 +00:00
Added some more helper functions
This commit is contained in:
parent
ad0449da87
commit
755f481421
6 changed files with 56 additions and 22 deletions
Binary file not shown.
|
|
@ -17,56 +17,48 @@ def balance_call(userid : str, clientid : int):
|
|||
users = get_bank_data()
|
||||
name = client_to_name(clientid)
|
||||
|
||||
cash_amt = users[str(userid)]["cash"]
|
||||
bank_cash_amt = users[str(userid)]["bank_cash"]
|
||||
bank_space = users[str(userid)]["bank_space"]
|
||||
PlayerData = get_player_data(userid)
|
||||
|
||||
balance = CLstr("English", "balance").format(str(name), str(cash_amt), str(bank_cash_amt), str(bank_space))
|
||||
balance = CLstr("English", "balance").format(str(name), str(PlayerData[0]), str(PlayerData[1]), str(PlayerData[2]))
|
||||
send(balance, clientid)
|
||||
|
||||
|
||||
|
||||
|
||||
def beg_call(userid : str, clientid : int):
|
||||
open_account(userid)
|
||||
earned = get_random_cash()
|
||||
|
||||
users = get_bank_data()
|
||||
|
||||
users[str(userid)]["cash"] += earned
|
||||
cash = users[str(userid)]["cash"]
|
||||
update_bank(userid, earned, "cash", type_only=True)
|
||||
cash = get_player_data(userid)[0]
|
||||
donator = get_random_donator()
|
||||
|
||||
send(CLstr("English", "beg").format(donator, earned, cash), clientid)
|
||||
commit(users)
|
||||
|
||||
|
||||
|
||||
|
||||
def withdraw_call(userid : str, args : int, clientid : int):
|
||||
open_account(userid)
|
||||
|
||||
users = get_bank_data()
|
||||
withd = int(args[0])
|
||||
|
||||
if cheack_withd(userid, withd, clientid):
|
||||
return
|
||||
|
||||
users[str(userid)]["cash"] += withd
|
||||
users[str(userid)]["bank_cash"] -= withd
|
||||
commit(users)
|
||||
update_bank(userid, withd)
|
||||
|
||||
send(CLstr("English", "withdraw").format(withd), clientid)
|
||||
|
||||
|
||||
|
||||
|
||||
def deposit_call(userid : str, args : int, clientid : int):
|
||||
open_account(userid)
|
||||
|
||||
users = get_bank_data()
|
||||
dep = int(args[0])
|
||||
|
||||
if cheack_cash_and_space(userid, dep, clientid):
|
||||
return
|
||||
|
||||
users[str(userid)]["cash"] -= dep
|
||||
users[str(userid)]["bank_cash"] += dep
|
||||
commit(users)
|
||||
update_bank(userid, dep, "bank")
|
||||
|
||||
send(CLstr("English", "deposit").format(dep), clientid)
|
||||
4
dist/ba_root/mods/Currency/Data/bank.json
vendored
4
dist/ba_root/mods/Currency/Data/bank.json
vendored
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"None": {
|
||||
"cash": 2620,
|
||||
"cash": 3402,
|
||||
"bank_space": 100,
|
||||
"bank_cash": 0
|
||||
"bank_cash": 10
|
||||
},
|
||||
"pb-IF4VAk4a": {
|
||||
"cash": 0,
|
||||
|
|
|
|||
3
dist/ba_root/mods/Currency/Data/textes.json
vendored
3
dist/ba_root/mods/Currency/Data/textes.json
vendored
|
|
@ -3,7 +3,8 @@
|
|||
"errors":{
|
||||
"short_space":"You don't have that much space",
|
||||
"short_ammount":"You don't have that much cash",
|
||||
"short_bank_cash":"you don't have that much money in bank"
|
||||
"short_bank_cash":"you don't have that much money in bank",
|
||||
"bank_space_error":"get space in bank first"
|
||||
},
|
||||
"balance": "|| {} | Cash - {} | Bank- {}/{} ||",
|
||||
"beg":"{} gave you {} now you have {} coins",
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -14,6 +14,19 @@ def get_bank_data():
|
|||
|
||||
|
||||
|
||||
def get_player_data(accountid : str):
|
||||
users = get_bank_data()
|
||||
|
||||
cash = users[str(accountid)]["cash"]
|
||||
bank_space = users[str(accountid)]["bank_space"]
|
||||
bank_cash = users[str(accountid)]["bank_cash"]
|
||||
|
||||
PlayerData = cash, bank_cash, bank_space
|
||||
|
||||
return PlayerData
|
||||
|
||||
|
||||
|
||||
def commit(data):
|
||||
with open(bank_path, "w") as f:
|
||||
json.dump(data, f, indent=2)
|
||||
|
|
@ -35,17 +48,45 @@ def open_account(accountid : str):
|
|||
|
||||
|
||||
|
||||
def update_bank(userid, ammount : int=0, type="cash", type_only=False):
|
||||
users = get_bank_data()
|
||||
|
||||
if type == "cash":
|
||||
users[str(userid)]["cash"] += ammount
|
||||
if type_only:
|
||||
commit(users)
|
||||
return
|
||||
users[str(userid)]["bank_cash"] -= ammount
|
||||
|
||||
commit(users)
|
||||
|
||||
if type == "bank":
|
||||
users[str(userid)]["cash"] -= ammount
|
||||
if type_only:
|
||||
commit(users)
|
||||
return
|
||||
users[str(userid)]["bank_cash"] += ammount
|
||||
|
||||
commit(users)
|
||||
|
||||
|
||||
|
||||
def cheack_cash_and_space(userid, ammount : int, clientid : int):
|
||||
users = get_bank_data()
|
||||
|
||||
cash_amt = users[str(userid)]["cash"]
|
||||
bank_cash = users[str(userid)]["bank_cash"]
|
||||
bank_space = users[str(userid)]["bank_space"]
|
||||
|
||||
|
||||
if bank_space < ammount:
|
||||
send(Errorstr("English", "short_space"), clientid)
|
||||
return True
|
||||
|
||||
if bank_space < bank_cash + ammount:
|
||||
send(Errorstr("English", "bank_space_error"), clientid)
|
||||
return True
|
||||
|
||||
if cash_amt < ammount:
|
||||
send(Errorstr("English", "short_ammount"), clientid)
|
||||
return True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue