mirror of
https://github.com/imayushsaini/Bombsquad-Ballistica-Modded-Server.git
synced 2025-10-20 00:00:39 +00:00
added some stuf
This commit is contained in:
parent
b582230e7e
commit
ad0449da87
13 changed files with 140 additions and 32 deletions
Binary file not shown.
|
|
@ -1,16 +1,17 @@
|
||||||
""" store functions executed when chat command are called """
|
""" store functions executed when chat command are called """
|
||||||
import ba, _ba, json, random
|
import ba, _ba, json, random
|
||||||
from _ba import chatmessage as send
|
|
||||||
from _ba import screenmessage as screenmsg
|
|
||||||
from Currency.Handlers.bank_handler import *
|
from Currency.Handlers.bank_handler import *
|
||||||
from Currency.Handlers.ba_get_player_data import *
|
from Currency.Handlers.ba_get_player_data import *
|
||||||
from Currency.Handlers.cooldown_manager import *
|
#from Currency.Handlers.cooldown_manager import *
|
||||||
|
from Currency.Handlers.CLstr import CLstr, Errorstr
|
||||||
from .fun import get_random_donator, get_random_cash
|
from .fun import get_random_donator, get_random_cash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def balance_call(userid, clientid):
|
|
||||||
|
def balance_call(userid : str, clientid : int):
|
||||||
open_account(userid)
|
open_account(userid)
|
||||||
|
|
||||||
users = get_bank_data()
|
users = get_bank_data()
|
||||||
|
|
@ -20,23 +21,52 @@ def balance_call(userid, clientid):
|
||||||
bank_cash_amt = users[str(userid)]["bank_cash"]
|
bank_cash_amt = users[str(userid)]["bank_cash"]
|
||||||
bank_space = users[str(userid)]["bank_space"]
|
bank_space = users[str(userid)]["bank_space"]
|
||||||
|
|
||||||
balance = '|| {} | Cash - {} | Bank- {}/{} ||'.format(str(name), str(cash_amt), str(bank_cash_amt), str(bank_space))
|
balance = CLstr("English", "balance").format(str(name), str(cash_amt), str(bank_cash_amt), str(bank_space))
|
||||||
send(balance)
|
send(balance, clientid)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def beg_call(userid):
|
def beg_call(userid : str, clientid : int):
|
||||||
open_account(userid)
|
open_account(userid)
|
||||||
earned = get_random_cash()
|
earned = get_random_cash()
|
||||||
|
|
||||||
users = get_bank_data()
|
users = get_bank_data()
|
||||||
user = users[str(userid)]
|
|
||||||
|
|
||||||
user["cash"] += earned
|
users[str(userid)]["cash"] += earned
|
||||||
cash_amt = user["cash"]
|
cash = users[str(userid)]["cash"]
|
||||||
donator = get_random_donator()
|
donator = get_random_donator()
|
||||||
send(f'{donator} gave you {earned} now you have {cash_amt} coins')
|
|
||||||
|
|
||||||
|
send(CLstr("English", "beg").format(donator, earned, cash), clientid)
|
||||||
commit(users)
|
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)
|
||||||
|
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)
|
||||||
|
send(CLstr("English", "deposit").format(dep), clientid)
|
||||||
Binary file not shown.
|
|
@ -10,4 +10,11 @@ def on_command(cmd, args, accountid, clientid):
|
||||||
balance_call(accountid, clientid)
|
balance_call(accountid, clientid)
|
||||||
|
|
||||||
elif cmd == 'beg':
|
elif cmd == 'beg':
|
||||||
beg_call(accountid)
|
beg_call(accountid, clientid)
|
||||||
|
|
||||||
|
elif cmd in ['with', 'withdraw']:
|
||||||
|
withdraw_call(accountid, args, clientid)
|
||||||
|
|
||||||
|
elif cmd in ['dep', 'deposite']:
|
||||||
|
deposit_call(accountid, args, clientid)
|
||||||
|
|
||||||
|
|
|
||||||
4
dist/ba_root/mods/Currency/Data/bank.json
vendored
4
dist/ba_root/mods/Currency/Data/bank.json
vendored
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"None": {
|
"None": {
|
||||||
"cash": 1421,
|
"cash": 2620,
|
||||||
"bank_space": 100,
|
"bank_space": 100,
|
||||||
"bank_cash": 0
|
"bank_cash": 0
|
||||||
},
|
},
|
||||||
"pb-IF4VAk4a": {
|
"pb-IF4VAk4a": {
|
||||||
"cash": 297,
|
"cash": 0,
|
||||||
"bank_space": 100,
|
"bank_space": 100,
|
||||||
"bank_cash": 0
|
"bank_cash": 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
dist/ba_root/mods/Currency/Data/textes.json
vendored
Normal file
13
dist/ba_root/mods/Currency/Data/textes.json
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"English": {
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
"balance": "|| {} | Cash - {} | Bank- {}/{} ||",
|
||||||
|
"beg":"{} gave you {} now you have {} coins",
|
||||||
|
"deposit":"deposited {}",
|
||||||
|
"withdraw": "withdrew {}"
|
||||||
|
}
|
||||||
|
}
|
||||||
18
dist/ba_root/mods/Currency/Handlers/CLstr.py
vendored
Normal file
18
dist/ba_root/mods/Currency/Handlers/CLstr.py
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import ba, _ba, json
|
||||||
|
|
||||||
|
textes_path = _ba.env()['python_directory_user']+'/Currency/Data/textes.json'
|
||||||
|
|
||||||
|
|
||||||
|
def CLstr(language, text):
|
||||||
|
with open(textes_path, 'r') as f:
|
||||||
|
textes = json.load(f)
|
||||||
|
text = textes[language][text]
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
def Errorstr(language, text):
|
||||||
|
with open(textes_path, 'r') as f:
|
||||||
|
textes = json.load(f)
|
||||||
|
t = textes[language]["errors"][text]
|
||||||
|
return t
|
||||||
|
|
||||||
BIN
dist/ba_root/mods/Currency/Handlers/__pycache__/CLstr.cpython-38.opt-1.pyc
vendored
Normal file
BIN
dist/ba_root/mods/Currency/Handlers/__pycache__/CLstr.cpython-38.opt-1.pyc
vendored
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -22,3 +22,17 @@ def client_to_display_string(client_id):
|
||||||
if i['client_id'] == client_id:
|
if i['client_id'] == client_id:
|
||||||
return i['display_string']
|
return i['display_string']
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def send(msg, clientid):
|
||||||
|
_ba.chatmessage(str(msg), clients=[clientid])
|
||||||
|
_ba.screenmessage(str(msg), transient=True, clients=[clientid])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def senderror(msg, clientid):
|
||||||
|
_ba.chatmessage(str(msg), clients=[clientid], sender_override = "Use[server]")
|
||||||
|
_ba.screenmessage("Use[server] " + str(msg), transient=True, clients=[clientid])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,12 @@
|
||||||
""" helperfunctions for save lot of lines of code """
|
""" helperfunctions for save lot of lines of code """
|
||||||
|
|
||||||
import ba, _ba, json
|
import ba, _ba, json
|
||||||
|
from .ba_get_player_data import send
|
||||||
|
from .CLstr import Errorstr
|
||||||
|
|
||||||
bank_path = _ba.env()['python_directory_user']+'/Currency/Data/bank.json'
|
bank_path = _ba.env()['python_directory_user']+'/Currency/Data/bank.json'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def open_account(accountid):
|
|
||||||
users = get_bank_data()
|
|
||||||
|
|
||||||
if str(accountid) in users:
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
users[str(accountid)] = {}
|
|
||||||
users[str(accountid)]["cash"] = 0
|
|
||||||
users[str(accountid)]["bank_space"] = 100
|
|
||||||
users[str(accountid)]["bank_cash"] = 0
|
|
||||||
commit(users)
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_bank_data():
|
def get_bank_data():
|
||||||
with open(bank_path, 'r') as f:
|
with open(bank_path, 'r') as f:
|
||||||
users = json.load(f)
|
users = json.load(f)
|
||||||
|
|
@ -36,3 +20,45 @@ def commit(data):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def open_account(accountid : str):
|
||||||
|
users = get_bank_data()
|
||||||
|
|
||||||
|
if str(accountid) in users:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
users[str(accountid)] = {}
|
||||||
|
users[str(accountid)]["cash"] = 0
|
||||||
|
users[str(accountid)]["bank_space"] = 100
|
||||||
|
users[str(accountid)]["bank_cash"] = 0
|
||||||
|
commit(users)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def cheack_cash_and_space(userid, ammount : int, clientid : int):
|
||||||
|
users = get_bank_data()
|
||||||
|
|
||||||
|
cash_amt = users[str(userid)]["cash"]
|
||||||
|
bank_space = users[str(userid)]["bank_space"]
|
||||||
|
|
||||||
|
|
||||||
|
if bank_space < ammount:
|
||||||
|
send(Errorstr("English", "short_space"), clientid)
|
||||||
|
return True
|
||||||
|
if cash_amt < ammount:
|
||||||
|
send(Errorstr("English", "short_ammount"), clientid)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def cheack_withd(userid, ammount : int, clientid : int):
|
||||||
|
users = get_bank_data()
|
||||||
|
bank_cash = users[str(userid)]["bank_cash"]
|
||||||
|
|
||||||
|
if bank_cash < ammount:
|
||||||
|
send(Errorstr("English", "short_bank_cash"), clientid)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue