Answer the question
In order to leave comments, you need to log in
What is the script error?
I am making a script that allows the user to place a bet, but there was a problem that sometimes the user is either added more than his bet, then more than his bet is removed, then it goes into a minus.
Here is the script itself:
msg = event.obj["text"].lower()
text = msg.split(' ', maxsplit=1)
if text[0] == "!ставка":
get_msg = text[1].split(" ")
get_side = get_msg[0]
get_rate = get_msg[1:]
text_rate = ' '.join(get_rate)
value_rate = re.sub(r'[^0-9.]+', r'', text_rate)
user_id = event.obj["from_id"]
sides = ["орел", "решка"]
if value_rate in "":
send("❗ | Неправильно указан формат!\n✔ | Правильный формат: !ставка [орел/решка] [сумма]")
if user_id not in money_bag:
send("❗ | Вы ещё не завели себе кошелёк.\n✔ | Кошелёк можно завести командой: !кошелёк")
if money_bag[user_id] < int(value_rate):
send("❗ | Вам не хватает средств чтобы сделать ставку на эту сумму.")
if money_bag[user_id] == int(value_rate):
send("❗ | Нельзя ставить весь кошелёк как ставку.")
if value_rate:
if get_side in sides:
if user_id in money_bag:
if money_bag[user_id] >= int(value_rate):
if money_bag[user_id] != int(value_rate):
coin_side = random.randint(1,100)
if coin_side <= 40:
money_bag[user_id] = money = money + int(value_rate)
with open('money_bag.txt','w') as f:
for key,val in money_bag.items():
f.write('{}:{}\n'.format(key,val))
send("✔ | Вы победили!\n | Вам зачислено " + str(value_rate) + " руб.")
else:
money_bag[user_id] = money = money - int(value_rate)
with open('money_bag.txt','w') as f:
for key,val in money_bag.items():
f.write('{}:{}\n'.format(key,val))
send("❌ | Вы проиграли!\n | С вашего счёта списано " + str(value_rate) + " руб.")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question