Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import s_taper
- from s_taper.consts import *
- scheme = {
- "userid": INT + KEY,
- "inv": TEXT
- }
- players = s_taper.Taper("players", "data.db").create_table(scheme)
- def check_inv(player: int):
- inv = players.read("userid", player)
- text = f"Инвентарь:\n"
- inv = inv[1]
- for name, amount in inv.items():
- text += f"{name}: {amount}\n"
- print(text)
- def add_item_to_inv(player: int, item: tuple[str, int]):
- data = players.read("userid", player)
- inv = data[1]
- inv[item[0]] = item[1]
- players.write([player, inv])
- if __name__ == '__main__':
- while True:
- if input("mode: ") == "1":
- userid = int(input("Enter userid: "))
- check_inv(userid)
- else:
- userid = int(input("Enter userid: "))
- name = input("Enter item name: ")
- amount = int(input("Enter amount: "))
- add_item_to_inv(userid, (name, amount))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement