Skip to content
Open navbar menu
Sign UpLog In

Community

#gta
PromptFinder
Profile picture for CoderGautamYTCoderGautamYT
DATA
Profile picture for SteveMoracoSteveMoraco
Diplop
Profile picture for mathieufloresmathieuflores
Explore the Community HubSubmit a Deployment
Community Hub
Submit Deployment
FEATURED
LenaAtReplit
Welcome to the Replit Community!
jeff
Announcing Ghostwriter Chat
TOP TAGS
#python
#javascript
#ai
#apps
#html
#fun
#game
#simple
#python3
#java
#cpp
#bash
#Css
#c
Alex0120
Alex0120
published a Repl
20 days ago
4
GTA 5 In Python!
GTA 5 In Python!there is a 60s timer in between heists btw.
IndaLin
IndaLin
try to use this kind of code to save: import pickle # Import the pickle module for serialization # ... (your existing code) # Function to save the game state def save_game(): game_state = { 'damage': damage, 'xp': xp, 'kills': kills, 'cash': cash, 'hp': hp, 'current_rank': current_rank, 'inventory': inventory, # Add other relevant variables } with open('save_game.pkl', 'wb') as file: pickle.dump(game_state, file) print("Game saved successfully.") # Function to load the game state def load_game(): try: with open('save_game.pkl', 'rb') as file: loaded_state = pickle.load(file) # Update current state with the loaded state global damage, xp, kills, cash, hp, current_rank, inventory damage = loaded_state['damage'] xp = loaded_state['xp'] kills = loaded_state['kills'] cash = loaded_state['cash'] hp = loaded_state['hp'] current_rank = loaded_state['current_rank'] inventory = loaded_state['inventory'] # Update other relevant variables print("Game loaded successfully.") except FileNotFoundError: print("No saved game found.") # ... (continue your existing code) # Example: Call the save_game function when needed # For example, you might want to call this function when the player decides to save the game. # You can add this option in your game menu or at specific points in the game. # save_game() # Example: Call the load_game function at the beginning of your script to load the saved game state # load_game() # ... (continue your existing code) 18 days ago
IndaLin
IndaLin
I think you should just ask chat gpt18 days ago